var Utt=Object.defineProperty;var INe=t=>{throw TypeError(t)};var qtt=(t,s,r)=>s in t?Utt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var hn=(t,s,r)=>qtt(t,typeof s!="symbol"?s+"":s,r),Vde=(t,s,r)=>s.has(t)||INe("Cannot "+r);var ls=(t,s,r)=>(Vde(t,s,"read from private field"),r?r.call(t):s.get(t)),Aa=(t,s,r)=>s.has(t)?INe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),In=(t,s,r,n)=>(Vde(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Ii=(t,s,r)=>(Vde(t,s,"access private method"),r);var lO=(t,s,r,n)=>({set _(a){In(t,s,a,r)},get _(){return ls(t,s,n)}});function Vtt(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 By=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function $6e(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 U6e={exports:{}},Yae={},q6e={exports:{}},to={};/** * @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 g6=Symbol.for("react.element"),Htt=Symbol.for("react.portal"),Wtt=Symbol.for("react.fragment"),Gtt=Symbol.for("react.strict_mode"),Ktt=Symbol.for("react.profiler"),Ztt=Symbol.for("react.provider"),Ytt=Symbol.for("react.context"),Xtt=Symbol.for("react.forward_ref"),Qtt=Symbol.for("react.suspense"),Jtt=Symbol.for("react.memo"),est=Symbol.for("react.lazy"),PNe=Symbol.iterator;function tst(t){return t===null||typeof t!="object"?null:(t=PNe&&t[PNe]||t["@@iterator"],typeof t=="function"?t:null)}var V6e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},H6e=Object.assign,W6e={};function k3(t,s,r){this.props=t,this.context=s,this.refs=W6e,this.updater=r||V6e}k3.prototype.isReactComponent={};k3.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")};k3.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function G6e(){}G6e.prototype=k3.prototype;function Qye(t,s,r){this.props=t,this.context=s,this.refs=W6e,this.updater=r||V6e}var Jye=Qye.prototype=new G6e;Jye.constructor=Qye;H6e(Jye,k3.prototype);Jye.isPureReactComponent=!0;var LNe=Array.isArray,K6e=Object.prototype.hasOwnProperty,e0e={current:null},Z6e={key:!0,ref:!0,__self:!0,__source:!0};function Y6e(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)K6e.call(s,n)&&!Z6e.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,ye=ce[ve];if(0>>1;vea(Ae,Te))Eea(He,Ae)?(ce[ve]=He,ce[Ee]=Te,ve=Ee):(ce[ve]=Ae,ce[Ke]=Te,ve=Ke);else if(Eea(He,Te))ce[ve]=He,ce[Ee]=Te,ve=Ee;else break e}}return ge}function a(ce,ge){var Te=ce.sortIndex-ge.sortIndex;return Te!==0?Te:ce.id-ge.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=[],h=[],f=1,g=null,v=3,_=!1,j=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(ce){for(var ge=r(h);ge!==null;){if(ge.callback===null)n(h);else if(ge.startTime<=ce)n(h),ge.sortIndex=ge.expirationTime,s(d,ge);else break;ge=r(h)}}function D(ce){if(w=!1,E(ce),!j)if(r(d)!==null)j=!0,oe(L);else{var ge=r(h);ge!==null&&ue(D,ge.startTime-ce)}}function L(ce,ge){j=!1,w&&(w=!1,M(V),V=-1),_=!0;var Te=v;try{for(E(ge),g=r(d);g!==null&&(!(g.expirationTime>ge)||ce&&!J());){var ve=g.callback;if(typeof ve=="function"){g.callback=null,v=g.priorityLevel;var ye=ve(g.expirationTime<=ge);ge=t.unstable_now(),typeof ye=="function"?g.callback=ye:g===r(d)&&n(d),E(ge)}else n(d);g=r(d)}if(g!==null)var Se=!0;else{var Ke=r(h);Ke!==null&&ue(D,Ke.startTime-ge),Se=!1}return Se}finally{g=null,v=Te,_=!1}}var B=!1,$=null,V=-1,W=5,G=-1;function J(){return!(t.unstable_now()-Gce||125ve?(ce.sortIndex=Te,s(h,ce),r(d)===null&&ce===r(h)&&(w?(M(V),V=-1):w=!0,ue(D,Te-ve))):(ce.sortIndex=ye,s(d,ce),j||_||(j=!0,oe(L))),ce},t.unstable_shouldYield=J,t.unstable_wrapCallback=function(ce){var ge=v;return function(){var Te=v;v=ge;try{return ce.apply(this,arguments)}finally{v=Te}}}})(tLe);eLe.exports=tLe;var hst=eLe.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 mst=T,ap=hst;function Ur(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"),qme=Object.prototype.hasOwnProperty,pst=/^[: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]*$/,ONe={},RNe={};function fst(t){return qme.call(RNe,t)?!0:qme.call(ONe,t)?!1:pst.test(t)?RNe[t]=!0:(ONe[t]=!0,!1)}function gst(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 xst(t,s,r,n){if(s===null||typeof s>"u"||gst(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 Eh(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 Eh(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 Eh(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){bu[t]=new Eh(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){bu[t]=new Eh(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 Eh(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){bu[t]=new Eh(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){bu[t]=new Eh(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){bu[t]=new Eh(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){bu[t]=new Eh(t,5,!1,t.toLowerCase(),null,!1,!1)});var r0e=/[\-:]([a-z])/g;function n0e(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(r0e,n0e);bu[s]=new Eh(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(r0e,n0e);bu[s]=new Eh(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(r0e,n0e);bu[s]=new Eh(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){bu[t]=new Eh(t,1,!1,t.toLowerCase(),null,!1,!1)});bu.xlinkHref=new Eh("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){bu[t]=new Eh(t,1,!1,t.toLowerCase(),null,!0,!0)});function a0e(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{Gde=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?WA(t):""}function yst(t){switch(t.tag){case 5:return WA(t.type);case 16:return WA("Lazy");case 13:return WA("Suspense");case 19:return WA("SuspenseList");case 0:case 2:case 15:return t=Kde(t.type,!1),t;case 11:return t=Kde(t.type.render,!1),t;case 1:return t=Kde(t.type,!0),t;default:return""}}function Gme(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 WC:return"Fragment";case HC:return"Portal";case Vme:return"Profiler";case i0e:return"StrictMode";case Hme:return"Suspense";case Wme:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case nLe:return(t.displayName||"Context")+".Consumer";case rLe:return(t._context.displayName||"Context")+".Provider";case o0e:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case l0e:return s=t.displayName||null,s!==null?s:Gme(t.type)||"Memo";case Mv:s=t._payload,t=t._init;try{return Gme(t(s))}catch{}}return null}function vst(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 Gme(s);case 8:return s===i0e?"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 V1(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function iLe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function _st(t){var s=iLe(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 uO(t){t._valueTracker||(t._valueTracker=_st(t))}function oLe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=iLe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function qse(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 Kme(t,s){var r=s.checked;return pc({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function zNe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=V1(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 lLe(t,s){s=s.checked,s!=null&&a0e(t,"checked",s,!1)}function Zme(t,s){lLe(t,s);var r=V1(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")?Yme(t,s.type,r):s.hasOwnProperty("defaultValue")&&Yme(t,s.type,V1(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function BNe(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 Yme(t,s,r){(s!=="number"||qse(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var GA=Array.isArray;function g4(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=hO.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function II(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var lE={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},bst=["Webkit","ms","Moz","O"];Object.keys(lE).forEach(function(t){bst.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),lE[s]=lE[t]})});function hLe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||lE.hasOwnProperty(t)&&lE[t]?(""+s).trim():s+"px"}function mLe(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=hLe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var wst=pc({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 Jme(t,s){if(s){if(wst[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Ur(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Ur(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Ur(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Ur(62))}}function epe(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 tpe=null;function c0e(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var spe=null,x4=null,y4=null;function qNe(t){if(t=v6(t)){if(typeof spe!="function")throw Error(Ur(280));var s=t.stateNode;s&&(s=tie(s),spe(t.stateNode,t.type,s))}}function pLe(t){x4?y4?y4.push(t):y4=[t]:x4=t}function fLe(){if(x4){var t=x4,s=y4;if(y4=x4=null,qNe(t),s)for(t=0;t>>=0,t===0?32:31-(Pst(t)/Lst|0)|0}var mO=64,pO=4194304;function KA(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 Gse(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=KA(i):(o&=l,o!==0&&(n=KA(o)))}else l=r&~a,l!==0?n=KA(l):o!==0&&(n=KA(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 x6(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-lg(s),t[s]=r}function Fst(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=dE),QNe=" ",JNe=!1;function DLe(t,s){switch(t){case"keyup":return hrt.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function OLe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var GC=!1;function prt(t,s){switch(t){case"compositionend":return OLe(s);case"keypress":return s.which!==32?null:(JNe=!0,QNe);case"textInput":return t=s.data,t===QNe&&JNe?null:t;default:return null}}function frt(t,s){if(GC)return t==="compositionend"||!x0e&&DLe(t,s)?(t=PLe(),$8=p0e=a1=null,GC=!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=rSe(r)}}function BLe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?BLe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function $Le(){for(var t=window,s=qse();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=qse(t.document)}return s}function y0e(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 krt(t){var s=$Le(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&BLe(r.ownerDocument.documentElement,r)){if(n!==null&&y0e(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=nSe(r,o);var l=nSe(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,KC=null,lpe=null,hE=null,cpe=!1;function aSe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;cpe||KC==null||KC!==qse(n)||(n=KC,"selectionStart"in n&&y0e(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}),hE&&FI(hE,n)||(hE=n,n=Yse(lpe,"onSelect"),0XC||(t.current=fpe[XC],fpe[XC]=null,XC--)}function gl(t,s){XC++,fpe[XC]=t.current,t.current=s}var H1={},$u=s_(H1),nm=s_(!1),Wk=H1;function S5(t,s){var r=t.type.contextTypes;if(!r)return H1;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===s)return n.__reactInternalMemoizedMaskedChildContext;var a={},o;for(o in r)a[o]=s[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=a),a}function am(t){return t=t.childContextTypes,t!=null}function Qse(){Pl(nm),Pl($u)}function hSe(t,s,r){if($u.current!==H1)throw Error(Ur(168));gl($u,s),gl(nm,r)}function YLe(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(Ur(108,vst(t)||"Unknown",a));return pc({},r,n)}function Jse(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||H1,Wk=$u.current,gl($u,t),gl(nm,nm.current),!0}function mSe(t,s,r){var n=t.stateNode;if(!n)throw Error(Ur(169));r?(t=YLe(t,s,Wk),n.__reactInternalMemoizedMergedChildContext=t,Pl(nm),Pl($u),gl($u,t)):Pl(nm),gl(nm,r)}var Ly=null,sie=!1,lue=!1;function XLe(t){Ly===null?Ly=[t]:Ly.push(t)}function Ort(t){sie=!0,XLe(t)}function r_(){if(!lue&&Ly!==null){lue=!0;var t=0,s=Ho;try{var r=Ly;for(Ho=1;t>=l,a-=l,$y=1<<32-lg(s)+a|r<V?(W=$,$=null):W=$.sibling;var G=v(M,$,E[V],D);if(G===null){$===null&&($=W);break}t&&$&&G.alternate===null&&s(M,$),S=o(G,S,V),B===null?L=G:B.sibling=G,B=G,$=W}if(V===E.length)return r(M,$),ql&&yb(M,V),L;if($===null){for(;VV?(W=$,$=null):W=$.sibling;var J=v(M,$,G.value,D);if(J===null){$===null&&($=W);break}t&&$&&J.alternate===null&&s(M,$),S=o(J,S,V),B===null?L=J:B.sibling=J,B=J,$=W}if(G.done)return r(M,$),ql&&yb(M,V),L;if($===null){for(;!G.done;V++,G=E.next())G=g(M,G.value,D),G!==null&&(S=o(G,S,V),B===null?L=G:B.sibling=G,B=G);return ql&&yb(M,V),L}for($=n(M,$);!G.done;V++,G=E.next())G=_($,M,V,G.value,D),G!==null&&(t&&G.alternate!==null&&$.delete(G.key===null?V:G.key),S=o(G,S,V),B===null?L=G:B.sibling=G,B=G);return t&&$.forEach(function(ne){return s(M,ne)}),ql&&yb(M,V),L}function k(M,S,E,D){if(typeof E=="object"&&E!==null&&E.type===WC&&E.key===null&&(E=E.props.children),typeof E=="object"&&E!==null){switch(E.$$typeof){case dO:e:{for(var L=E.key,B=S;B!==null;){if(B.key===L){if(L=E.type,L===WC){if(B.tag===7){r(M,B.sibling),S=a(B,E.props.children),S.return=M,M=S;break e}}else if(B.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===Mv&&gSe(L)===B.type){r(M,B.sibling),S=a(B,E.props),S.ref=hA(M,B,E),S.return=M,M=S;break e}r(M,B);break}else s(M,B);B=B.sibling}E.type===WC?(S=gk(E.props.children,M.mode,D,E.key),S.return=M,M=S):(D=Z8(E.type,E.key,E.props,null,M.mode,D),D.ref=hA(M,S,E),D.return=M,M=D)}return l(M);case HC:e:{for(B=E.key;S!==null;){if(S.key===B)if(S.tag===4&&S.stateNode.containerInfo===E.containerInfo&&S.stateNode.implementation===E.implementation){r(M,S.sibling),S=a(S,E.children||[]),S.return=M,M=S;break e}else{r(M,S);break}else s(M,S);S=S.sibling}S=gue(E,M.mode,D),S.return=M,M=S}return l(M);case Mv:return B=E._init,k(M,S,B(E._payload),D)}if(GA(E))return j(M,S,E,D);if(oA(E))return w(M,S,E,D);bO(M,E)}return typeof E=="string"&&E!==""||typeof E=="number"?(E=""+E,S!==null&&S.tag===6?(r(M,S.sibling),S=a(S,E),S.return=M,M=S):(r(M,S),S=fue(E,M.mode,D),S.return=M,M=S),l(M)):r(M,S)}return k}var M5=tDe(!0),sDe=tDe(!1),sre=s_(null),rre=null,e4=null,w0e=null;function j0e(){w0e=e4=rre=null}function k0e(t){var s=sre.current;Pl(sre),t._currentValue=s}function ype(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 _4(t,s){rre=t,w0e=e4=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(Xh=!0),t.firstContext=null)}function tf(t){var s=t._currentValue;if(w0e!==t)if(t={context:t,memoizedValue:s,next:null},e4===null){if(rre===null)throw Error(Ur(308));e4=t,rre.dependencies={lanes:0,firstContext:t}}else e4=e4.next=t;return s}var Vj=null;function N0e(t){Vj===null?Vj=[t]:Vj.push(t)}function rDe(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,N0e(s)):(r.next=a.next,a.next=r),s.interleaved=r,m0(t,n)}function m0(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 Tv=!1;function S0e(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function nDe(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 Ky(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function v1(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,_o&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,m0(t,r)}return a=n.interleaved,a===null?(s.next=s,N0e(n)):(s.next=a.next,a.next=s),n.interleaved=s,m0(t,r)}function q8(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,u0e(t,r)}}function xSe(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 nre(t,s,r,n){var a=t.updateQueue;Tv=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var d=i,h=d.next;d.next=null,l===null?o=h:l.next=h,l=d;var f=t.alternate;f!==null&&(f=f.updateQueue,i=f.lastBaseUpdate,i!==l&&(i===null?f.firstBaseUpdate=h:i.next=h,f.lastBaseUpdate=d))}if(o!==null){var g=a.baseState;l=0,f=h=d=null,i=o;do{var v=i.lane,_=i.eventTime;if((n&v)===v){f!==null&&(f=f.next={eventTime:_,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var j=t,w=i;switch(v=s,_=r,w.tag){case 1:if(j=w.payload,typeof j=="function"){g=j.call(_,g,v);break e}g=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=w.payload,v=typeof j=="function"?j.call(_,g,v):j,v==null)break e;g=pc({},g,v);break e;case 2:Tv=!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},f===null?(h=f=_,d=g):f=f.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(f===null&&(d=g),a.baseState=d,a.firstBaseUpdate=h,a.lastBaseUpdate=f,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);Zk|=l,t.lanes=l,t.memoizedState=g}}function ySe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=due.transition;due.transition={};try{t(!1),s()}finally{Ho=r,due.transition=n}}function bDe(){return sf().memoizedState}function Brt(t,s,r){var n=b1(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},wDe(t))jDe(s,r);else if(r=rDe(t,s,r,n),r!==null){var a=jh();cg(r,t,n,a),kDe(r,s,n)}}function $rt(t,s,r){var n=b1(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(wDe(t))jDe(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,yg(i,l)){var d=s.interleaved;d===null?(a.next=a,N0e(s)):(a.next=d.next,d.next=a),s.interleaved=a;return}}catch{}finally{}r=rDe(t,s,a,n),r!==null&&(a=jh(),cg(r,t,n,a),kDe(r,s,n))}}function wDe(t){var s=t.alternate;return t===uc||s!==null&&s===uc}function jDe(t,s){mE=ire=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function kDe(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,u0e(t,r)}}var ore={readContext:tf,useCallback:Mu,useContext:Mu,useEffect:Mu,useImperativeHandle:Mu,useInsertionEffect:Mu,useLayoutEffect:Mu,useMemo:Mu,useReducer:Mu,useRef:Mu,useState:Mu,useDebugValue:Mu,useDeferredValue:Mu,useTransition:Mu,useMutableSource:Mu,useSyncExternalStore:Mu,useId:Mu,unstable_isNewReconciler:!1},Urt={readContext:tf,useCallback:function(t,s){return rx().memoizedState=[t,s===void 0?null:s],t},useContext:tf,useEffect:_Se,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,H8(4194308,4,gDe.bind(null,s,t),r)},useLayoutEffect:function(t,s){return H8(4194308,4,t,s)},useInsertionEffect:function(t,s){return H8(4,2,t,s)},useMemo:function(t,s){var r=rx();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=rx();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=Brt.bind(null,uc,t),[n.memoizedState,t]},useRef:function(t){var s=rx();return t={current:t},s.memoizedState=t},useState:vSe,useDebugValue:L0e,useDeferredValue:function(t){return rx().memoizedState=t},useTransition:function(){var t=vSe(!1),s=t[0];return t=zrt.bind(null,t[1]),rx().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=uc,a=rx();if(ql){if(r===void 0)throw Error(Ur(407));r=r()}else{if(r=s(),Xd===null)throw Error(Ur(349));Kk&30||lDe(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,_Se(dDe.bind(null,n,o,t),[t]),n.flags|=2048,WI(9,cDe.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=rx(),s=Xd.identifierPrefix;if(ql){var r=Uy,n=$y;r=(n&~(1<<32-lg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=VI++,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[mx]=s,t[$I]=n,LDe(t,s,!1,!1),s.stateNode=t;e:{switch(l=epe(r,n),r){case"dialog":Tl("cancel",t),Tl("close",t),a=n;break;case"iframe":case"object":case"embed":Tl("load",t),a=n;break;case"video":case"audio":for(a=0;aE5&&(s.flags|=128,n=!0,mA(o,!1),s.lanes=4194304)}else{if(!n)if(t=are(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),mA(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!ql)return Tu(s),null}else 2*Vc()-o.renderingStartTime>E5&&r!==1073741824&&(s.flags|=128,n=!0,mA(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=Vc(),s.sibling=null,r=tc.current,gl(tc,n?r&1|2:r&1),s):(Tu(s),null);case 22:case 23:return B0e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?Pm&1073741824&&(Tu(s),s.subtreeFlags&6&&(s.flags|=8192)):Tu(s),null;case 24:return null;case 25:return null}throw Error(Ur(156,s.tag))}function Yrt(t,s){switch(_0e(s),s.tag){case 1:return am(s.type)&&Qse(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return T5(),Pl(nm),Pl($u),T0e(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return M0e(s),null;case 13:if(Pl(tc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Ur(340));C5()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return Pl(tc),null;case 4:return T5(),null;case 10:return k0e(s.type._context),null;case 22:case 23:return B0e(),null;case 24:return null;default:return null}}var jO=!1,Pu=!1,Xrt=typeof WeakSet=="function"?WeakSet:Set,$n=null;function t4(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){wc(t,s,n)}else r.current=null}function Cpe(t,s,r){try{r()}catch(n){wc(t,s,n)}}var ESe=!1;function Qrt(t,s){if(dpe=Kse,t=$Le(),y0e(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,h=0,f=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&&++h===a&&(i=l),v===o&&++f===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(upe={focusedElem:t,selectionRange:r},Kse=!1,$n=s;$n!==null;)if(s=$n,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,$n=t;else for(;$n!==null;){s=$n;try{var j=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var w=j.memoizedProps,k=j.memoizedState,M=s.stateNode,S=M.getSnapshotBeforeUpdate(s.elementType===s.type?w:Hf(s.type,w),k);M.__reactInternalSnapshotBeforeUpdate=S}break;case 3:var E=s.stateNode.containerInfo;E.nodeType===1?E.textContent="":E.nodeType===9&&E.documentElement&&E.removeChild(E.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ur(163))}}catch(D){wc(s,s.return,D)}if(t=s.sibling,t!==null){t.return=s.return,$n=t;break}$n=s.return}return j=ESe,ESe=!1,j}function pE(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&&Cpe(s,r,o)}a=a.next}while(a!==n)}}function aie(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 Mpe(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 RDe(t){var s=t.alternate;s!==null&&(t.alternate=null,RDe(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[mx],delete s[$I],delete s[ppe],delete s[Lrt],delete s[Drt])),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 FDe(t){return t.tag===5||t.tag===3||t.tag===4}function ISe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||FDe(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 Tpe(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=Xse));else if(n!==4&&(t=t.child,t!==null))for(Tpe(t,s,r),t=t.sibling;t!==null;)Tpe(t,s,r),t=t.sibling}function Ape(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(Ape(t,s,r),t=t.sibling;t!==null;)Ape(t,s,r),t=t.sibling}var hu=null,Zf=!1;function fv(t,s,r){for(r=r.child;r!==null;)zDe(t,s,r),r=r.sibling}function zDe(t,s,r){if(_x&&typeof _x.onCommitFiberUnmount=="function")try{_x.onCommitFiberUnmount(Xae,r)}catch{}switch(r.tag){case 5:Pu||t4(r,s);case 6:var n=hu,a=Zf;hu=null,fv(t,s,r),hu=n,Zf=a,hu!==null&&(Zf?(t=hu,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):hu.removeChild(r.stateNode));break;case 18:hu!==null&&(Zf?(t=hu,r=r.stateNode,t.nodeType===8?oue(t.parentNode,r):t.nodeType===1&&oue(t,r),OI(t)):oue(hu,r.stateNode));break;case 4:n=hu,a=Zf,hu=r.stateNode.containerInfo,Zf=!0,fv(t,s,r),hu=n,Zf=a;break;case 0:case 11:case 14:case 15:if(!Pu&&(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)&&Cpe(r,s,l),a=a.next}while(a!==n)}fv(t,s,r);break;case 1:if(!Pu&&(t4(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){wc(r,s,i)}fv(t,s,r);break;case 21:fv(t,s,r);break;case 22:r.mode&1?(Pu=(n=Pu)||r.memoizedState!==null,fv(t,s,r),Pu=n):fv(t,s,r);break;default:fv(t,s,r)}}function PSe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Xrt),s.forEach(function(n){var a=ont.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function Of(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=Vc()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*ent(n/1960))-n,10t?16:t,i1===null)var n=!1;else{if(t=i1,i1=null,dre=0,_o&6)throw Error(Ur(331));var a=_o;for(_o|=4,$n=t.current;$n!==null;){var o=$n,l=o.child;if($n.flags&16){var i=o.deletions;if(i!==null){for(var d=0;dVc()-F0e?fk(t,0):R0e|=r),im(t,s)}function GDe(t,s){s===0&&(t.mode&1?(s=pO,pO<<=1,!(pO&130023424)&&(pO=4194304)):s=1);var r=jh();t=m0(t,s),t!==null&&(x6(t,s,r),im(t,r))}function int(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),GDe(t,r)}function ont(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(Ur(314))}n!==null&&n.delete(s),GDe(t,r)}var KDe;KDe=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||nm.current)Xh=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return Xh=!1,Krt(t,s,r);Xh=!!(t.flags&131072)}else Xh=!1,ql&&s.flags&1048576&&QLe(s,tre,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;W8(t,s),t=s.pendingProps;var a=S5(s,$u.current);_4(s,r),a=E0e(null,s,n,t,a,r);var o=I0e();return s.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,am(n)?(o=!0,Jse(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,S0e(s),a.updater=nie,s.stateNode=a,a._reactInternals=s,_pe(s,n,t,r),s=jpe(null,s,n,!0,o,r)):(s.tag=0,ql&&o&&v0e(s),uh(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(W8(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=cnt(n),t=Hf(n,t),a){case 0:s=wpe(null,s,n,t,r);break e;case 1:s=MSe(null,s,n,t,r);break e;case 11:s=SSe(null,s,n,t,r);break e;case 14:s=CSe(null,s,n,Hf(n.type,t),r);break e}throw Error(Ur(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Hf(n,a),wpe(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Hf(n,a),MSe(t,s,n,a,r);case 3:e:{if(EDe(s),t===null)throw Error(Ur(387));n=s.pendingProps,o=s.memoizedState,a=o.element,nDe(t,s),nre(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=A5(Error(Ur(423)),s),s=TSe(t,s,n,r,a);break e}else if(n!==a){a=A5(Error(Ur(424)),s),s=TSe(t,s,n,r,a);break e}else for(qm=y1(s.stateNode.containerInfo.firstChild),Hm=s,ql=!0,Jf=null,r=sDe(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(C5(),n===a){s=p0(t,s,r);break e}uh(t,s,n,r)}s=s.child}return s;case 5:return aDe(s),t===null&&xpe(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,hpe(n,a)?l=null:o!==null&&hpe(n,o)&&(s.flags|=32),ADe(t,s),uh(t,s,l,r),s.child;case 6:return t===null&&xpe(s),null;case 13:return IDe(t,s,r);case 4:return C0e(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=M5(s,null,n,r):uh(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Hf(n,a),SSe(t,s,n,a,r);case 7:return uh(t,s,s.pendingProps,r),s.child;case 8:return uh(t,s,s.pendingProps.children,r),s.child;case 12:return uh(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,gl(sre,n._currentValue),n._currentValue=l,o!==null)if(yg(o.value,l)){if(o.children===a.children&&!nm.current){s=p0(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=Ky(-1,r&-r),d.tag=2;var h=o.updateQueue;if(h!==null){h=h.shared;var f=h.pending;f===null?d.next=d:(d.next=f.next,f.next=d),h.pending=d}}o.lanes|=r,d=o.alternate,d!==null&&(d.lanes|=r),ype(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(Ur(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),ype(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}uh(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,_4(s,r),a=tf(a),n=n(a),s.flags|=1,uh(t,s,n,r),s.child;case 14:return n=s.type,a=Hf(n,s.pendingProps),a=Hf(n.type,a),CSe(t,s,n,a,r);case 15:return MDe(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Hf(n,a),W8(t,s),s.tag=1,am(n)?(t=!0,Jse(s)):t=!1,_4(s,r),NDe(s,n,a),_pe(s,n,a,r),jpe(null,s,n,!0,t,r);case 19:return PDe(t,s,r);case 22:return TDe(t,s,r)}throw Error(Ur(156,s.tag))};function ZDe(t,s){return wLe(t,s)}function lnt(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 $p(t,s,r,n){return new lnt(t,s,r,n)}function U0e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function cnt(t){if(typeof t=="function")return U0e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===o0e)return 11;if(t===l0e)return 14}return 2}function w1(t,s){var r=t.alternate;return r===null?(r=$p(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 Z8(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")U0e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case WC:return gk(r.children,a,o,s);case i0e:l=8,a|=8;break;case Vme:return t=$p(12,r,s,a|2),t.elementType=Vme,t.lanes=o,t;case Hme:return t=$p(13,r,s,a),t.elementType=Hme,t.lanes=o,t;case Wme:return t=$p(19,r,s,a),t.elementType=Wme,t.lanes=o,t;case aLe:return oie(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case rLe:l=10;break e;case nLe:l=9;break e;case o0e:l=11;break e;case l0e:l=14;break e;case Mv:l=16,n=null;break e}throw Error(Ur(130,t==null?t:typeof t,""))}return s=$p(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function gk(t,s,r,n){return t=$p(7,t,n,s),t.lanes=r,t}function oie(t,s,r,n){return t=$p(22,t,n,s),t.elementType=aLe,t.lanes=r,t.stateNode={isHidden:!1},t}function fue(t,s,r){return t=$p(6,t,null,s),t.lanes=r,t}function gue(t,s,r){return s=$p(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function dnt(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=Yde(0),this.expirationTimes=Yde(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yde(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function q0e(t,s,r,n,a,o,l,i,d){return t=new dnt(t,s,r,i,d),s===1?(s=1,o===!0&&(s|=8)):s=0,o=$p(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},S0e(o),t}function unt(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(JDe)}catch(t){console.error(t)}}JDe(),J6e.exports=lp;var Qh=J6e.exports;const G0e=fo(Qh);var eOe,$Se=Qh;eOe=$Se.createRoot,$Se.hydrateRoot;const gnt=1,xnt=1e6;let xue=0;function ynt(){return xue=(xue+1)%Number.MAX_SAFE_INTEGER,xue.toString()}const yue=new Map,USe=t=>{if(yue.has(t))return;const s=setTimeout(()=>{yue.delete(t),xE({type:"REMOVE_TOAST",toastId:t})},xnt);yue.set(t,s)},vnt=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,gnt)};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?USe(r):t.toasts.forEach(n=>{USe(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)}}},Y8=[];let X8={toasts:[]};function xE(t){X8=vnt(X8,t),Y8.forEach(s=>{s(X8)})}function pn({...t}){const s=ynt(),r=a=>xE({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>xE({type:"DISMISS_TOAST",toastId:s});return xE({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Sa(){const[t,s]=T.useState(X8);return T.useEffect(()=>(Y8.push(s),()=>{const r=Y8.indexOf(s);r>-1&&Y8.splice(r,1)}),[t]),{...t,toast:pn,dismiss:r=>xE({type:"DISMISS_TOAST",toastId:r})}}function kr(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 qSe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function f0(...t){return s=>{let r=!1;const n=t.map(a=>{const o=qSe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=T.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,children:l})};n.displayName=t+"Provider";function a(o){const l=T.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 Dc(t,s=[]){let r=[];function n(o,l){const i=T.createContext(l),d=r.length;r=[...r,l];const h=g=>{var M;const{scope:v,children:_,...j}=g,w=((M=v==null?void 0:v[t])==null?void 0:M[d])||i,k=T.useMemo(()=>j,Object.values(j));return e.jsx(w.Provider,{value:k,children:_})};h.displayName=o+"Provider";function f(g,v){var w;const _=((w=v==null?void 0:v[t])==null?void 0:w[d])||i,j=T.useContext(_);if(j)return j;if(l!==void 0)return l;throw new Error(`\`${g}\` must be used within \`${o}\``)}return[h,f]}const a=()=>{const o=r.map(l=>T.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return T.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,bnt(a,...s)]}function bnt(...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:h})=>{const g=d(o)[`__scope${h}`];return{...i,...g}},{});return T.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function W1(t){const s=wnt(t),r=T.forwardRef((n,a)=>{const{children:o,...l}=n,i=T.Children.toArray(o),d=i.find(jnt);if(d){const h=d.props.children,f=i.map(g=>g===d?T.Children.count(h)>1?T.Children.only(null):T.isValidElement(h)?h.props.children:null:g);return e.jsx(s,{...l,ref:a,children:T.isValidElement(h)?T.cloneElement(h,void 0,f):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var K0e=W1("Slot");function wnt(t){const s=T.forwardRef((r,n)=>{const{children:a,...o}=r;if(T.isValidElement(a)){const l=Nnt(a),i=knt(o,a.props);return a.type!==T.Fragment&&(i.ref=n?f0(n,l):l),T.cloneElement(a,i)}return T.Children.count(a)>1?T.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var tOe=Symbol("radix.slottable");function sOe(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=tOe,s}function jnt(t){return T.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===tOe}function knt(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 Nnt(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 b6(t){const s=t+"CollectionProvider",[r,n]=Dc(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=w=>{const{scope:k,children:M}=w,S=lt.useRef(null),E=lt.useRef(new Map).current;return e.jsx(a,{scope:k,itemMap:E,collectionRef:S,children:M})};l.displayName=s;const i=t+"CollectionSlot",d=W1(i),h=lt.forwardRef((w,k)=>{const{scope:M,children:S}=w,E=o(i,M),D=ba(k,E.collectionRef);return e.jsx(d,{ref:D,children:S})});h.displayName=i;const f=t+"CollectionItemSlot",g="data-radix-collection-item",v=W1(f),_=lt.forwardRef((w,k)=>{const{scope:M,children:S,...E}=w,D=lt.useRef(null),L=ba(k,D),B=o(f,M);return lt.useEffect(()=>(B.itemMap.set(D,{ref:D,...E}),()=>void B.itemMap.delete(D))),e.jsx(v,{[g]:"",ref:L,children:S})});_.displayName=f;function j(w){const k=o(t+"CollectionConsumer",w);return lt.useCallback(()=>{const S=k.collectionRef.current;if(!S)return[];const E=Array.from(S.querySelectorAll(`[${g}]`));return Array.from(k.itemMap.values()).sort((B,$)=>E.indexOf(B.ref.current)-E.indexOf($.ref.current))},[k.collectionRef,k.itemMap])}return[{Provider:l,Slot:h,ItemSlot:_},j,n]}var Snt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Qr=Snt.reduce((t,s)=>{const r=W1(`Primitive.${s}`),n=T.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 Z0e(t,s){t&&Qh.flushSync(()=>t.dispatchEvent(s))}function Ac(t){const s=T.useRef(t);return T.useEffect(()=>{s.current=t}),T.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function Cnt(t,s=globalThis==null?void 0:globalThis.document){const r=Ac(t);T.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 Mnt="DismissableLayer",Dpe="dismissableLayer.update",Tnt="dismissableLayer.pointerDownOutside",Ant="dismissableLayer.focusOutside",VSe,rOe=T.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),n_=T.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,h=T.useContext(rOe),[f,g]=T.useState(null),v=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=T.useState({}),j=ba(s,$=>g($)),w=Array.from(h.layers),[k]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),M=w.indexOf(k),S=f?w.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,D=S>=M,L=Int($=>{const V=$.target,W=[...h.branches].some(G=>G.contains(V));!D||W||(a==null||a($),l==null||l($),$.defaultPrevented||i==null||i())},v),B=Pnt($=>{const V=$.target;[...h.branches].some(G=>G.contains(V))||(o==null||o($),l==null||l($),$.defaultPrevented||i==null||i())},v);return Cnt($=>{S===h.layers.size-1&&(n==null||n($),!$.defaultPrevented&&i&&($.preventDefault(),i()))},v),T.useEffect(()=>{if(f)return r&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(VSe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),HSe(),()=>{r&&h.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=VSe)}},[f,v,r,h]),T.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),HSe())},[f,h]),T.useEffect(()=>{const $=()=>_({});return document.addEventListener(Dpe,$),()=>document.removeEventListener(Dpe,$)},[]),e.jsx(Qr.div,{...d,ref:j,style:{pointerEvents:E?D?"auto":"none":void 0,...t.style},onFocusCapture:kr(t.onFocusCapture,B.onFocusCapture),onBlurCapture:kr(t.onBlurCapture,B.onBlurCapture),onPointerDownCapture:kr(t.onPointerDownCapture,L.onPointerDownCapture)})});n_.displayName=Mnt;var Ent="DismissableLayerBranch",nOe=T.forwardRef((t,s)=>{const r=T.useContext(rOe),n=T.useRef(null),a=ba(s,n);return T.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})});nOe.displayName=Ent;function Int(t,s=globalThis==null?void 0:globalThis.document){const r=Ac(t),n=T.useRef(!1),a=T.useRef(()=>{});return T.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){aOe(Tnt,r,h,{discrete:!0})};const h={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 Pnt(t,s=globalThis==null?void 0:globalThis.document){const r=Ac(t),n=T.useRef(!1);return T.useEffect(()=>{const a=o=>{o.target&&!n.current&&aOe(Ant,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 HSe(){const t=new CustomEvent(Dpe);document.dispatchEvent(t)}function aOe(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?Z0e(a,o):a.dispatchEvent(o)}var Lnt=n_,Dnt=nOe,Pc=globalThis!=null&&globalThis.document?T.useLayoutEffect:()=>{},Ont="Portal",C3=T.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=T.useState(!1);Pc(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?G0e.createPortal(e.jsx(Qr.div,{...n,ref:s}),l):null});C3.displayName=Ont;function Rnt(t,s){return T.useReducer((r,n)=>s[r][n]??r,t)}var Qc=t=>{const{present:s,children:r}=t,n=Fnt(s),a=typeof r=="function"?r({present:n.isPresent}):T.Children.only(r),o=ba(n.ref,znt(a));return typeof r=="function"||n.isPresent?T.cloneElement(a,{ref:o}):null};Qc.displayName="Presence";function Fnt(t){const[s,r]=T.useState(),n=T.useRef(null),a=T.useRef(t),o=T.useRef("none"),l=t?"mounted":"unmounted",[i,d]=Rnt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return T.useEffect(()=>{const h=SO(n.current);o.current=i==="mounted"?h:"none"},[i]),Pc(()=>{const h=n.current,f=a.current;if(f!==t){const v=o.current,_=SO(h);t?d("MOUNT"):_==="none"||(h==null?void 0:h.display)==="none"?d("UNMOUNT"):d(f&&v!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,d]),Pc(()=>{if(s){let h;const f=s.ownerDocument.defaultView??window,g=_=>{const w=SO(n.current).includes(_.animationName);if(_.target===s&&w&&(d("ANIMATION_END"),!a.current)){const k=s.style.animationFillMode;s.style.animationFillMode="forwards",h=f.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=k)})}},v=_=>{_.target===s&&(o.current=SO(n.current))};return s.addEventListener("animationstart",v),s.addEventListener("animationcancel",g),s.addEventListener("animationend",g),()=>{f.clearTimeout(h),s.removeEventListener("animationstart",v),s.removeEventListener("animationcancel",g),s.removeEventListener("animationend",g)}}else d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:T.useCallback(h=>{n.current=h?getComputedStyle(h):null,r(h)},[])}}function SO(t){return(t==null?void 0:t.animationName)||"none"}function znt(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 Bnt=s0e[" useInsertionEffect ".trim().toString()]||Pc;function Sh({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=$nt({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const f=T.useRef(t!==void 0);T.useEffect(()=>{const g=f.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.`),f.current=i},[i,n])}const h=T.useCallback(f=>{var g;if(i){const v=Unt(f)?f(t):f;v!==t&&((g=l.current)==null||g.call(l,v))}else o(f)},[i,t,o,l]);return[d,h]}function $nt({defaultProp:t,onChange:s}){const[r,n]=T.useState(t),a=T.useRef(r),o=T.useRef(s);return Bnt(()=>{o.current=s},[s]),T.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function Unt(t){return typeof t=="function"}var iOe=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"}),qnt="VisuallyHidden",hie=T.forwardRef((t,s)=>e.jsx(Qr.span,{...t,ref:s,style:{...iOe,...t.style}}));hie.displayName=qnt;var Vnt=hie,Y0e="ToastProvider",[X0e,Hnt,Wnt]=b6("Toast"),[oOe]=Dc("Toast",[Wnt]),[Gnt,mie]=oOe(Y0e),lOe=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=T.useState(null),[h,f]=T.useState(0),g=T.useRef(!1),v=T.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${Y0e}\`. Expected non-empty \`string\`.`),e.jsx(X0e.Provider,{scope:s,children:e.jsx(Gnt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:h,viewport:i,onViewportChange:d,onToastAdd:T.useCallback(()=>f(_=>_+1),[]),onToastRemove:T.useCallback(()=>f(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:v,children:l})})};lOe.displayName=Y0e;var cOe="ToastViewport",Knt=["F8"],Ope="toast.viewportPause",Rpe="toast.viewportResume",dOe=T.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=Knt,label:a="Notifications ({hotkey})",...o}=t,l=mie(cOe,r),i=Hnt(r),d=T.useRef(null),h=T.useRef(null),f=T.useRef(null),g=T.useRef(null),v=ba(s,g,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),j=l.toastCount>0;T.useEffect(()=>{const k=M=>{var E;n.length!==0&&n.every(D=>M[D]||M.code===D)&&((E=g.current)==null||E.focus())};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[n]),T.useEffect(()=>{const k=d.current,M=g.current;if(j&&k&&M){const S=()=>{if(!l.isClosePausedRef.current){const B=new CustomEvent(Ope);M.dispatchEvent(B),l.isClosePausedRef.current=!0}},E=()=>{if(l.isClosePausedRef.current){const B=new CustomEvent(Rpe);M.dispatchEvent(B),l.isClosePausedRef.current=!1}},D=B=>{!k.contains(B.relatedTarget)&&E()},L=()=>{k.contains(document.activeElement)||E()};return k.addEventListener("focusin",S),k.addEventListener("focusout",D),k.addEventListener("pointermove",S),k.addEventListener("pointerleave",L),window.addEventListener("blur",S),window.addEventListener("focus",E),()=>{k.removeEventListener("focusin",S),k.removeEventListener("focusout",D),k.removeEventListener("pointermove",S),k.removeEventListener("pointerleave",L),window.removeEventListener("blur",S),window.removeEventListener("focus",E)}}},[j,l.isClosePausedRef]);const w=T.useCallback(({tabbingDirection:k})=>{const S=i().map(E=>{const D=E.ref.current,L=[D,...oat(D)];return k==="forwards"?L:L.reverse()});return(k==="forwards"?S.reverse():S).flat()},[i]);return T.useEffect(()=>{const k=g.current;if(k){const M=S=>{var L,B,$;const E=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!E){const V=document.activeElement,W=S.shiftKey;if(S.target===k&&W){(L=h.current)==null||L.focus();return}const ne=w({tabbingDirection:W?"backwards":"forwards"}),ie=ne.findIndex(ee=>ee===V);vue(ne.slice(ie+1))?S.preventDefault():W?(B=h.current)==null||B.focus():($=f.current)==null||$.focus()}};return k.addEventListener("keydown",M),()=>k.removeEventListener("keydown",M)}},[i,w]),e.jsxs(Dnt,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:j?void 0:"none"},children:[j&&e.jsx(Fpe,{ref:h,onFocusFromOutsideViewport:()=>{const k=w({tabbingDirection:"forwards"});vue(k)}}),e.jsx(X0e.Slot,{scope:r,children:e.jsx(Qr.ol,{tabIndex:-1,...o,ref:v})}),j&&e.jsx(Fpe,{ref:f,onFocusFromOutsideViewport:()=>{const k=w({tabbingDirection:"backwards"});vue(k)}})]})});dOe.displayName=cOe;var uOe="ToastFocusProxy",Fpe=T.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=mie(uOe,r);return e.jsx(hie,{"aria-hidden":!0,tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:l=>{var h;const i=l.relatedTarget;!((h=o.viewport)!=null&&h.contains(i))&&n()}})});Fpe.displayName=uOe;var w6="Toast",Znt="toast.swipeStart",Ynt="toast.swipeMove",Xnt="toast.swipeCancel",Qnt="toast.swipeEnd",hOe=T.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,d]=Sh({prop:n,defaultProp:a??!0,onChange:o,caller:w6});return e.jsx(Qc,{present:r||i,children:e.jsx(tat,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:Ac(t.onPause),onResume:Ac(t.onResume),onSwipeStart:kr(t.onSwipeStart,h=>{h.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:kr(t.onSwipeMove,h=>{const{x:f,y:g}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","move"),h.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:kr(t.onSwipeCancel,h=>{h.currentTarget.setAttribute("data-swipe","cancel"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:kr(t.onSwipeEnd,h=>{const{x:f,y:g}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","end"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${f}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),d(!1)})})})});hOe.displayName=w6;var[Jnt,eat]=oOe(w6,{onClose(){}}),tat=T.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:h,onSwipeStart:f,onSwipeMove:g,onSwipeCancel:v,onSwipeEnd:_,...j}=t,w=mie(w6,r),[k,M]=T.useState(null),S=ba(s,ee=>M(ee)),E=T.useRef(null),D=T.useRef(null),L=a||w.duration,B=T.useRef(0),$=T.useRef(L),V=T.useRef(0),{onToastAdd:W,onToastRemove:G}=w,J=Ac(()=>{var de;(k==null?void 0:k.contains(document.activeElement))&&((de=w.viewport)==null||de.focus()),l()}),ne=T.useCallback(ee=>{!ee||ee===1/0||(window.clearTimeout(V.current),B.current=new Date().getTime(),V.current=window.setTimeout(J,ee))},[J]);T.useEffect(()=>{const ee=w.viewport;if(ee){const de=()=>{ne($.current),h==null||h()},oe=()=>{const ue=new Date().getTime()-B.current;$.current=$.current-ue,window.clearTimeout(V.current),d==null||d()};return ee.addEventListener(Ope,oe),ee.addEventListener(Rpe,de),()=>{ee.removeEventListener(Ope,oe),ee.removeEventListener(Rpe,de)}}},[w.viewport,L,d,h,ne]),T.useEffect(()=>{o&&!w.isClosePausedRef.current&&ne(L)},[o,L,w.isClosePausedRef,ne]),T.useEffect(()=>(W(),()=>G()),[W,G]);const ie=T.useMemo(()=>k?vOe(k):null,[k]);return w.viewport?e.jsxs(e.Fragment,{children:[ie&&e.jsx(sat,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:ie}),e.jsx(Jnt,{scope:r,onClose:J,children:Qh.createPortal(e.jsx(X0e.ItemSlot,{scope:r,children:e.jsx(Lnt,{asChild:!0,onEscapeKeyDown:kr(i,()=>{w.isFocusedToastEscapeKeyDownRef.current||J(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(Qr.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":w.swipeDirection,...j,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:kr(t.onKeyDown,ee=>{ee.key==="Escape"&&(i==null||i(ee.nativeEvent),ee.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,J()))}),onPointerDown:kr(t.onPointerDown,ee=>{ee.button===0&&(E.current={x:ee.clientX,y:ee.clientY})}),onPointerMove:kr(t.onPointerMove,ee=>{if(!E.current)return;const de=ee.clientX-E.current.x,oe=ee.clientY-E.current.y,ue=!!D.current,ce=["left","right"].includes(w.swipeDirection),ge=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,Te=ce?ge(0,de):0,ve=ce?0:ge(0,oe),ye=ee.pointerType==="touch"?10:2,Se={x:Te,y:ve},Ke={originalEvent:ee,delta:Se};ue?(D.current=Se,CO(Ynt,g,Ke,{discrete:!1})):WSe(Se,w.swipeDirection,ye)?(D.current=Se,CO(Znt,f,Ke,{discrete:!1}),ee.target.setPointerCapture(ee.pointerId)):(Math.abs(de)>ye||Math.abs(oe)>ye)&&(E.current=null)}),onPointerUp:kr(t.onPointerUp,ee=>{const de=D.current,oe=ee.target;if(oe.hasPointerCapture(ee.pointerId)&&oe.releasePointerCapture(ee.pointerId),D.current=null,E.current=null,de){const ue=ee.currentTarget,ce={originalEvent:ee,delta:de};WSe(de,w.swipeDirection,w.swipeThreshold)?CO(Qnt,_,ce,{discrete:!0}):CO(Xnt,v,ce,{discrete:!0}),ue.addEventListener("click",ge=>ge.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),sat=t=>{const{__scopeToast:s,children:r,...n}=t,a=mie(w6,s),[o,l]=T.useState(!1),[i,d]=T.useState(!1);return aat(()=>l(!0)),T.useEffect(()=>{const h=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(h)},[]),i?null:e.jsx(C3,{asChild:!0,children:e.jsx(hie,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},rat="ToastTitle",mOe=T.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});mOe.displayName=rat;var nat="ToastDescription",pOe=T.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});pOe.displayName=nat;var fOe="ToastAction",gOe=T.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(yOe,{altText:r,asChild:!0,children:e.jsx(Q0e,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${fOe}\`. Expected non-empty \`string\`.`),null)});gOe.displayName=fOe;var xOe="ToastClose",Q0e=T.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=eat(xOe,r);return e.jsx(yOe,{asChild:!0,children:e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:kr(t.onClick,a.onClose)})})});Q0e.displayName=xOe;var yOe=T.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 vOe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),iat(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(...vOe(n))}}),s}function CO(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?Z0e(a,o):a.dispatchEvent(o)}var WSe=(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 aat(t=()=>{}){const s=Ac(t);Pc(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function iat(t){return t.nodeType===t.ELEMENT_NODE}function oat(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 vue(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var lat=lOe,_Oe=dOe,bOe=hOe,wOe=mOe,jOe=pOe,kOe=gOe,NOe=Q0e;function SOe(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,KSe=Ai,M3=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return KSe(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:o}=s,l=Object.keys(a).map(h=>{const f=r==null?void 0:r[h],g=o==null?void 0:o[h];if(f===null)return null;const v=GSe(f)||GSe(g);return a[h][v]}),i=r&&Object.entries(r).reduce((h,f)=>{let[g,v]=f;return v===void 0||(h[g]=v),h},{}),d=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((h,f)=>{let{class:g,className:v,..._}=f;return Object.entries(_).every(j=>{let[w,k]=j;return Array.isArray(k)?k.includes({...o,...i}[w]):{...o,...i}[w]===k})?[...h,g,v]:h},[]);return KSe(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 cat=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),COe=(...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 dat={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 MOe=T.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>T.createElement("svg",{ref:d,...dat,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:COe("lucide",a),...i},[...l.map(([h,f])=>T.createElement(h,f)),...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 H=(t,s)=>{const r=T.forwardRef(({className:n,...a},o)=>T.createElement(MOe,{ref:o,iconNode:s,className:COe(`lucide-${cat(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 Q8=H("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 J8=H("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 eR=H("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 tR=H("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 wx=H("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 sR=H("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 rR=H("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 _b=H("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 bb=H("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 nR=H("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 wb=H("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 aR=H("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 iR=H("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 oR=H("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 lR=H("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 cR=H("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 w4=H("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 dR=H("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 uR=H("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 hR=H("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 mR=H("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 pR=H("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 fR=H("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 gR=H("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 xR=H("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 yR=H("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 vR=H("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 _R=H("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 j4=H("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 k4=H("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 bR=H("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 wR=H("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 jR=H("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 kR=H("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 NR=H("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 SR=H("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 CR=H("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 MR=H("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 TR=H("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 AR=H("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 ER=H("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 IR=H("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 PR=H("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 LR=H("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 DR=H("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 OR=H("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 RR=H("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 FR=H("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 zR=H("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 BR=H("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 $R=H("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 yE=H("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 UR=H("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 vE=H("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 qR=H("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 N4=H("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 VR=H("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 HR=H("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 WR=H("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 GR=H("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 KR=H("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 ZR=H("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 YR=H("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 XR=H("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 QR=H("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 JR=H("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 eF=H("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 jb=H("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 tF=H("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 sF=H("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 rF=H("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 nF=H("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 aF=H("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 iF=H("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 oF=H("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 kb=H("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 Nb=H("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 jx=H("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 lF=H("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 cF=H("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 dF=H("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 bi=H("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 uF=H("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 Zy=H("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 hF=H("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 qi=H("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 mF=H("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 pF=H("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 Sb=H("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 Hp=H("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 fF=H("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 gF=H("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 xF=H("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 Cb=H("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 yF=H("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 vF=H("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 _F=H("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 Mb=H("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 Wm=H("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 bF=H("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 wF=H("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 jF=H("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 kF=H("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 NF=H("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 SF=H("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 nc=H("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 CF=H("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 Tb=H("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 MF=H("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 TF=H("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 AF=H("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 EF=H("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 Ab=H("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 IF=H("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 PF=H("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 LF=H("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 DF=H("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 OF=H("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 RF=H("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 FF=H("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 zF=H("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 BF=H("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 $F=H("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 UF=H("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 qF=H("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 VF=H("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 HF=H("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 WF=H("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 GF=H("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 KF=H("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 ZF=H("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 YF=H("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 XF=H("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 QF=H("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 j1=H("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 JF=H("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 ez=H("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 tz=H("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 sz=H("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 rz=H("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 nz=H("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 az=H("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 iz=H("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 oz=H("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 lz=H("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 cz=H("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 k1=H("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 dz=H("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 uz=H("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 hz=H("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 mz=H("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 pz=H("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 fz=H("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 xk=H("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 gz=H("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 xz=H("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 dg=H("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 Eb=H("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 Ib=H("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 yz=H("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 vz=H("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 _z=H("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 bz=H("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 wz=H("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 jz=H("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 kz=H("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 Nz=H("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 Sz=H("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 Cz=H("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 Mz=H("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 Tz=H("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 Az=H("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 Ez=H("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 Iz=H("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 Pz=H("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 S4=H("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 Lz=H("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 Dz=H("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 Oz=H("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 Rz=H("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 Fz=H("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 zz=H("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 Bz=H("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 Pb=H("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 $z=H("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 Uz=H("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 qz=H("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 Vz=H("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 Hz=H("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 Wz=H("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 Gz=H("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 Kz=H("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 Zz=H("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 Yz=H("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 Yy=H("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 Xz=H("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 Qz=H("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 Jz=H("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 e7=H("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 t7=H("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 s7=H("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 r7=H("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 n7=H("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 a7=H("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 i7=H("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 _E=H("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 o7=H("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 ug=H("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 l7=H("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 c7=H("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 d7=H("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 C4=H("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 u7=H("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 h7=H("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 Lb=H("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 m7=H("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 p7=H("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 f7=H("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 bE=H("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 g7=H("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 x7=H("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 y7=H("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 v7=H("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 Fu=H("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 _7=H("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 b7=H("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 w7=H("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 j7=H("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 k7=H("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 Ya=H("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=H("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 N7=H("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 S7=H("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 C7=H("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 M7=H("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 T7=H("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 Gm=H("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 A7=H("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 E7=H("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 I7=H("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 P7=H("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 L7=H("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 D7=H("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 wE=H("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 O7=H("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 Km=H("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 R7=H("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 F7=H("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 z7=H("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 B7=H("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 $7=H("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 U7=H("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 N1=H("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 q7=H("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 V7=H("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 H7=H("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 W7=H("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 G7=H("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 xn=H("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 K7=H("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 hg=H("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 Z7=H("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 Y7=H("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 X7=H("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 Q7=H("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 J7=H("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 Db=H("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 eB=H("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 tB=H("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 sB=H("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 rB=H("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 nB=H("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 aB=H("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 iB=H("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 oB=H("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 lB=H("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 cB=H("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 dB=H("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 uB=H("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 hB=H("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 Ob=H("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 Rb=H("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 mB=H("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 pB=H("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 fB=H("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 Fb=H("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 zb=H("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 Bb=H("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 gB=H("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 $b=H("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 xB=H("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 Sc=H("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 yB=H("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 Ub=H("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 vB=H("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 _B=H("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 qb=H("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 Vb=H("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 bB=H("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 Hb=H("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 Wb=H("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 Gb=H("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 wB=H("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 jB=H("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 ma=H("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 kB=H("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 NB=H("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 Gc=H("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 SB=H("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 CB=H("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 hc=H("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 Ri=H("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 kx=H("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 MB=H("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 TB=H("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 AB=H("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 EB=H("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 IB=H("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 PB=H("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 LB=H("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 mg=H("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 DB=H("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 OB=H("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 RB=H("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 FB=H("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 zB=H("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=H("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 Kb=H("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 Zb=H("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 Yb=H("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 Xb=H("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 Qb=H("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 Jb=H("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 ew=H("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 tw=H("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 yi=H("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 oi=H("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 sw=H("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=H("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 nw=H("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 aw=H("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 BB=H("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 iw=H("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 $B=H("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 UB=H("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 qB=H("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 VB=H("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 HB=H("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 WB=H("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 GB=H("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 ow=H("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 Dy=H("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 lw=H("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 KB=H("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 cw=H("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 dw=H("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 uw=H("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 hw=H("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 Om=H("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 mw=H("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 pw=H("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 fw=H("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 ZB=H("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 gw=H("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=H("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 yw=H("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 Cc=H("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 Td=H("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 YB=H("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 XB=H("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 QB=H("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 M4=H("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 JB=H("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 jE=H("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 e9=H("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 t9=H("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 vw=H("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 _w=H("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 s9=H("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 r9=H("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 n9=H("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 a9=H("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 i9=H("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 o9=H("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 l9=H("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 c9=H("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 d9=H("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 u9=H("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 h9=H("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 m9=H("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 p9=H("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 f9=H("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 g9=H("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 x9=H("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 y9=H("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 v9=H("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 _9=H("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 ca=H("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 b9=H("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 w9=H("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 bw=H("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 j9=H("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 k9=H("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 N9=H("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 S9=H("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 C9=H("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 M9=H("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 T9=H("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 A9=H("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 E9=H("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 I9=H("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 P9=H("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 L9=H("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 ww=H("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 D9=H("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 O9=H("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 qy=H("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 R9=H("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 jw=H("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 vk=H("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 F9=H("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 z9=H("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 _k=H("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 B9=H("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 $9=H("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 kw=H("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 Nw=H("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 U9=H("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 q9=H("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 V9=H("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 H9=H("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 W9=H("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 G9=H("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 K9=H("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 Z9=H("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 Y9=H("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 Sw=H("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 bk=H("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 X9=H("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 Q9=H("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 J9=H("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 e$=H("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 t$=H("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 s$=H("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 r$=H("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 n$=H("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 a$=H("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 Di=H("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 i$=H("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 o$=H("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 l$=H("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 c$=H("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 d$=H("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 u$=H("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 h$=H("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 m$=H("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 p$=H("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 f$=H("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 g$=H("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 x$=H("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 Zm=H("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 y$=H("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 v$=H("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 _$=H("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 b$=H("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 kh=H("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 w$=H("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 j$=H("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 k$=H("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 N$=H("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 S$=H("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 C$=H("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 M$=H("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 T$=H("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 A$=H("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 E$=H("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 I$=H("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 P$=H("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 Cw=H("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 L$=H("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 D$=H("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 O$=H("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 R$=H("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 F$=H("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 z$=H("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 B$=H("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 $$=H("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 U$=H("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 q$=H("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 V$=H("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 H$=H("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 W$=H("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 G$=H("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 K$=H("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 Z$=H("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 Y$=H("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 X$=H("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 Q$=H("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 Ad=H("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 J$=H("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 eU=H("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 Xy=H("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 tU=H("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 Vi=H("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 sU=H("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 rU=H("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 nU=H("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 aU=H("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 iU=H("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 Nx=H("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 oU=H("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 lU=H("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 cU=H("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 dU=H("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 uU=H("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 hU=H("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 Mw=H("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 mU=H("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 pU=H("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 fU=H("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 T4=H("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 hx=H("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 Rp=H("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 gU=H("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 xU=H("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 yU=H("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 vU=H("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 _U=H("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 bU=H("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 wU=H("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 bn=H("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 jU=H("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 Wp=H("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 wi=H("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 Qd=H("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kU=H("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 NU=H("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 SU=H("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 CU=H("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 MU=H("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 TU=H("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 AU=H("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 EU=H("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IU=H("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 PU=H("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 Tw=H("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 LU=H("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 DU=H("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 OU=H("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 Aw=H("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 Ew=H("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 Iw=H("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 Pw=H("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 RU=H("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 FU=H("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 zU=H("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 BU=H("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 $U=H("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 Lw=H("FileCog",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UU=H("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 qU=H("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 VU=H("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 HU=H("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 S1=H("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 WU=H("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 GU=H("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 KU=H("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 ZU=H("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 YU=H("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 XU=H("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 QU=H("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 JU=H("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 eq=H("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 tq=H("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 sq=H("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 Dw=H("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 Ow=H("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 rq=H("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 nq=H("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 aq=H("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 iq=H("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 oq=H("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 lq=H("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 cq=H("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 Qy=H("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 kE=H("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 dq=H("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 uq=H("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 Yn=H("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 hq=H("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 mq=H("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 pq=H("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 fq=H("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 gq=H("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 xq=H("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 yq=H("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 vq=H("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 _q=H("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 bq=H("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 wq=H("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 A4=H("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 jq=H("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 Wd=H("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 kq=H("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 Jy=H("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 Nq=H("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 Sq=H("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 Cq=H("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 Mq=H("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 Tq=H("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 Aq=H("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 Eq=H("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 Iq=H("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 e0=H("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 Pq=H("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 Ym=H("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 Lq=H("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 Dq=H("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 Oq=H("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 wk=H("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 Rq=H("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 Fq=H("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 zq=H("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 Bq=H("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 $q=H("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 ng=H("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 Uq=H("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 qq=H("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 Vq=H("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 Hq=H("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 Wq=H("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 Gq=H("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 Kq=H("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 Zq=H("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 Yq=H("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 Rw=H("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 Xq=H("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 Qq=H("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 Jq=H("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 eV=H("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 tV=H("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 sV=H("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 rV=H("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 nV=H("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 aV=H("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 iV=H("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 oV=H("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 om=H("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 lV=H("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 Fw=H("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 cV=H("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 dV=H("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 uV=H("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 hV=H("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 mV=H("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 pV=H("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 fV=H("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 gV=H("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 xV=H("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 yV=H("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 vV=H("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 _V=H("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 bV=H("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 wV=H("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 jV=H("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 kV=H("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 NV=H("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 SV=H("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 CV=H("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 MV=H("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 TV=H("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 AV=H("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 EV=H("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 IV=H("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 PV=H("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 LV=H("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 DV=H("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 OV=H("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 RV=H("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 jk=H("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 oo=H("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 FV=H("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 zV=H("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 zw=H("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 BV=H("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 $V=H("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 UV=H("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 qV=H("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 VV=H("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 HV=H("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 WV=H("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 GV=H("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 KV=H("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 ZV=H("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 YV=H("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 XV=H("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 QV=H("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 JV=H("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 eH=H("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 tH=H("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 sH=H("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 pg=H("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 rH=H("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 nH=H("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 C1=H("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 aH=H("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 iH=H("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 Bw=H("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 oH=H("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 $w=H("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 Im=H("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 lH=H("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 lm=H("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 cH=H("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 dH=H("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 uH=H("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 hH=H("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 mH=H("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 pH=H("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 fH=H("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 Uw=H("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 gH=H("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 xH=H("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 NE=H("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 yH=H("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 vH=H("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 _H=H("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 SE=H("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 bH=H("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 E4=H("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 wH=H("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 jH=H("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 CE=H("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 ME=H("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 kH=H("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 NH=H("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 SH=H("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 CH=H("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 MH=H("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 TH=H("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 AH=H("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 EH=H("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 IH=H("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 PH=H("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 LH=H("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 DH=H("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 Ti=H("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 OH=H("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 RH=H("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 FH=H("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 I4=H("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 zH=H("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 BH=H("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 $H=H("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 UH=H("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 qH=H("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 VH=H("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 HH=H("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 Zn=H("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 qw=H("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 Vw=H("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 WH=H("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 GH=H("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 KH=H("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 ZH=H("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 YH=H("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 M1=H("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 XH=H("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 QH=H("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 fl=H("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 JH=H("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 eW=H("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 tW=H("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 Hw=H("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 Ww=H("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 sW=H("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 rW=H("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 nW=H("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 aW=H("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 vu=H("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 P4=H("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 iW=H("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 oW=H("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 lW=H("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 cW=H("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 Sx=H("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 kk=H("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 dW=H("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 Xm=H("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 uW=H("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 hW=H("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 mW=H("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 pW=H("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 fW=H("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 gW=H("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 xW=H("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 yW=H("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 vW=H("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 _W=H("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 bW=H("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 wW=H("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 jW=H("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 Gw=H("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 kW=H("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 NW=H("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 SW=H("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 CW=H("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 MW=H("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 TW=H("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 AW=H("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 Nk=H("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 Qm=H("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 EW=H("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 IW=H("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 PW=H("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 Sk=H("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 LW=H("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 DW=H("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 OW=H("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 RW=H("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 FW=H("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 L4=H("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 D4=H("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 zW=H("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 BW=H("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 t0=H("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 $W=H("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 Jm=H("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 Ro=H("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 cm=H("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 UW=H("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 qW=H("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 VW=H("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 HW=H("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 WW=H("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 GW=H("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 KW=H("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 O4=H("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 ZW=H("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 YW=H("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 XW=H("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 QW=H("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 JW=H("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 eG=H("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 tG=H("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 dm=H("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 Us=H("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 sG=H("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 rG=H("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 nG=H("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 aG=H("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 TE=H("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 Kw=H("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 iG=H("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 Zw=H("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 zu=H("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 R4=H("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 F4=H("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 oG=H("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 lG=H("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 cG=H("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 dG=H("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 uG=H("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 hG=H("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 mG=H("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 pG=H("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 fG=H("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 gG=H("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 xG=H("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 AE=H("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 zr=H("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 yG=H("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 vG=H("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 _G=H("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 bG=H("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 wG=H("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 jG=H("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 kG=H("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 NG=H("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 SG=H("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 CG=H("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 MG=H("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 TG=H("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 Gi=H("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 AG=H("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 EG=H("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 IG=H("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 PG=H("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 LG=H("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 s0=H("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 DG=H("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=H("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 OG=H("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 RG=H("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 EE=H("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 FG=H("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 zG=H("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 BG=H("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 z4=H("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 $G=H("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 UG=H("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 qG=H("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 IE=H("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 VG=H("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 HG=H("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 WG=H("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 Gl=H("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 GG=H("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 KG=H("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 ZG=H("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 YG=H("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 PE=H("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 XG=H("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 QG=H("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 JG=H("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 B4=H("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 LE=H("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 eK=H("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 tK=H("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 sK=H("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 rK=H("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 nK=H("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 Eo=H("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 aK=H("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 iK=H("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 Yw=H("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 DE=H("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 oK=H("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 lK=H("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 cK=H("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 dK=H("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 uK=H("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 hK=H("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 mK=H("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 pK=H("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 T1=H("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 fK=H("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 gK=H("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 xK=H("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 yK=H("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 vK=H("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 _K=H("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 bK=H("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 wK=H("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 jK=H("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 kK=H("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 NK=H("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 SK=H("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 Ck=H("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 CK=H("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 MK=H("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 TK=H("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 AK=H("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 EK=H("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 IK=H("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 PK=H("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 A1=H("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 LK=H("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 DK=H("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 Xw=H("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 OK=H("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 RK=H("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 FK=H("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 zK=H("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 BK=H("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 $K=H("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 UK=H("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 qK=H("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 VK=H("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 HK=H("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 WK=H("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 GK=H("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 KK=H("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 ZK=H("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 YK=H("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 XK=H("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 QK=H("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 JK=H("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 eZ=H("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 tZ=H("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 OE=H("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 sZ=H("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 r0=H("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 rZ=H("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 nZ=H("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 aZ=H("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 iZ=H("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 oZ=H("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 lZ=H("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 cZ=H("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 dZ=H("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 uZ=H("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 Qw=H("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 hZ=H("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 Jw=H("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 e2=H("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 mZ=H("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 pZ=H("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 fZ=H("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 gZ=H("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 xZ=H("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 yZ=H("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 vZ=H("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 _Z=H("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 bZ=H("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 wZ=H("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 jZ=H("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 kZ=H("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 mc=H("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 NZ=H("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 SZ=H("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 t2=H("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 CZ=H("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 hd=H("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 MZ=H("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 s2=H("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 TZ=H("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 AZ=H("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 r2=H("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 n2=H("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 a2=H("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 i2=H("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 EZ=H("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 o2=H("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 IZ=H("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 PZ=H("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 LZ=H("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 l2=H("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 DZ=H("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 OZ=H("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 RZ=H("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 FZ=H("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 Av=H("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mk=H("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 zZ=H("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 BZ=H("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 md=H("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 ep=H("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 $Z=H("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 UZ=H("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 Ev=H("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 qZ=H("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 Tk=H("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 Iv=H("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 VZ=H("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 HZ=H("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 WZ=H("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 Xa=H("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 GZ=H("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 $4=H("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 KZ=H("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 ZZ=H("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 YZ=H("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 XZ=H("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 QZ=H("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 JZ=H("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 eY=H("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 tY=H("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 Ha=H("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 sY=H("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 rY=H("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 nY=H("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 aY=H("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 iY=H("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 oY=H("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 lY=H("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 cY=H("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 dY=H("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 uY=H("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 hY=H("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 RE=H("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 E1=H("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 mY=H("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 pY=H("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 fY=H("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 gY=H("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 xY=H("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 Kl=H("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 yY=H("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 c2=H("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 FE=H("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 ar=H("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 vY=H("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 _Y=H("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 bY=H("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 wY=H("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 jY=H("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 kY=H("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 NY=H("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 SY=H("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 CY=H("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 MY=H("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 Gp=H("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 TY=H("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 zE=H("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 AY=H("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 EY=H("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 IY=H("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 PY=H("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 Ak=H("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 U4=H("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 LY=H("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 DY=H("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 OY=H("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 RY=H("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 FY=H("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 zY=H("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 Ek=H("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 BY=H("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 $Y=H("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 UY=H("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 qY=H("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 VY=H("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 HY=H("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 WY=H("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 GY=H("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 KY=H("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 ZY=H("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 YY=H("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 XY=H("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 QY=H("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 JY=H("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 d2=H("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 eX=H("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 tX=H("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 sX=H("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 rX=H("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 nX=H("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 q4=H("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 aX=H("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 iX=H("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 oX=H("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 el=H("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 lX=H("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 cX=H("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 dX=H("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 uX=H("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 hX=H("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 BE=H("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 mX=H("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 pX=H("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 fX=H("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 $E=H("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 gX=H("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 xX=H("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 Cx=H("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 yX=H("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 vX=H("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 u2=H("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 _X=H("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 Ik=H("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 bX=H("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 UE=H("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 wX=H("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 jX=H("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 kX=H("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=H("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 m2=H("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 NX=H("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 SX=H("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 CX=H("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 MX=H("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 TX=H("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 AX=H("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 EX=H("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 IX=H("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 PX=H("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 LX=H("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 DX=H("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 um=H("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 p2=H("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 OX=H("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 RX=H("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 FX=H("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 zX=H("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 BX=H("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 $X=H("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 UX=H("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 qX=H("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 VX=H("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 HX=H("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 WX=H("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 GX=H("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 KX=H("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 ZX=H("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 YX=H("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 XX=H("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 QX=H("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 JX=H("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 eQ=H("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 tQ=H("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 sQ=H("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 On=H("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 rQ=H("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 f2=H("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 nQ=H("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 Wa=H("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 aQ=H("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 iQ=H("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 oQ=H("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 lQ=H("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 cQ=H("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 dQ=H("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 uQ=H("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 Ic=H("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 hQ=H("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 Kc=H("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 qE=H("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 mQ=H("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 pQ=H("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 fQ=H("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 gQ=H("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 VE=H("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=H("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 yQ=H("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 vQ=H("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 _Q=H("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 bQ=H("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 wQ=H("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 g2=H("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 Bu=H("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 jQ=H("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 kQ=H("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 NQ=H("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 Mx=H("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 SQ=H("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 Jh=H("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 CQ=H("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 MQ=H("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 TQ=H("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 AQ=H("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 EQ=H("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 IQ=H("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 PQ=H("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 LQ=H("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 DQ=H("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 OQ=H("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 RQ=H("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 FQ=H("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 zQ=H("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 BQ=H("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 $Q=H("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 UQ=H("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 qQ=H("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 VQ=H("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 HQ=H("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 WQ=H("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 GQ=H("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 HE=H("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 x2=H("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 KQ=H("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 ZQ=H("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 n0=H("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 YQ=H("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 XQ=H("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 QQ=H("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 o1=H("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 JQ=H("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 eJ=H("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 tJ=H("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 sJ=H("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 rJ=H("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 Sn=H("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 nJ=H("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 aJ=H("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 iJ=H("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 oJ=H("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 lJ=H("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 cJ=H("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 dJ=H("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 uJ=H("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 y2=H("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 v2=H("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 _2=H("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 b2=H("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 w2=H("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 j2=H("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 k2=H("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 N2=H("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 S2=H("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 C2=H("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 M2=H("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 T2=H("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 A2=H("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 E2=H("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 I2=H("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 sx=H("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 Oy=H("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 P2=H("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 L2=H("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 D2=H("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 O2=H("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 R2=H("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 F2=H("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=H("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 mJ=H("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 z2=H("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 B2=H("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 $2=H("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 U2=H("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 q2=H("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 V2=H("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 H2=H("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 W2=H("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 G2=H("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 K2=H("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 Z2=H("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 Y2=H("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 X2=H("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 Q2=H("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 J2=H("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 _c=H("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 ej=H("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 tj=H("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 sj=H("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 rj=H("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 nj=H("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 aj=H("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 pJ=H("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 ij=H("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 oj=H("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 lj=H("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 cj=H("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 dj=H("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 fJ=H("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 gJ=H("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 uj=H("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=H("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 mj=H("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 pj=H("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 Tx=H("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 xJ=H("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 yJ=H("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 vJ=H("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 _J=H("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 bJ=H("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 qn=H("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 wJ=H("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 jJ=H("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 kJ=H("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 NJ=H("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 SJ=H("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 CJ=H("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 MJ=H("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 TJ=H("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 AJ=H("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 EJ=H("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 IJ=H("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 PJ=H("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 LJ=H("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 DJ=H("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 I1=H("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 OJ=H("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 RJ=H("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 FJ=H("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 zJ=H("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 BJ=H("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 $J=H("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 UJ=H("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 qJ=H("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 VJ=H("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 V4=H("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 HJ=H("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 WJ=H("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 GJ=H("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 KJ=H("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 ZJ=H("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 YJ=H("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 WE=H("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 XJ=H("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 QJ=H("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 JJ=H("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 Kp=H("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 eee=H("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 tee=H("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 see=H("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 ree=H("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 nee=H("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 aee=H("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 iee=H("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 hm=H("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 oee=H("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 lee=H("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 cee=H("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 dee=H("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 fj=H("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 uee=H("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=H("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 mee=H("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 pee=H("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 fee=H("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 gee=H("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 gj=H("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 xee=H("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 yee=H("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 vee=H("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 _ee=H("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 bee=H("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 GE=H("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 Ed=H("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 wee=H("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 jee=H("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 kee=H("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 Nee=H("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 See=H("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 Cee=H("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 KE=H("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 Mee=H("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 Tee=H("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 Aee=H("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 Eee=H("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 Iee=H("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 Pee=H("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 Lee=H("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 Dee=H("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 Oee=H("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 Ree=H("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 Fee=H("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 zee=H("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 Bee=H("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 $ee=H("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 Uee=H("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 qee=H("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 Vee=H("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 Hee=H("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 Wee=H("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 xj=H("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 Ir=H("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 Gee=H("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 Kee=H("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 yj=H("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 P1=H("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 Zee=H("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 Yee=H("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 Pk=H("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 Xee=H("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 Jd=H("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 Lu=H("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 Qee=H("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 Jee=H("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 vo=H("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 ZE=H("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 ete=H("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 tte=H("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 vj=H("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 ste=H("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 rte=H("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 nte=H("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 ate=H("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 ite=H("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 ote=H("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 lte=H("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 cte=H("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 dte=H("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 ute=H("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 H4=H("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=H("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 mte=H("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 pte=H("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 _j=H("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 fte=H("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 YE=H("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 gte=H("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 ji=H("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 xte=H("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 Lk=H("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 XE=H("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 QE=H("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 yte=H("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 Zc=H("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 bj=H("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 wj=H("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 jj=H("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 vte=H("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 kj=H("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 _te=H("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 Nj=H("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 Sj=H("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 bte=H("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 wte=H("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 Wo=H("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 Cj=H("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 br=H("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 Mj=H("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 Tj=H("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 jte=H("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 JE=H("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 kte=H("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 Nte=H("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 Ste=H("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 Cte=H("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 Mte=H("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 Tte=H("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 Wn=H("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 Ate=H("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 Ete=H("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 Ite=H("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 Pte=H("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 Lte=H("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 Dte=H("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 Ote=H("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 Rte=H("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 Fte=H("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 zte=H("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 Bte=H("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 Aj=H("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 $te=H("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 Ute=H("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 Ej=H("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 qte=H("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 Vte=H("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 Hte=H("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 Wte=H("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 Gte=H("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 Kte=H("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 Zte=H("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 Yte=H("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 Xte=H("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 Qte=H("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 Jte=H("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 ese=H("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 tse=H("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 sse=H("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 rse=H("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 nse=H("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 ase=H("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 ise=H("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 ose=H("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 lse=H("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 cse=H("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 dse=H("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=H("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 hse=H("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 mse=H("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 a0=H("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 Xr=H("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 pse=H("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 fse=H("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 Ax=H("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 W4=H("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 G4=H("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 uat=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Q8,AArrowUp:J8,ALargeSmall:eR,Accessibility:tR,Activity:wx,AirVent:sR,Airplay:rR,AlarmClock:aR,AlarmClockCheck:_b,AlarmClockMinus:bb,AlarmClockOff:nR,AlarmClockPlus:wb,AlarmSmoke:iR,Album:oR,AlignCenter:w4,AlignCenterHorizontal:lR,AlignCenterVertical:cR,AlignEndHorizontal:dR,AlignEndVertical:uR,AlignHorizontalDistributeCenter:hR,AlignHorizontalDistributeEnd:mR,AlignHorizontalDistributeStart:pR,AlignHorizontalJustifyCenter:fR,AlignHorizontalJustifyEnd:gR,AlignHorizontalJustifyStart:xR,AlignHorizontalSpaceAround:yR,AlignHorizontalSpaceBetween:vR,AlignJustify:_R,AlignLeft:j4,AlignRight:k4,AlignStartHorizontal:bR,AlignStartVertical:wR,AlignVerticalDistributeCenter:jR,AlignVerticalDistributeEnd:kR,AlignVerticalDistributeStart:NR,AlignVerticalJustifyCenter:SR,AlignVerticalJustifyEnd:CR,AlignVerticalJustifyStart:MR,AlignVerticalSpaceAround:TR,AlignVerticalSpaceBetween:AR,Ambulance:ER,Ampersand:IR,Ampersands:PR,Amphora:LR,Anchor:DR,Angry:OR,Annoyed:RR,Antenna:FR,Anvil:zR,Aperture:BR,AppWindow:yE,AppWindowMac:$R,Apple:UR,Archive:N4,ArchiveRestore:vE,ArchiveX:qR,Armchair:VR,ArrowBigDown:WR,ArrowBigDownDash:HR,ArrowBigLeft:KR,ArrowBigLeftDash:GR,ArrowBigRight:YR,ArrowBigRightDash:ZR,ArrowBigUp:QR,ArrowBigUpDash:XR,ArrowDown:jx,ArrowDown01:JR,ArrowDown10:eF,ArrowDownAZ:jb,ArrowDownFromLine:tF,ArrowDownLeft:sF,ArrowDownNarrowWide:rF,ArrowDownRight:nF,ArrowDownToDot:aF,ArrowDownToLine:iF,ArrowDownUp:oF,ArrowDownWideNarrow:kb,ArrowDownZA:Nb,ArrowLeft:bi,ArrowLeftFromLine:lF,ArrowLeftRight:cF,ArrowLeftToLine:dF,ArrowRight:qi,ArrowRightFromLine:uF,ArrowRightLeft:Zy,ArrowRightToLine:hF,ArrowUp:Wm,ArrowUp01:mF,ArrowUp10:pF,ArrowUpAZ:Sb,ArrowUpDown:Hp,ArrowUpFromDot:fF,ArrowUpFromLine:gF,ArrowUpLeft:xF,ArrowUpNarrowWide:Cb,ArrowUpRight:yF,ArrowUpToLine:vF,ArrowUpWideNarrow:_F,ArrowUpZA:Mb,ArrowsUpFromLine:bF,Asterisk:wF,AtSign:jF,Atom:kF,AudioLines:NF,AudioWaveform:SF,Award:nc,Axe:CF,Axis3d:Tb,Baby:MF,Backpack:TF,Badge:HF,BadgeAlert:AF,BadgeCent:EF,BadgeCheck:Ab,BadgeDollarSign:IF,BadgeEuro:PF,BadgeHelp:LF,BadgeIndianRupee:DF,BadgeInfo:OF,BadgeJapaneseYen:RF,BadgeMinus:FF,BadgePercent:zF,BadgePlus:BF,BadgePoundSterling:$F,BadgeRussianRuble:UF,BadgeSwissFranc:qF,BadgeX:VF,BaggageClaim:WF,Ban:GF,Banana:KF,Bandage:ZF,Banknote:YF,Barcode:XF,Baseline:QF,Bath:j1,Battery:nz,BatteryCharging:JF,BatteryFull:ez,BatteryLow:tz,BatteryMedium:sz,BatteryWarning:rz,Beaker:az,Bean:oz,BeanOff:iz,Bed:k1,BedDouble:lz,BedSingle:cz,Beef:dz,Beer:hz,BeerOff:uz,Bell:dg,BellDot:mz,BellElectric:pz,BellMinus:fz,BellOff:xk,BellPlus:gz,BellRing:xz,BetweenHorizontalEnd:Eb,BetweenHorizontalStart:Ib,BetweenVerticalEnd:yz,BetweenVerticalStart:vz,BicepsFlexed:_z,Bike:bz,Binary:wz,Binoculars:jz,Biohazard:kz,Bird:Nz,Bitcoin:Sz,Blend:Cz,Blinds:Mz,Blocks:Tz,Bluetooth:Pz,BluetoothConnected:Az,BluetoothOff:Ez,BluetoothSearching:Iz,Bold:S4,Bolt:Lz,Bomb:Dz,Bone:Oz,Book:n7,BookA:Rz,BookAudio:Fz,BookCheck:zz,BookCopy:Bz,BookDashed:Pb,BookDown:$z,BookHeadphones:Uz,BookHeart:qz,BookImage:Vz,BookKey:Hz,BookLock:Wz,BookMarked:Gz,BookMinus:Kz,BookOpen:Yy,BookOpenCheck:Zz,BookOpenText:Yz,BookPlus:Xz,BookText:Qz,BookType:Jz,BookUp:t7,BookUp2:e7,BookUser:s7,BookX:r7,Bookmark:ug,BookmarkCheck:a7,BookmarkMinus:i7,BookmarkPlus:_E,BookmarkX:o7,BoomBox:l7,Bot:C4,BotMessageSquare:c7,BotOff:d7,Box:u7,Boxes:h7,Braces:Lb,Brackets:m7,Brain:bE,BrainCircuit:p7,BrainCog:f7,BrickWall:g7,Briefcase:Fu,BriefcaseBusiness:x7,BriefcaseConveyorBelt:y7,BriefcaseMedical:v7,BringToFront:_7,Brush:b7,Bug:k7,BugOff:w7,BugPlay:j7,Building:yk,Building2:Ya,Bus:S7,BusFront:N7,Cable:M7,CableCar:C7,Cake:Gm,CakeSlice:T7,Calculator:A7,Calendar:xn,Calendar1:E7,CalendarArrowDown:I7,CalendarArrowUp:P7,CalendarCheck:D7,CalendarCheck2:L7,CalendarClock:wE,CalendarCog:O7,CalendarDays:Km,CalendarFold:R7,CalendarHeart:F7,CalendarMinus:B7,CalendarMinus2:z7,CalendarOff:$7,CalendarPlus:N1,CalendarPlus2:U7,CalendarRange:q7,CalendarSearch:V7,CalendarSync:H7,CalendarX:G7,CalendarX2:W7,Camera:hg,CameraOff:K7,Candy:X7,CandyCane:Z7,CandyOff:Y7,Cannabis:Q7,Captions:Db,CaptionsOff:J7,Car:sB,CarFront:eB,CarTaxiFront:tB,Caravan:rB,Carrot:nB,CaseLower:aB,CaseSensitive:iB,CaseUpper:oB,CassetteTape:lB,Cast:cB,Castle:dB,Cat:uB,Cctv:hB,ChartArea:Ob,ChartBar:Fb,ChartBarBig:Rb,ChartBarDecreasing:mB,ChartBarIncreasing:pB,ChartBarStacked:fB,ChartCandlestick:zb,ChartColumn:Sc,ChartColumnBig:Bb,ChartColumnDecreasing:gB,ChartColumnIncreasing:$b,ChartColumnStacked:xB,ChartGantt:yB,ChartLine:Ub,ChartNetwork:vB,ChartNoAxesColumn:Vb,ChartNoAxesColumnDecreasing:_B,ChartNoAxesColumnIncreasing:qb,ChartNoAxesCombined:bB,ChartNoAxesGantt:Hb,ChartPie:Wb,ChartScatter:Gb,ChartSpline:wB,Check:ma,CheckCheck:jB,ChefHat:kB,Cherry:NB,ChevronDown:Gc,ChevronFirst:SB,ChevronLast:CB,ChevronLeft:hc,ChevronRight:Ri,ChevronUp:kx,ChevronsDown:TB,ChevronsDownUp:MB,ChevronsLeft:IB,ChevronsLeftRight:EB,ChevronsLeftRightEllipsis:AB,ChevronsRight:LB,ChevronsRightLeft:PB,ChevronsUp:DB,ChevronsUpDown:mg,Chrome:OB,Church:RB,Cigarette:zB,CigaretteOff:FB,Circle:Td,CircleAlert:Qo,CircleArrowDown:Kb,CircleArrowLeft:Zb,CircleArrowOutDownLeft:Yb,CircleArrowOutDownRight:Xb,CircleArrowOutUpLeft:Qb,CircleArrowOutUpRight:Jb,CircleArrowRight:ew,CircleArrowUp:tw,CircleCheck:oi,CircleCheckBig:yi,CircleChevronDown:sw,CircleChevronLeft:rw,CircleChevronRight:nw,CircleChevronUp:aw,CircleDashed:BB,CircleDivide:iw,CircleDollarSign:$B,CircleDot:qB,CircleDotDashed:UB,CircleEllipsis:VB,CircleEqual:HB,CircleFadingArrowUp:WB,CircleFadingPlus:GB,CircleGauge:ow,CircleHelp:Dy,CircleMinus:lw,CircleOff:KB,CircleParking:dw,CircleParkingOff:cw,CirclePause:uw,CirclePercent:hw,CirclePlay:Om,CirclePlus:mw,CirclePower:pw,CircleSlash:ZB,CircleSlash2:fw,CircleStop:gw,CircleUser:yw,CircleUserRound:xw,CircleX:Cc,CircuitBoard:YB,Citrus:XB,Clapperboard:QB,Clipboard:a9,ClipboardCheck:M4,ClipboardCopy:JB,ClipboardList:jE,ClipboardMinus:e9,ClipboardPaste:t9,ClipboardPen:_w,ClipboardPenLine:vw,ClipboardPlus:s9,ClipboardType:r9,ClipboardX:n9,Clock:ca,Clock1:i9,Clock10:o9,Clock11:l9,Clock12:c9,Clock2:d9,Clock3:u9,Clock4:h9,Clock5:m9,Clock6:p9,Clock7:f9,Clock8:g9,Clock9:x9,ClockAlert:y9,ClockArrowDown:v9,ClockArrowUp:_9,Cloud:D9,CloudAlert:b9,CloudCog:w9,CloudDownload:bw,CloudDrizzle:j9,CloudFog:k9,CloudHail:N9,CloudLightning:S9,CloudMoon:M9,CloudMoonRain:C9,CloudOff:T9,CloudRain:E9,CloudRainWind:A9,CloudSnow:I9,CloudSun:L9,CloudSunRain:P9,CloudUpload:ww,Cloudy:O9,Clover:qy,Club:R9,Code:vk,CodeXml:jw,Codepen:F9,Codesandbox:z9,Coffee:_k,Cog:B9,Coins:$9,Columns2:kw,Columns3:Nw,Columns4:U9,Combine:q9,Command:V9,Compass:H9,Component:W9,Computer:G9,ConciergeBell:K9,Cone:Z9,Construction:Y9,Contact:bk,ContactRound:Sw,Container:X9,Contrast:Q9,Cookie:J9,CookingPot:e$,Copy:Di,CopyCheck:t$,CopyMinus:s$,CopyPlus:r$,CopySlash:n$,CopyX:a$,Copyleft:i$,Copyright:o$,CornerDownLeft:l$,CornerDownRight:c$,CornerLeftDown:d$,CornerLeftUp:u$,CornerRightDown:h$,CornerRightUp:m$,CornerUpLeft:p$,CornerUpRight:f$,Cpu:g$,CreativeCommons:x$,CreditCard:Zm,Croissant:y$,Crop:v$,Cross:_$,Crosshair:b$,Crown:kh,Cuboid:w$,CupSoda:j$,Currency:k$,Cylinder:N$,Dam:S$,Database:T$,DatabaseBackup:C$,DatabaseZap:M$,Delete:A$,Dessert:E$,Diameter:I$,Diamond:D$,DiamondMinus:P$,DiamondPercent:Cw,DiamondPlus:L$,Dice1:O$,Dice2:R$,Dice3:F$,Dice4:z$,Dice5:B$,Dice6:$$,Dices:U$,Diff:q$,Disc:G$,Disc2:V$,Disc3:H$,DiscAlbum:W$,Divide:K$,Dna:Y$,DnaOff:Z$,Dock:X$,Dog:Q$,DollarSign:Ad,Donut:J$,DoorClosed:eU,DoorOpen:Xy,Dot:tU,Download:Vi,DraftingCompass:sU,Drama:rU,Dribbble:nU,Drill:aU,Droplet:iU,Droplets:Nx,Drum:oU,Drumstick:lU,Dumbbell:cU,Ear:uU,EarOff:dU,Earth:Mw,EarthLock:hU,Eclipse:mU,Egg:T4,EggFried:pU,EggOff:fU,Ellipsis:Rp,EllipsisVertical:hx,Equal:yU,EqualApproximately:gU,EqualNot:xU,Eraser:vU,EthernetPort:_U,Euro:bU,Expand:wU,ExternalLink:bn,Eye:wi,EyeClosed:jU,EyeOff:Wp,Facebook:Qd,Factory:kU,Fan:NU,FastForward:SU,Feather:CU,Fence:MU,FerrisWheel:TU,Figma:AU,File:A4,FileArchive:EU,FileAudio:PU,FileAudio2:IU,FileAxis3d:Tw,FileBadge:DU,FileBadge2:LU,FileBox:OU,FileChartColumn:Ew,FileChartColumnIncreasing:Aw,FileChartLine:Iw,FileChartPie:Pw,FileCheck:FU,FileCheck2:RU,FileClock:zU,FileCode:$U,FileCode2:BU,FileCog:Lw,FileDiff:UU,FileDigit:qU,FileDown:VU,FileHeart:HU,FileImage:S1,FileInput:WU,FileJson:KU,FileJson2:GU,FileKey:YU,FileKey2:ZU,FileLock:QU,FileLock2:XU,FileMinus:eq,FileMinus2:JU,FileMusic:tq,FileOutput:sq,FilePen:Ow,FilePenLine:Dw,FilePlus:nq,FilePlus2:rq,FileQuestion:aq,FileScan:iq,FileSearch:lq,FileSearch2:oq,FileSliders:cq,FileSpreadsheet:Qy,FileStack:kE,FileSymlink:dq,FileTerminal:uq,FileText:Yn,FileType:mq,FileType2:hq,FileUp:pq,FileUser:fq,FileVideo:xq,FileVideo2:gq,FileVolume:vq,FileVolume2:yq,FileWarning:_q,FileX:wq,FileX2:bq,Files:jq,Film:Wd,Filter:Jy,FilterX:kq,Fingerprint:Nq,FireExtinguisher:Sq,Fish:Tq,FishOff:Cq,FishSymbol:Mq,Flag:e0,FlagOff:Aq,FlagTriangleLeft:Eq,FlagTriangleRight:Iq,Flame:Ym,FlameKindling:Pq,Flashlight:Dq,FlashlightOff:Lq,FlaskConical:wk,FlaskConicalOff:Oq,FlaskRound:Rq,FlipHorizontal:zq,FlipHorizontal2:Fq,FlipVertical:$q,FlipVertical2:Bq,Flower:Uq,Flower2:ng,Focus:qq,FoldHorizontal:Vq,FoldVertical:Hq,Folder:yV,FolderArchive:Wq,FolderCheck:Gq,FolderClock:Kq,FolderClosed:Zq,FolderCode:Yq,FolderCog:Rw,FolderDot:Xq,FolderDown:Qq,FolderGit:eV,FolderGit2:Jq,FolderHeart:tV,FolderInput:sV,FolderKanban:rV,FolderKey:nV,FolderLock:aV,FolderMinus:iV,FolderOpen:om,FolderOpenDot:oV,FolderOutput:lV,FolderPen:Fw,FolderPlus:cV,FolderRoot:dV,FolderSearch:hV,FolderSearch2:uV,FolderSymlink:mV,FolderSync:pV,FolderTree:fV,FolderUp:gV,FolderX:xV,Folders:vV,Footprints:_V,Forklift:bV,Forward:wV,Frame:jV,Framer:kV,Frown:NV,Fuel:SV,Fullscreen:CV,GalleryHorizontal:TV,GalleryHorizontalEnd:MV,GalleryThumbnails:AV,GalleryVertical:IV,GalleryVerticalEnd:EV,Gamepad:LV,Gamepad2:PV,Gauge:DV,Gavel:OV,Gem:RV,Ghost:jk,Gift:oo,GitBranch:zV,GitBranchPlus:FV,GitCommitHorizontal:zw,GitCommitVertical:BV,GitCompare:UV,GitCompareArrows:$V,GitFork:qV,GitGraph:VV,GitMerge:HV,GitPullRequest:XV,GitPullRequestArrow:WV,GitPullRequestClosed:GV,GitPullRequestCreate:ZV,GitPullRequestCreateArrow:KV,GitPullRequestDraft:YV,Github:QV,Gitlab:JV,GlassWater:eH,Glasses:tH,Globe:pg,GlobeLock:sH,Goal:rH,Grab:nH,GraduationCap:C1,Grape:aH,Grid2x2:$w,Grid2x2Check:iH,Grid2x2Plus:Bw,Grid2x2X:oH,Grid3x3:Im,Grip:cH,GripHorizontal:lH,GripVertical:lm,Group:dH,Guitar:uH,Ham:hH,Hammer:mH,Hand:NE,HandCoins:pH,HandHeart:fH,HandHelping:Uw,HandMetal:gH,HandPlatter:xH,Handshake:yH,HardDrive:SE,HardDriveDownload:vH,HardDriveUpload:_H,HardHat:bH,Hash:E4,Haze:wH,HdmiPort:jH,Heading:MH,Heading1:CE,Heading2:ME,Heading3:kH,Heading4:NH,Heading5:SH,Heading6:CH,HeadphoneOff:TH,Headphones:AH,Headset:EH,Heart:Ti,HeartCrack:IH,HeartHandshake:PH,HeartOff:LH,HeartPulse:DH,Heater:OH,Hexagon:RH,Highlighter:FH,History:I4,Hop:BH,HopOff:zH,Hospital:$H,Hotel:UH,Hourglass:qH,House:Zn,HousePlug:VH,HousePlus:HH,IceCreamBowl:qw,IceCreamCone:Vw,IdCard:WH,Image:fl,ImageDown:GH,ImageMinus:KH,ImageOff:ZH,ImagePlay:YH,ImagePlus:M1,ImageUp:XH,ImageUpscale:QH,Images:JH,Import:eW,Inbox:tW,IndentDecrease:Hw,IndentIncrease:Ww,IndianRupee:sW,Infinity:rW,Info:nW,InspectionPanel:aW,Instagram:vu,Italic:P4,IterationCcw:iW,IterationCw:oW,JapaneseYen:lW,Joystick:cW,Kanban:Sx,Key:Xm,KeyRound:kk,KeySquare:dW,Keyboard:mW,KeyboardMusic:uW,KeyboardOff:hW,Lamp:vW,LampCeiling:pW,LampDesk:fW,LampFloor:gW,LampWallDown:xW,LampWallUp:yW,LandPlot:_W,Landmark:bW,Languages:wW,Laptop:kW,LaptopMinimal:Gw,LaptopMinimalCheck:jW,Lasso:SW,LassoSelect:NW,Laugh:CW,Layers:AW,Layers2:MW,Layers3:TW,LayoutDashboard:Nk,LayoutGrid:Qm,LayoutList:EW,LayoutPanelLeft:IW,LayoutPanelTop:PW,LayoutTemplate:Sk,Leaf:LW,LeafyGreen:DW,Lectern:OW,LetterText:RW,Library:L4,LibraryBig:FW,LifeBuoy:D4,Ligature:zW,Lightbulb:t0,LightbulbOff:BW,Link:Ro,Link2:Jm,Link2Off:$W,Linkedin:cm,List:dm,ListCheck:UW,ListChecks:qW,ListCollapse:VW,ListEnd:HW,ListFilter:WW,ListMinus:GW,ListMusic:KW,ListOrdered:O4,ListPlus:ZW,ListRestart:YW,ListStart:XW,ListTodo:QW,ListTree:JW,ListVideo:eG,ListX:tG,Loader:rG,LoaderCircle:Us,LoaderPinwheel:sG,Locate:TE,LocateFixed:nG,LocateOff:aG,Lock:zu,LockKeyhole:iG,LockKeyholeOpen:Kw,LockOpen:Zw,LogIn:R4,LogOut:F4,Logs:oG,Lollipop:lG,Luggage:cG,Magnet:dG,Mail:zr,MailCheck:uG,MailMinus:hG,MailOpen:mG,MailPlus:pG,MailQuestion:fG,MailSearch:gG,MailWarning:xG,MailX:AE,Mailbox:yG,Mails:vG,Map:EG,MapPin:Gi,MapPinCheck:bG,MapPinCheckInside:_G,MapPinHouse:wG,MapPinMinus:kG,MapPinMinusInside:jG,MapPinOff:NG,MapPinPlus:CG,MapPinPlusInside:SG,MapPinX:TG,MapPinXInside:MG,MapPinned:AG,Martini:IG,Maximize:LG,Maximize2:PG,Medal:s0,Megaphone:fg,MegaphoneOff:DG,Meh:OG,MemoryStick:RG,Menu:EE,Merge:FG,MessageCircle:Gl,MessageCircleCode:zG,MessageCircleDashed:BG,MessageCircleHeart:z4,MessageCircleMore:$G,MessageCircleOff:UG,MessageCirclePlus:qG,MessageCircleQuestion:IE,MessageCircleReply:VG,MessageCircleWarning:HG,MessageCircleX:WG,MessageSquare:Eo,MessageSquareCode:GG,MessageSquareDashed:KG,MessageSquareDiff:ZG,MessageSquareDot:YG,MessageSquareHeart:PE,MessageSquareLock:XG,MessageSquareMore:QG,MessageSquareOff:JG,MessageSquarePlus:B4,MessageSquareQuote:LE,MessageSquareReply:eK,MessageSquareShare:tK,MessageSquareText:sK,MessageSquareWarning:rK,MessageSquareX:nK,MessagesSquare:aK,Mic:DE,MicOff:iK,MicVocal:Yw,Microchip:oK,Microscope:lK,Microwave:cK,Milestone:dK,Milk:hK,MilkOff:uK,Minimize:pK,Minimize2:mK,Minus:T1,Monitor:Ck,MonitorCheck:fK,MonitorCog:gK,MonitorDot:xK,MonitorDown:yK,MonitorOff:vK,MonitorPause:_K,MonitorPlay:bK,MonitorSmartphone:wK,MonitorSpeaker:jK,MonitorStop:kK,MonitorUp:NK,MonitorX:SK,Moon:MK,MoonStar:CK,Mountain:AK,MountainSnow:TK,Mouse:DK,MouseOff:EK,MousePointer:LK,MousePointer2:IK,MousePointerBan:PK,MousePointerClick:A1,Move:KK,Move3d:Xw,MoveDiagonal:RK,MoveDiagonal2:OK,MoveDown:BK,MoveDownLeft:FK,MoveDownRight:zK,MoveHorizontal:$K,MoveLeft:UK,MoveRight:qK,MoveUp:WK,MoveUpLeft:VK,MoveUpRight:HK,MoveVertical:GK,Music:QK,Music2:ZK,Music3:YK,Music4:XK,Navigation:OE,Navigation2:eZ,Navigation2Off:JK,NavigationOff:tZ,Network:sZ,Newspaper:r0,Nfc:rZ,Notebook:oZ,NotebookPen:nZ,NotebookTabs:aZ,NotebookText:iZ,NotepadText:cZ,NotepadTextDashed:lZ,Nut:uZ,NutOff:dZ,Octagon:mZ,OctagonAlert:Qw,OctagonMinus:hZ,OctagonPause:Jw,OctagonX:e2,Omega:pZ,Option:fZ,Orbit:gZ,Origami:xZ,Package:mc,Package2:yZ,PackageCheck:vZ,PackageMinus:_Z,PackageOpen:bZ,PackagePlus:wZ,PackageSearch:jZ,PackageX:kZ,PaintBucket:NZ,PaintRoller:SZ,Paintbrush:CZ,PaintbrushVertical:t2,Palette:hd,PanelBottom:AZ,PanelBottomClose:MZ,PanelBottomDashed:s2,PanelBottomOpen:TZ,PanelLeft:i2,PanelLeftClose:r2,PanelLeftDashed:n2,PanelLeftOpen:a2,PanelRight:PZ,PanelRightClose:EZ,PanelRightDashed:o2,PanelRightOpen:IZ,PanelTop:OZ,PanelTopClose:LZ,PanelTopDashed:l2,PanelTopOpen:DZ,PanelsLeftBottom:RZ,PanelsRightBottom:FZ,PanelsTopLeft:Av,Paperclip:Mk,Parentheses:zZ,ParkingMeter:BZ,PartyPopper:md,Pause:ep,PawPrint:$Z,PcCase:UZ,Pen:Iv,PenLine:Ev,PenOff:qZ,PenTool:Tk,Pencil:Xa,PencilLine:VZ,PencilOff:HZ,PencilRuler:WZ,Pentagon:GZ,Percent:$4,PersonStanding:KZ,PhilippinePeso:ZZ,Phone:Ha,PhoneCall:YZ,PhoneForwarded:XZ,PhoneIncoming:QZ,PhoneMissed:JZ,PhoneOff:eY,PhoneOutgoing:tY,Pi:sY,Piano:rY,Pickaxe:nY,PictureInPicture:iY,PictureInPicture2:aY,PiggyBank:oY,Pilcrow:dY,PilcrowLeft:lY,PilcrowRight:cY,Pill:hY,PillBottle:uY,Pin:E1,PinOff:RE,Pipette:mY,Pizza:pY,Plane:xY,PlaneLanding:fY,PlaneTakeoff:gY,Play:Kl,Plug:FE,Plug2:yY,PlugZap:c2,Plus:ar,Pocket:_Y,PocketKnife:vY,Podcast:bY,Pointer:jY,PointerOff:wY,Popcorn:kY,Popsicle:NY,PoundSterling:SY,Power:MY,PowerOff:CY,Presentation:Gp,Printer:zE,PrinterCheck:TY,Projector:AY,Proportions:EY,Puzzle:IY,Pyramid:PY,QrCode:Ak,Quote:U4,Rabbit:LY,Radar:DY,Radiation:OY,Radical:RY,Radio:Ek,RadioReceiver:FY,RadioTower:zY,Radius:BY,RailSymbol:$Y,Rainbow:UY,Rat:qY,Ratio:VY,Receipt:JY,ReceiptCent:HY,ReceiptEuro:WY,ReceiptIndianRupee:GY,ReceiptJapaneseYen:KY,ReceiptPoundSterling:ZY,ReceiptRussianRuble:YY,ReceiptSwissFranc:XY,ReceiptText:QY,RectangleEllipsis:d2,RectangleHorizontal:eX,RectangleVertical:tX,Recycle:sX,Redo:q4,Redo2:rX,RedoDot:nX,RefreshCcw:iX,RefreshCcwDot:aX,RefreshCw:el,RefreshCwOff:oX,Refrigerator:lX,Regex:cX,RemoveFormatting:dX,Repeat:BE,Repeat1:uX,Repeat2:hX,Replace:pX,ReplaceAll:mX,Reply:$E,ReplyAll:fX,Rewind:gX,Ribbon:xX,Rocket:Cx,RockingChair:yX,RollerCoaster:vX,Rotate3d:u2,RotateCcw:Ik,RotateCcwSquare:_X,RotateCw:UE,RotateCwSquare:bX,Route:jX,RouteOff:wX,Router:kX,Rows2:h2,Rows3:m2,Rows4:NX,Rss:SX,Ruler:CX,RussianRuble:MX,Sailboat:TX,Salad:AX,Sandwich:EX,Satellite:PX,SatelliteDish:IX,Save:um,SaveAll:LX,SaveOff:DX,Scale:OX,Scale3d:p2,Scaling:RX,Scan:HX,ScanBarcode:FX,ScanEye:zX,ScanFace:BX,ScanLine:$X,ScanQrCode:UX,ScanSearch:qX,ScanText:VX,School:WX,Scissors:KX,ScissorsLineDashed:GX,ScreenShare:YX,ScreenShareOff:ZX,Scroll:QX,ScrollText:XX,Search:On,SearchCheck:JX,SearchCode:eQ,SearchSlash:tQ,SearchX:sQ,Section:rQ,Send:Wa,SendHorizontal:f2,SendToBack:nQ,SeparatorHorizontal:aQ,SeparatorVertical:iQ,Server:dQ,ServerCog:oQ,ServerCrash:lQ,ServerOff:cQ,Settings:Ic,Settings2:uQ,Shapes:hQ,Share:qE,Share2:Kc,Sheet:mQ,Shell:pQ,Shield:Bu,ShieldAlert:fQ,ShieldBan:gQ,ShieldCheck:VE,ShieldEllipsis:xQ,ShieldHalf:yQ,ShieldMinus:vQ,ShieldOff:_Q,ShieldPlus:bQ,ShieldQuestion:wQ,ShieldX:g2,Ship:kQ,ShipWheel:jQ,Shirt:NQ,ShoppingBag:Mx,ShoppingBasket:SQ,ShoppingCart:Jh,Shovel:CQ,ShowerHead:MQ,Shrink:TQ,Shrub:AQ,Shuffle:EQ,Sigma:IQ,Signal:RQ,SignalHigh:PQ,SignalLow:LQ,SignalMedium:DQ,SignalZero:OQ,Signature:FQ,Signpost:BQ,SignpostBig:zQ,Siren:$Q,SkipBack:UQ,SkipForward:qQ,Skull:VQ,Slack:HQ,Slash:WQ,Slice:GQ,SlidersHorizontal:HE,SlidersVertical:x2,Smartphone:n0,SmartphoneCharging:KQ,SmartphoneNfc:ZQ,Smile:XQ,SmilePlus:YQ,Snail:QQ,Snowflake:o1,Sofa:JQ,Soup:eJ,Space:tJ,Spade:sJ,Sparkle:rJ,Sparkles:Sn,Speaker:nJ,Speech:aJ,SpellCheck:oJ,SpellCheck2:iJ,Spline:lJ,Split:cJ,SprayCan:dJ,Sprout:uJ,Square:Tx,SquareActivity:y2,SquareArrowDown:b2,SquareArrowDownLeft:v2,SquareArrowDownRight:_2,SquareArrowLeft:w2,SquareArrowOutDownLeft:j2,SquareArrowOutDownRight:k2,SquareArrowOutUpLeft:N2,SquareArrowOutUpRight:S2,SquareArrowRight:C2,SquareArrowUp:A2,SquareArrowUpLeft:M2,SquareArrowUpRight:T2,SquareAsterisk:E2,SquareBottomDashedScissors:I2,SquareChartGantt:sx,SquareCheck:P2,SquareCheckBig:Oy,SquareChevronDown:L2,SquareChevronLeft:D2,SquareChevronRight:O2,SquareChevronUp:R2,SquareCode:F2,SquareDashed:$2,SquareDashedBottom:mJ,SquareDashedBottomCode:hJ,SquareDashedKanban:z2,SquareDashedMousePointer:B2,SquareDivide:U2,SquareDot:q2,SquareEqual:V2,SquareFunction:H2,SquareKanban:W2,SquareLibrary:G2,SquareM:K2,SquareMenu:Z2,SquareMinus:Y2,SquareMousePointer:X2,SquareParking:J2,SquareParkingOff:Q2,SquarePen:_c,SquarePercent:ej,SquarePi:tj,SquarePilcrow:sj,SquarePlay:rj,SquarePlus:nj,SquarePower:aj,SquareRadical:pJ,SquareScissors:ij,SquareSigma:oj,SquareSlash:lj,SquareSplitHorizontal:cj,SquareSplitVertical:dj,SquareSquare:fJ,SquareStack:gJ,SquareTerminal:uj,SquareUser:mj,SquareUserRound:hj,SquareX:pj,Squircle:xJ,Squirrel:yJ,Stamp:vJ,Star:qn,StarHalf:_J,StarOff:bJ,StepBack:wJ,StepForward:jJ,Stethoscope:kJ,Sticker:NJ,StickyNote:SJ,Store:CJ,StretchHorizontal:MJ,StretchVertical:TJ,Strikethrough:AJ,Subscript:EJ,Sun:I1,SunDim:IJ,SunMedium:PJ,SunMoon:LJ,SunSnow:DJ,Sunrise:OJ,Sunset:RJ,Superscript:FJ,SwatchBook:zJ,SwissFranc:BJ,SwitchCamera:$J,Sword:UJ,Swords:qJ,Syringe:VJ,Table:WE,Table2:V4,TableCellsMerge:HJ,TableCellsSplit:WJ,TableColumnsSplit:GJ,TableOfContents:KJ,TableProperties:ZJ,TableRowsSplit:YJ,Tablet:QJ,TabletSmartphone:XJ,Tablets:JJ,Tag:Kp,Tags:eee,Tally1:tee,Tally2:see,Tally3:ree,Tally4:nee,Tally5:aee,Tangent:iee,Target:hm,Telescope:oee,Tent:cee,TentTree:lee,Terminal:dee,TestTube:uee,TestTubeDiagonal:fj,TestTubes:hee,Text:xee,TextCursor:pee,TextCursorInput:mee,TextQuote:fee,TextSearch:gee,TextSelect:gj,Theater:yee,Thermometer:bee,ThermometerSnowflake:vee,ThermometerSun:_ee,ThumbsDown:GE,ThumbsUp:Ed,Ticket:KE,TicketCheck:wee,TicketMinus:jee,TicketPercent:kee,TicketPlus:Nee,TicketSlash:See,TicketX:Cee,Tickets:Tee,TicketsPlane:Mee,Timer:Iee,TimerOff:Aee,TimerReset:Eee,ToggleLeft:Pee,ToggleRight:Lee,Toilet:Dee,Tornado:Oee,Torus:Ree,Touchpad:zee,TouchpadOff:Fee,TowerControl:Bee,ToyBrick:$ee,Tractor:Uee,TrafficCone:qee,TrainFront:Hee,TrainFrontTunnel:Vee,TrainTrack:Wee,TramFront:xj,Trash:Gee,Trash2:Ir,TreeDeciduous:Kee,TreePalm:yj,TreePine:P1,Trees:Zee,Trello:Yee,TrendingDown:Pk,TrendingUp:Jd,TrendingUpDown:Xee,Triangle:Jee,TriangleAlert:Lu,TriangleRight:Qee,Trophy:vo,Truck:ZE,Turtle:ete,Tv:ste,TvMinimal:vj,TvMinimalPlay:tte,Twitch:rte,Twitter:nte,Type:ite,TypeOutline:ate,Umbrella:lte,UmbrellaOff:ote,Underline:cte,Undo:H4,Undo2:dte,UndoDot:ute,UnfoldHorizontal:hte,UnfoldVertical:mte,Ungroup:pte,University:_j,Unlink:YE,Unlink2:fte,Unplug:gte,Upload:ji,Usb:xte,User:Wo,UserCheck:Lk,UserCog:XE,UserMinus:QE,UserPen:yte,UserPlus:Zc,UserRound:Sj,UserRoundCheck:bj,UserRoundCog:wj,UserRoundMinus:jj,UserRoundPen:vte,UserRoundPlus:kj,UserRoundSearch:_te,UserRoundX:Nj,UserSearch:bte,UserX:wte,Users:br,UsersRound:Cj,Utensils:Tj,UtensilsCrossed:Mj,UtilityPole:jte,Variable:JE,Vault:kte,Vegan:Nte,VenetianMask:Ste,Vibrate:Mte,VibrateOff:Cte,Video:Wn,VideoOff:Tte,Videotape:Ate,View:Ete,Voicemail:Ite,Volleyball:Pte,Volume:Fte,Volume1:Lte,Volume2:Dte,VolumeOff:Ote,VolumeX:Rte,Vote:zte,Wallet:$te,WalletCards:Bte,WalletMinimal:Aj,Wallpaper:Ute,Wand:qte,WandSparkles:Ej,Warehouse:Vte,WashingMachine:Hte,Watch:Wte,Waves:Gte,Waypoints:Kte,Webcam:Zte,Webhook:Xte,WebhookOff:Yte,Weight:Qte,Wheat:ese,WheatOff:Jte,WholeWord:tse,Wifi:ise,WifiHigh:sse,WifiLow:rse,WifiOff:nse,WifiZero:ase,Wind:lse,WindArrowDown:ose,Wine:dse,WineOff:cse,Workflow:use,Worm:hse,WrapText:mse,Wrench:a0,X:Xr,Youtube:pse,Zap:Ax,ZapOff:fse,ZoomIn:W4,ZoomOut:G4},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 TOe=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Q8,AArrowDownIcon:Q8,AArrowUp:J8,AArrowUpIcon:J8,ALargeSmall:eR,ALargeSmallIcon:eR,Accessibility:tR,AccessibilityIcon:tR,Activity:wx,ActivityIcon:wx,ActivitySquare:y2,ActivitySquareIcon:y2,AirVent:sR,AirVentIcon:sR,Airplay:rR,AirplayIcon:rR,AlarmCheck:_b,AlarmCheckIcon:_b,AlarmClock:aR,AlarmClockCheck:_b,AlarmClockCheckIcon:_b,AlarmClockIcon:aR,AlarmClockMinus:bb,AlarmClockMinusIcon:bb,AlarmClockOff:nR,AlarmClockOffIcon:nR,AlarmClockPlus:wb,AlarmClockPlusIcon:wb,AlarmMinus:bb,AlarmMinusIcon:bb,AlarmPlus:wb,AlarmPlusIcon:wb,AlarmSmoke:iR,AlarmSmokeIcon:iR,Album:oR,AlbumIcon:oR,AlertCircle:Qo,AlertCircleIcon:Qo,AlertOctagon:Qw,AlertOctagonIcon:Qw,AlertTriangle:Lu,AlertTriangleIcon:Lu,AlignCenter:w4,AlignCenterHorizontal:lR,AlignCenterHorizontalIcon:lR,AlignCenterIcon:w4,AlignCenterVertical:cR,AlignCenterVerticalIcon:cR,AlignEndHorizontal:dR,AlignEndHorizontalIcon:dR,AlignEndVertical:uR,AlignEndVerticalIcon:uR,AlignHorizontalDistributeCenter:hR,AlignHorizontalDistributeCenterIcon:hR,AlignHorizontalDistributeEnd:mR,AlignHorizontalDistributeEndIcon:mR,AlignHorizontalDistributeStart:pR,AlignHorizontalDistributeStartIcon:pR,AlignHorizontalJustifyCenter:fR,AlignHorizontalJustifyCenterIcon:fR,AlignHorizontalJustifyEnd:gR,AlignHorizontalJustifyEndIcon:gR,AlignHorizontalJustifyStart:xR,AlignHorizontalJustifyStartIcon:xR,AlignHorizontalSpaceAround:yR,AlignHorizontalSpaceAroundIcon:yR,AlignHorizontalSpaceBetween:vR,AlignHorizontalSpaceBetweenIcon:vR,AlignJustify:_R,AlignJustifyIcon:_R,AlignLeft:j4,AlignLeftIcon:j4,AlignRight:k4,AlignRightIcon:k4,AlignStartHorizontal:bR,AlignStartHorizontalIcon:bR,AlignStartVertical:wR,AlignStartVerticalIcon:wR,AlignVerticalDistributeCenter:jR,AlignVerticalDistributeCenterIcon:jR,AlignVerticalDistributeEnd:kR,AlignVerticalDistributeEndIcon:kR,AlignVerticalDistributeStart:NR,AlignVerticalDistributeStartIcon:NR,AlignVerticalJustifyCenter:SR,AlignVerticalJustifyCenterIcon:SR,AlignVerticalJustifyEnd:CR,AlignVerticalJustifyEndIcon:CR,AlignVerticalJustifyStart:MR,AlignVerticalJustifyStartIcon:MR,AlignVerticalSpaceAround:TR,AlignVerticalSpaceAroundIcon:TR,AlignVerticalSpaceBetween:AR,AlignVerticalSpaceBetweenIcon:AR,Ambulance:ER,AmbulanceIcon:ER,Ampersand:IR,AmpersandIcon:IR,Ampersands:PR,AmpersandsIcon:PR,Amphora:LR,AmphoraIcon:LR,Anchor:DR,AnchorIcon:DR,Angry:OR,AngryIcon:OR,Annoyed:RR,AnnoyedIcon:RR,Antenna:FR,AntennaIcon:FR,Anvil:zR,AnvilIcon:zR,Aperture:BR,ApertureIcon:BR,AppWindow:yE,AppWindowIcon:yE,AppWindowMac:$R,AppWindowMacIcon:$R,Apple:UR,AppleIcon:UR,Archive:N4,ArchiveIcon:N4,ArchiveRestore:vE,ArchiveRestoreIcon:vE,ArchiveX:qR,ArchiveXIcon:qR,AreaChart:Ob,AreaChartIcon:Ob,Armchair:VR,ArmchairIcon:VR,ArrowBigDown:WR,ArrowBigDownDash:HR,ArrowBigDownDashIcon:HR,ArrowBigDownIcon:WR,ArrowBigLeft:KR,ArrowBigLeftDash:GR,ArrowBigLeftDashIcon:GR,ArrowBigLeftIcon:KR,ArrowBigRight:YR,ArrowBigRightDash:ZR,ArrowBigRightDashIcon:ZR,ArrowBigRightIcon:YR,ArrowBigUp:QR,ArrowBigUpDash:XR,ArrowBigUpDashIcon:XR,ArrowBigUpIcon:QR,ArrowDown:jx,ArrowDown01:JR,ArrowDown01Icon:JR,ArrowDown10:eF,ArrowDown10Icon:eF,ArrowDownAZ:jb,ArrowDownAZIcon:jb,ArrowDownAz:jb,ArrowDownAzIcon:jb,ArrowDownCircle:Kb,ArrowDownCircleIcon:Kb,ArrowDownFromLine:tF,ArrowDownFromLineIcon:tF,ArrowDownIcon:jx,ArrowDownLeft:sF,ArrowDownLeftFromCircle:Yb,ArrowDownLeftFromCircleIcon:Yb,ArrowDownLeftFromSquare:j2,ArrowDownLeftFromSquareIcon:j2,ArrowDownLeftIcon:sF,ArrowDownLeftSquare:v2,ArrowDownLeftSquareIcon:v2,ArrowDownNarrowWide:rF,ArrowDownNarrowWideIcon:rF,ArrowDownRight:nF,ArrowDownRightFromCircle:Xb,ArrowDownRightFromCircleIcon:Xb,ArrowDownRightFromSquare:k2,ArrowDownRightFromSquareIcon:k2,ArrowDownRightIcon:nF,ArrowDownRightSquare:_2,ArrowDownRightSquareIcon:_2,ArrowDownSquare:b2,ArrowDownSquareIcon:b2,ArrowDownToDot:aF,ArrowDownToDotIcon:aF,ArrowDownToLine:iF,ArrowDownToLineIcon:iF,ArrowDownUp:oF,ArrowDownUpIcon:oF,ArrowDownWideNarrow:kb,ArrowDownWideNarrowIcon:kb,ArrowDownZA:Nb,ArrowDownZAIcon:Nb,ArrowDownZa:Nb,ArrowDownZaIcon:Nb,ArrowLeft:bi,ArrowLeftCircle:Zb,ArrowLeftCircleIcon:Zb,ArrowLeftFromLine:lF,ArrowLeftFromLineIcon:lF,ArrowLeftIcon:bi,ArrowLeftRight:cF,ArrowLeftRightIcon:cF,ArrowLeftSquare:w2,ArrowLeftSquareIcon:w2,ArrowLeftToLine:dF,ArrowLeftToLineIcon:dF,ArrowRight:qi,ArrowRightCircle:ew,ArrowRightCircleIcon:ew,ArrowRightFromLine:uF,ArrowRightFromLineIcon:uF,ArrowRightIcon:qi,ArrowRightLeft:Zy,ArrowRightLeftIcon:Zy,ArrowRightSquare:C2,ArrowRightSquareIcon:C2,ArrowRightToLine:hF,ArrowRightToLineIcon:hF,ArrowUp:Wm,ArrowUp01:mF,ArrowUp01Icon:mF,ArrowUp10:pF,ArrowUp10Icon:pF,ArrowUpAZ:Sb,ArrowUpAZIcon:Sb,ArrowUpAz:Sb,ArrowUpAzIcon:Sb,ArrowUpCircle:tw,ArrowUpCircleIcon:tw,ArrowUpDown:Hp,ArrowUpDownIcon:Hp,ArrowUpFromDot:fF,ArrowUpFromDotIcon:fF,ArrowUpFromLine:gF,ArrowUpFromLineIcon:gF,ArrowUpIcon:Wm,ArrowUpLeft:xF,ArrowUpLeftFromCircle:Qb,ArrowUpLeftFromCircleIcon:Qb,ArrowUpLeftFromSquare:N2,ArrowUpLeftFromSquareIcon:N2,ArrowUpLeftIcon:xF,ArrowUpLeftSquare:M2,ArrowUpLeftSquareIcon:M2,ArrowUpNarrowWide:Cb,ArrowUpNarrowWideIcon:Cb,ArrowUpRight:yF,ArrowUpRightFromCircle:Jb,ArrowUpRightFromCircleIcon:Jb,ArrowUpRightFromSquare:S2,ArrowUpRightFromSquareIcon:S2,ArrowUpRightIcon:yF,ArrowUpRightSquare:T2,ArrowUpRightSquareIcon:T2,ArrowUpSquare:A2,ArrowUpSquareIcon:A2,ArrowUpToLine:vF,ArrowUpToLineIcon:vF,ArrowUpWideNarrow:_F,ArrowUpWideNarrowIcon:_F,ArrowUpZA:Mb,ArrowUpZAIcon:Mb,ArrowUpZa:Mb,ArrowUpZaIcon:Mb,ArrowsUpFromLine:bF,ArrowsUpFromLineIcon:bF,Asterisk:wF,AsteriskIcon:wF,AsteriskSquare:E2,AsteriskSquareIcon:E2,AtSign:jF,AtSignIcon:jF,Atom:kF,AtomIcon:kF,AudioLines:NF,AudioLinesIcon:NF,AudioWaveform:SF,AudioWaveformIcon:SF,Award:nc,AwardIcon:nc,Axe:CF,AxeIcon:CF,Axis3D:Tb,Axis3DIcon:Tb,Axis3d:Tb,Axis3dIcon:Tb,Baby:MF,BabyIcon:MF,Backpack:TF,BackpackIcon:TF,Badge:HF,BadgeAlert:AF,BadgeAlertIcon:AF,BadgeCent:EF,BadgeCentIcon:EF,BadgeCheck:Ab,BadgeCheckIcon:Ab,BadgeDollarSign:IF,BadgeDollarSignIcon:IF,BadgeEuro:PF,BadgeEuroIcon:PF,BadgeHelp:LF,BadgeHelpIcon:LF,BadgeIcon:HF,BadgeIndianRupee:DF,BadgeIndianRupeeIcon:DF,BadgeInfo:OF,BadgeInfoIcon:OF,BadgeJapaneseYen:RF,BadgeJapaneseYenIcon:RF,BadgeMinus:FF,BadgeMinusIcon:FF,BadgePercent:zF,BadgePercentIcon:zF,BadgePlus:BF,BadgePlusIcon:BF,BadgePoundSterling:$F,BadgePoundSterlingIcon:$F,BadgeRussianRuble:UF,BadgeRussianRubleIcon:UF,BadgeSwissFranc:qF,BadgeSwissFrancIcon:qF,BadgeX:VF,BadgeXIcon:VF,BaggageClaim:WF,BaggageClaimIcon:WF,Ban:GF,BanIcon:GF,Banana:KF,BananaIcon:KF,Bandage:ZF,BandageIcon:ZF,Banknote:YF,BanknoteIcon:YF,BarChart:qb,BarChart2:Vb,BarChart2Icon:Vb,BarChart3:Sc,BarChart3Icon:Sc,BarChart4:$b,BarChart4Icon:$b,BarChartBig:Bb,BarChartBigIcon:Bb,BarChartHorizontal:Fb,BarChartHorizontalBig:Rb,BarChartHorizontalBigIcon:Rb,BarChartHorizontalIcon:Fb,BarChartIcon:qb,Barcode:XF,BarcodeIcon:XF,Baseline:QF,BaselineIcon:QF,Bath:j1,BathIcon:j1,Battery:nz,BatteryCharging:JF,BatteryChargingIcon:JF,BatteryFull:ez,BatteryFullIcon:ez,BatteryIcon:nz,BatteryLow:tz,BatteryLowIcon:tz,BatteryMedium:sz,BatteryMediumIcon:sz,BatteryWarning:rz,BatteryWarningIcon:rz,Beaker:az,BeakerIcon:az,Bean:oz,BeanIcon:oz,BeanOff:iz,BeanOffIcon:iz,Bed:k1,BedDouble:lz,BedDoubleIcon:lz,BedIcon:k1,BedSingle:cz,BedSingleIcon:cz,Beef:dz,BeefIcon:dz,Beer:hz,BeerIcon:hz,BeerOff:uz,BeerOffIcon:uz,Bell:dg,BellDot:mz,BellDotIcon:mz,BellElectric:pz,BellElectricIcon:pz,BellIcon:dg,BellMinus:fz,BellMinusIcon:fz,BellOff:xk,BellOffIcon:xk,BellPlus:gz,BellPlusIcon:gz,BellRing:xz,BellRingIcon:xz,BetweenHorizonalEnd:Eb,BetweenHorizonalEndIcon:Eb,BetweenHorizonalStart:Ib,BetweenHorizonalStartIcon:Ib,BetweenHorizontalEnd:Eb,BetweenHorizontalEndIcon:Eb,BetweenHorizontalStart:Ib,BetweenHorizontalStartIcon:Ib,BetweenVerticalEnd:yz,BetweenVerticalEndIcon:yz,BetweenVerticalStart:vz,BetweenVerticalStartIcon:vz,BicepsFlexed:_z,BicepsFlexedIcon:_z,Bike:bz,BikeIcon:bz,Binary:wz,BinaryIcon:wz,Binoculars:jz,BinocularsIcon:jz,Biohazard:kz,BiohazardIcon:kz,Bird:Nz,BirdIcon:Nz,Bitcoin:Sz,BitcoinIcon:Sz,Blend:Cz,BlendIcon:Cz,Blinds:Mz,BlindsIcon:Mz,Blocks:Tz,BlocksIcon:Tz,Bluetooth:Pz,BluetoothConnected:Az,BluetoothConnectedIcon:Az,BluetoothIcon:Pz,BluetoothOff:Ez,BluetoothOffIcon:Ez,BluetoothSearching:Iz,BluetoothSearchingIcon:Iz,Bold:S4,BoldIcon:S4,Bolt:Lz,BoltIcon:Lz,Bomb:Dz,BombIcon:Dz,Bone:Oz,BoneIcon:Oz,Book:n7,BookA:Rz,BookAIcon:Rz,BookAudio:Fz,BookAudioIcon:Fz,BookCheck:zz,BookCheckIcon:zz,BookCopy:Bz,BookCopyIcon:Bz,BookDashed:Pb,BookDashedIcon:Pb,BookDown:$z,BookDownIcon:$z,BookHeadphones:Uz,BookHeadphonesIcon:Uz,BookHeart:qz,BookHeartIcon:qz,BookIcon:n7,BookImage:Vz,BookImageIcon:Vz,BookKey:Hz,BookKeyIcon:Hz,BookLock:Wz,BookLockIcon:Wz,BookMarked:Gz,BookMarkedIcon:Gz,BookMinus:Kz,BookMinusIcon:Kz,BookOpen:Yy,BookOpenCheck:Zz,BookOpenCheckIcon:Zz,BookOpenIcon:Yy,BookOpenText:Yz,BookOpenTextIcon:Yz,BookPlus:Xz,BookPlusIcon:Xz,BookTemplate:Pb,BookTemplateIcon:Pb,BookText:Qz,BookTextIcon:Qz,BookType:Jz,BookTypeIcon:Jz,BookUp:t7,BookUp2:e7,BookUp2Icon:e7,BookUpIcon:t7,BookUser:s7,BookUserIcon:s7,BookX:r7,BookXIcon:r7,Bookmark:ug,BookmarkCheck:a7,BookmarkCheckIcon:a7,BookmarkIcon:ug,BookmarkMinus:i7,BookmarkMinusIcon:i7,BookmarkPlus:_E,BookmarkPlusIcon:_E,BookmarkX:o7,BookmarkXIcon:o7,BoomBox:l7,BoomBoxIcon:l7,Bot:C4,BotIcon:C4,BotMessageSquare:c7,BotMessageSquareIcon:c7,BotOff:d7,BotOffIcon:d7,Box:u7,BoxIcon:u7,BoxSelect:$2,BoxSelectIcon:$2,Boxes:h7,BoxesIcon:h7,Braces:Lb,BracesIcon:Lb,Brackets:m7,BracketsIcon:m7,Brain:bE,BrainCircuit:p7,BrainCircuitIcon:p7,BrainCog:f7,BrainCogIcon:f7,BrainIcon:bE,BrickWall:g7,BrickWallIcon:g7,Briefcase:Fu,BriefcaseBusiness:x7,BriefcaseBusinessIcon:x7,BriefcaseConveyorBelt:y7,BriefcaseConveyorBeltIcon:y7,BriefcaseIcon:Fu,BriefcaseMedical:v7,BriefcaseMedicalIcon:v7,BringToFront:_7,BringToFrontIcon:_7,Brush:b7,BrushIcon:b7,Bug:k7,BugIcon:k7,BugOff:w7,BugOffIcon:w7,BugPlay:j7,BugPlayIcon:j7,Building:yk,Building2:Ya,Building2Icon:Ya,BuildingIcon:yk,Bus:S7,BusFront:N7,BusFrontIcon:N7,BusIcon:S7,Cable:M7,CableCar:C7,CableCarIcon:C7,CableIcon:M7,Cake:Gm,CakeIcon:Gm,CakeSlice:T7,CakeSliceIcon:T7,Calculator:A7,CalculatorIcon:A7,Calendar:xn,Calendar1:E7,Calendar1Icon:E7,CalendarArrowDown:I7,CalendarArrowDownIcon:I7,CalendarArrowUp:P7,CalendarArrowUpIcon:P7,CalendarCheck:D7,CalendarCheck2:L7,CalendarCheck2Icon:L7,CalendarCheckIcon:D7,CalendarClock:wE,CalendarClockIcon:wE,CalendarCog:O7,CalendarCogIcon:O7,CalendarDays:Km,CalendarDaysIcon:Km,CalendarFold:R7,CalendarFoldIcon:R7,CalendarHeart:F7,CalendarHeartIcon:F7,CalendarIcon:xn,CalendarMinus:B7,CalendarMinus2:z7,CalendarMinus2Icon:z7,CalendarMinusIcon:B7,CalendarOff:$7,CalendarOffIcon:$7,CalendarPlus:N1,CalendarPlus2:U7,CalendarPlus2Icon:U7,CalendarPlusIcon:N1,CalendarRange:q7,CalendarRangeIcon:q7,CalendarSearch:V7,CalendarSearchIcon:V7,CalendarSync:H7,CalendarSyncIcon:H7,CalendarX:G7,CalendarX2:W7,CalendarX2Icon:W7,CalendarXIcon:G7,Camera:hg,CameraIcon:hg,CameraOff:K7,CameraOffIcon:K7,CandlestickChart:zb,CandlestickChartIcon:zb,Candy:X7,CandyCane:Z7,CandyCaneIcon:Z7,CandyIcon:X7,CandyOff:Y7,CandyOffIcon:Y7,Cannabis:Q7,CannabisIcon:Q7,Captions:Db,CaptionsIcon:Db,CaptionsOff:J7,CaptionsOffIcon:J7,Car:sB,CarFront:eB,CarFrontIcon:eB,CarIcon:sB,CarTaxiFront:tB,CarTaxiFrontIcon:tB,Caravan:rB,CaravanIcon:rB,Carrot:nB,CarrotIcon:nB,CaseLower:aB,CaseLowerIcon:aB,CaseSensitive:iB,CaseSensitiveIcon:iB,CaseUpper:oB,CaseUpperIcon:oB,CassetteTape:lB,CassetteTapeIcon:lB,Cast:cB,CastIcon:cB,Castle:dB,CastleIcon:dB,Cat:uB,CatIcon:uB,Cctv:hB,CctvIcon:hB,ChartArea:Ob,ChartAreaIcon:Ob,ChartBar:Fb,ChartBarBig:Rb,ChartBarBigIcon:Rb,ChartBarDecreasing:mB,ChartBarDecreasingIcon:mB,ChartBarIcon:Fb,ChartBarIncreasing:pB,ChartBarIncreasingIcon:pB,ChartBarStacked:fB,ChartBarStackedIcon:fB,ChartCandlestick:zb,ChartCandlestickIcon:zb,ChartColumn:Sc,ChartColumnBig:Bb,ChartColumnBigIcon:Bb,ChartColumnDecreasing:gB,ChartColumnDecreasingIcon:gB,ChartColumnIcon:Sc,ChartColumnIncreasing:$b,ChartColumnIncreasingIcon:$b,ChartColumnStacked:xB,ChartColumnStackedIcon:xB,ChartGantt:yB,ChartGanttIcon:yB,ChartLine:Ub,ChartLineIcon:Ub,ChartNetwork:vB,ChartNetworkIcon:vB,ChartNoAxesColumn:Vb,ChartNoAxesColumnDecreasing:_B,ChartNoAxesColumnDecreasingIcon:_B,ChartNoAxesColumnIcon:Vb,ChartNoAxesColumnIncreasing:qb,ChartNoAxesColumnIncreasingIcon:qb,ChartNoAxesCombined:bB,ChartNoAxesCombinedIcon:bB,ChartNoAxesGantt:Hb,ChartNoAxesGanttIcon:Hb,ChartPie:Wb,ChartPieIcon:Wb,ChartScatter:Gb,ChartScatterIcon:Gb,ChartSpline:wB,ChartSplineIcon:wB,Check:ma,CheckCheck:jB,CheckCheckIcon:jB,CheckCircle:yi,CheckCircle2:oi,CheckCircle2Icon:oi,CheckCircleIcon:yi,CheckIcon:ma,CheckSquare:Oy,CheckSquare2:P2,CheckSquare2Icon:P2,CheckSquareIcon:Oy,ChefHat:kB,ChefHatIcon:kB,Cherry:NB,CherryIcon:NB,ChevronDown:Gc,ChevronDownCircle:sw,ChevronDownCircleIcon:sw,ChevronDownIcon:Gc,ChevronDownSquare:L2,ChevronDownSquareIcon:L2,ChevronFirst:SB,ChevronFirstIcon:SB,ChevronLast:CB,ChevronLastIcon:CB,ChevronLeft:hc,ChevronLeftCircle:rw,ChevronLeftCircleIcon:rw,ChevronLeftIcon:hc,ChevronLeftSquare:D2,ChevronLeftSquareIcon:D2,ChevronRight:Ri,ChevronRightCircle:nw,ChevronRightCircleIcon:nw,ChevronRightIcon:Ri,ChevronRightSquare:O2,ChevronRightSquareIcon:O2,ChevronUp:kx,ChevronUpCircle:aw,ChevronUpCircleIcon:aw,ChevronUpIcon:kx,ChevronUpSquare:R2,ChevronUpSquareIcon:R2,ChevronsDown:TB,ChevronsDownIcon:TB,ChevronsDownUp:MB,ChevronsDownUpIcon:MB,ChevronsLeft:IB,ChevronsLeftIcon:IB,ChevronsLeftRight:EB,ChevronsLeftRightEllipsis:AB,ChevronsLeftRightEllipsisIcon:AB,ChevronsLeftRightIcon:EB,ChevronsRight:LB,ChevronsRightIcon:LB,ChevronsRightLeft:PB,ChevronsRightLeftIcon:PB,ChevronsUp:DB,ChevronsUpDown:mg,ChevronsUpDownIcon:mg,ChevronsUpIcon:DB,Chrome:OB,ChromeIcon:OB,Church:RB,ChurchIcon:RB,Cigarette:zB,CigaretteIcon:zB,CigaretteOff:FB,CigaretteOffIcon:FB,Circle:Td,CircleAlert:Qo,CircleAlertIcon:Qo,CircleArrowDown:Kb,CircleArrowDownIcon:Kb,CircleArrowLeft:Zb,CircleArrowLeftIcon:Zb,CircleArrowOutDownLeft:Yb,CircleArrowOutDownLeftIcon:Yb,CircleArrowOutDownRight:Xb,CircleArrowOutDownRightIcon:Xb,CircleArrowOutUpLeft:Qb,CircleArrowOutUpLeftIcon:Qb,CircleArrowOutUpRight:Jb,CircleArrowOutUpRightIcon:Jb,CircleArrowRight:ew,CircleArrowRightIcon:ew,CircleArrowUp:tw,CircleArrowUpIcon:tw,CircleCheck:oi,CircleCheckBig:yi,CircleCheckBigIcon:yi,CircleCheckIcon:oi,CircleChevronDown:sw,CircleChevronDownIcon:sw,CircleChevronLeft:rw,CircleChevronLeftIcon:rw,CircleChevronRight:nw,CircleChevronRightIcon:nw,CircleChevronUp:aw,CircleChevronUpIcon:aw,CircleDashed:BB,CircleDashedIcon:BB,CircleDivide:iw,CircleDivideIcon:iw,CircleDollarSign:$B,CircleDollarSignIcon:$B,CircleDot:qB,CircleDotDashed:UB,CircleDotDashedIcon:UB,CircleDotIcon:qB,CircleEllipsis:VB,CircleEllipsisIcon:VB,CircleEqual:HB,CircleEqualIcon:HB,CircleFadingArrowUp:WB,CircleFadingArrowUpIcon:WB,CircleFadingPlus:GB,CircleFadingPlusIcon:GB,CircleGauge:ow,CircleGaugeIcon:ow,CircleHelp:Dy,CircleHelpIcon:Dy,CircleIcon:Td,CircleMinus:lw,CircleMinusIcon:lw,CircleOff:KB,CircleOffIcon:KB,CircleParking:dw,CircleParkingIcon:dw,CircleParkingOff:cw,CircleParkingOffIcon:cw,CirclePause:uw,CirclePauseIcon:uw,CirclePercent:hw,CirclePercentIcon:hw,CirclePlay:Om,CirclePlayIcon:Om,CirclePlus:mw,CirclePlusIcon:mw,CirclePower:pw,CirclePowerIcon:pw,CircleSlash:ZB,CircleSlash2:fw,CircleSlash2Icon:fw,CircleSlashIcon:ZB,CircleSlashed:fw,CircleSlashedIcon:fw,CircleStop:gw,CircleStopIcon:gw,CircleUser:yw,CircleUserIcon:yw,CircleUserRound:xw,CircleUserRoundIcon:xw,CircleX:Cc,CircleXIcon:Cc,CircuitBoard:YB,CircuitBoardIcon:YB,Citrus:XB,CitrusIcon:XB,Clapperboard:QB,ClapperboardIcon:QB,Clipboard:a9,ClipboardCheck:M4,ClipboardCheckIcon:M4,ClipboardCopy:JB,ClipboardCopyIcon:JB,ClipboardEdit:_w,ClipboardEditIcon:_w,ClipboardIcon:a9,ClipboardList:jE,ClipboardListIcon:jE,ClipboardMinus:e9,ClipboardMinusIcon:e9,ClipboardPaste:t9,ClipboardPasteIcon:t9,ClipboardPen:_w,ClipboardPenIcon:_w,ClipboardPenLine:vw,ClipboardPenLineIcon:vw,ClipboardPlus:s9,ClipboardPlusIcon:s9,ClipboardSignature:vw,ClipboardSignatureIcon:vw,ClipboardType:r9,ClipboardTypeIcon:r9,ClipboardX:n9,ClipboardXIcon:n9,Clock:ca,Clock1:i9,Clock10:o9,Clock10Icon:o9,Clock11:l9,Clock11Icon:l9,Clock12:c9,Clock12Icon:c9,Clock1Icon:i9,Clock2:d9,Clock2Icon:d9,Clock3:u9,Clock3Icon:u9,Clock4:h9,Clock4Icon:h9,Clock5:m9,Clock5Icon:m9,Clock6:p9,Clock6Icon:p9,Clock7:f9,Clock7Icon:f9,Clock8:g9,Clock8Icon:g9,Clock9:x9,Clock9Icon:x9,ClockAlert:y9,ClockAlertIcon:y9,ClockArrowDown:v9,ClockArrowDownIcon:v9,ClockArrowUp:_9,ClockArrowUpIcon:_9,ClockIcon:ca,Cloud:D9,CloudAlert:b9,CloudAlertIcon:b9,CloudCog:w9,CloudCogIcon:w9,CloudDownload:bw,CloudDownloadIcon:bw,CloudDrizzle:j9,CloudDrizzleIcon:j9,CloudFog:k9,CloudFogIcon:k9,CloudHail:N9,CloudHailIcon:N9,CloudIcon:D9,CloudLightning:S9,CloudLightningIcon:S9,CloudMoon:M9,CloudMoonIcon:M9,CloudMoonRain:C9,CloudMoonRainIcon:C9,CloudOff:T9,CloudOffIcon:T9,CloudRain:E9,CloudRainIcon:E9,CloudRainWind:A9,CloudRainWindIcon:A9,CloudSnow:I9,CloudSnowIcon:I9,CloudSun:L9,CloudSunIcon:L9,CloudSunRain:P9,CloudSunRainIcon:P9,CloudUpload:ww,CloudUploadIcon:ww,Cloudy:O9,CloudyIcon:O9,Clover:qy,CloverIcon:qy,Club:R9,ClubIcon:R9,Code:vk,Code2:jw,Code2Icon:jw,CodeIcon:vk,CodeSquare:F2,CodeSquareIcon:F2,CodeXml:jw,CodeXmlIcon:jw,Codepen:F9,CodepenIcon:F9,Codesandbox:z9,CodesandboxIcon:z9,Coffee:_k,CoffeeIcon:_k,Cog:B9,CogIcon:B9,Coins:$9,CoinsIcon:$9,Columns:kw,Columns2:kw,Columns2Icon:kw,Columns3:Nw,Columns3Icon:Nw,Columns4:U9,Columns4Icon:U9,ColumnsIcon:kw,Combine:q9,CombineIcon:q9,Command:V9,CommandIcon:V9,Compass:H9,CompassIcon:H9,Component:W9,ComponentIcon:W9,Computer:G9,ComputerIcon:G9,ConciergeBell:K9,ConciergeBellIcon:K9,Cone:Z9,ConeIcon:Z9,Construction:Y9,ConstructionIcon:Y9,Contact:bk,Contact2:Sw,Contact2Icon:Sw,ContactIcon:bk,ContactRound:Sw,ContactRoundIcon:Sw,Container:X9,ContainerIcon:X9,Contrast:Q9,ContrastIcon:Q9,Cookie:J9,CookieIcon:J9,CookingPot:e$,CookingPotIcon:e$,Copy:Di,CopyCheck:t$,CopyCheckIcon:t$,CopyIcon:Di,CopyMinus:s$,CopyMinusIcon:s$,CopyPlus:r$,CopyPlusIcon:r$,CopySlash:n$,CopySlashIcon:n$,CopyX:a$,CopyXIcon:a$,Copyleft:i$,CopyleftIcon:i$,Copyright:o$,CopyrightIcon:o$,CornerDownLeft:l$,CornerDownLeftIcon:l$,CornerDownRight:c$,CornerDownRightIcon:c$,CornerLeftDown:d$,CornerLeftDownIcon:d$,CornerLeftUp:u$,CornerLeftUpIcon:u$,CornerRightDown:h$,CornerRightDownIcon:h$,CornerRightUp:m$,CornerRightUpIcon:m$,CornerUpLeft:p$,CornerUpLeftIcon:p$,CornerUpRight:f$,CornerUpRightIcon:f$,Cpu:g$,CpuIcon:g$,CreativeCommons:x$,CreativeCommonsIcon:x$,CreditCard:Zm,CreditCardIcon:Zm,Croissant:y$,CroissantIcon:y$,Crop:v$,CropIcon:v$,Cross:_$,CrossIcon:_$,Crosshair:b$,CrosshairIcon:b$,Crown:kh,CrownIcon:kh,Cuboid:w$,CuboidIcon:w$,CupSoda:j$,CupSodaIcon:j$,CurlyBraces:Lb,CurlyBracesIcon:Lb,Currency:k$,CurrencyIcon:k$,Cylinder:N$,CylinderIcon:N$,Dam:S$,DamIcon:S$,Database:T$,DatabaseBackup:C$,DatabaseBackupIcon:C$,DatabaseIcon:T$,DatabaseZap:M$,DatabaseZapIcon:M$,Delete:A$,DeleteIcon:A$,Dessert:E$,DessertIcon:E$,Diameter:I$,DiameterIcon:I$,Diamond:D$,DiamondIcon:D$,DiamondMinus:P$,DiamondMinusIcon:P$,DiamondPercent:Cw,DiamondPercentIcon:Cw,DiamondPlus:L$,DiamondPlusIcon:L$,Dice1:O$,Dice1Icon:O$,Dice2:R$,Dice2Icon:R$,Dice3:F$,Dice3Icon:F$,Dice4:z$,Dice4Icon:z$,Dice5:B$,Dice5Icon:B$,Dice6:$$,Dice6Icon:$$,Dices:U$,DicesIcon:U$,Diff:q$,DiffIcon:q$,Disc:G$,Disc2:V$,Disc2Icon:V$,Disc3:H$,Disc3Icon:H$,DiscAlbum:W$,DiscAlbumIcon:W$,DiscIcon:G$,Divide:K$,DivideCircle:iw,DivideCircleIcon:iw,DivideIcon:K$,DivideSquare:U2,DivideSquareIcon:U2,Dna:Y$,DnaIcon:Y$,DnaOff:Z$,DnaOffIcon:Z$,Dock:X$,DockIcon:X$,Dog:Q$,DogIcon:Q$,DollarSign:Ad,DollarSignIcon:Ad,Donut:J$,DonutIcon:J$,DoorClosed:eU,DoorClosedIcon:eU,DoorOpen:Xy,DoorOpenIcon:Xy,Dot:tU,DotIcon:tU,DotSquare:q2,DotSquareIcon:q2,Download:Vi,DownloadCloud:bw,DownloadCloudIcon:bw,DownloadIcon:Vi,DraftingCompass:sU,DraftingCompassIcon:sU,Drama:rU,DramaIcon:rU,Dribbble:nU,DribbbleIcon:nU,Drill:aU,DrillIcon:aU,Droplet:iU,DropletIcon:iU,Droplets:Nx,DropletsIcon:Nx,Drum:oU,DrumIcon:oU,Drumstick:lU,DrumstickIcon:lU,Dumbbell:cU,DumbbellIcon:cU,Ear:uU,EarIcon:uU,EarOff:dU,EarOffIcon:dU,Earth:Mw,EarthIcon:Mw,EarthLock:hU,EarthLockIcon:hU,Eclipse:mU,EclipseIcon:mU,Edit:_c,Edit2:Iv,Edit2Icon:Iv,Edit3:Ev,Edit3Icon:Ev,EditIcon:_c,Egg:T4,EggFried:pU,EggFriedIcon:pU,EggIcon:T4,EggOff:fU,EggOffIcon:fU,Ellipsis:Rp,EllipsisIcon:Rp,EllipsisVertical:hx,EllipsisVerticalIcon:hx,Equal:yU,EqualApproximately:gU,EqualApproximatelyIcon:gU,EqualIcon:yU,EqualNot:xU,EqualNotIcon:xU,EqualSquare:V2,EqualSquareIcon:V2,Eraser:vU,EraserIcon:vU,EthernetPort:_U,EthernetPortIcon:_U,Euro:bU,EuroIcon:bU,Expand:wU,ExpandIcon:wU,ExternalLink:bn,ExternalLinkIcon:bn,Eye:wi,EyeClosed:jU,EyeClosedIcon:jU,EyeIcon:wi,EyeOff:Wp,EyeOffIcon:Wp,Facebook:Qd,FacebookIcon:Qd,Factory:kU,FactoryIcon:kU,Fan:NU,FanIcon:NU,FastForward:SU,FastForwardIcon:SU,Feather:CU,FeatherIcon:CU,Fence:MU,FenceIcon:MU,FerrisWheel:TU,FerrisWheelIcon:TU,Figma:AU,FigmaIcon:AU,File:A4,FileArchive:EU,FileArchiveIcon:EU,FileAudio:PU,FileAudio2:IU,FileAudio2Icon:IU,FileAudioIcon:PU,FileAxis3D:Tw,FileAxis3DIcon:Tw,FileAxis3d:Tw,FileAxis3dIcon:Tw,FileBadge:DU,FileBadge2:LU,FileBadge2Icon:LU,FileBadgeIcon:DU,FileBarChart:Aw,FileBarChart2:Ew,FileBarChart2Icon:Ew,FileBarChartIcon:Aw,FileBox:OU,FileBoxIcon:OU,FileChartColumn:Ew,FileChartColumnIcon:Ew,FileChartColumnIncreasing:Aw,FileChartColumnIncreasingIcon:Aw,FileChartLine:Iw,FileChartLineIcon:Iw,FileChartPie:Pw,FileChartPieIcon:Pw,FileCheck:FU,FileCheck2:RU,FileCheck2Icon:RU,FileCheckIcon:FU,FileClock:zU,FileClockIcon:zU,FileCode:$U,FileCode2:BU,FileCode2Icon:BU,FileCodeIcon:$U,FileCog:Lw,FileCog2:Lw,FileCog2Icon:Lw,FileCogIcon:Lw,FileDiff:UU,FileDiffIcon:UU,FileDigit:qU,FileDigitIcon:qU,FileDown:VU,FileDownIcon:VU,FileEdit:Ow,FileEditIcon:Ow,FileHeart:HU,FileHeartIcon:HU,FileIcon:A4,FileImage:S1,FileImageIcon:S1,FileInput:WU,FileInputIcon:WU,FileJson:KU,FileJson2:GU,FileJson2Icon:GU,FileJsonIcon:KU,FileKey:YU,FileKey2:ZU,FileKey2Icon:ZU,FileKeyIcon:YU,FileLineChart:Iw,FileLineChartIcon:Iw,FileLock:QU,FileLock2:XU,FileLock2Icon:XU,FileLockIcon:QU,FileMinus:eq,FileMinus2:JU,FileMinus2Icon:JU,FileMinusIcon:eq,FileMusic:tq,FileMusicIcon:tq,FileOutput:sq,FileOutputIcon:sq,FilePen:Ow,FilePenIcon:Ow,FilePenLine:Dw,FilePenLineIcon:Dw,FilePieChart:Pw,FilePieChartIcon:Pw,FilePlus:nq,FilePlus2:rq,FilePlus2Icon:rq,FilePlusIcon:nq,FileQuestion:aq,FileQuestionIcon:aq,FileScan:iq,FileScanIcon:iq,FileSearch:lq,FileSearch2:oq,FileSearch2Icon:oq,FileSearchIcon:lq,FileSignature:Dw,FileSignatureIcon:Dw,FileSliders:cq,FileSlidersIcon:cq,FileSpreadsheet:Qy,FileSpreadsheetIcon:Qy,FileStack:kE,FileStackIcon:kE,FileSymlink:dq,FileSymlinkIcon:dq,FileTerminal:uq,FileTerminalIcon:uq,FileText:Yn,FileTextIcon:Yn,FileType:mq,FileType2:hq,FileType2Icon:hq,FileTypeIcon:mq,FileUp:pq,FileUpIcon:pq,FileUser:fq,FileUserIcon:fq,FileVideo:xq,FileVideo2:gq,FileVideo2Icon:gq,FileVideoIcon:xq,FileVolume:vq,FileVolume2:yq,FileVolume2Icon:yq,FileVolumeIcon:vq,FileWarning:_q,FileWarningIcon:_q,FileX:wq,FileX2:bq,FileX2Icon:bq,FileXIcon:wq,Files:jq,FilesIcon:jq,Film:Wd,FilmIcon:Wd,Filter:Jy,FilterIcon:Jy,FilterX:kq,FilterXIcon:kq,Fingerprint:Nq,FingerprintIcon:Nq,FireExtinguisher:Sq,FireExtinguisherIcon:Sq,Fish:Tq,FishIcon:Tq,FishOff:Cq,FishOffIcon:Cq,FishSymbol:Mq,FishSymbolIcon:Mq,Flag:e0,FlagIcon:e0,FlagOff:Aq,FlagOffIcon:Aq,FlagTriangleLeft:Eq,FlagTriangleLeftIcon:Eq,FlagTriangleRight:Iq,FlagTriangleRightIcon:Iq,Flame:Ym,FlameIcon:Ym,FlameKindling:Pq,FlameKindlingIcon:Pq,Flashlight:Dq,FlashlightIcon:Dq,FlashlightOff:Lq,FlashlightOffIcon:Lq,FlaskConical:wk,FlaskConicalIcon:wk,FlaskConicalOff:Oq,FlaskConicalOffIcon:Oq,FlaskRound:Rq,FlaskRoundIcon:Rq,FlipHorizontal:zq,FlipHorizontal2:Fq,FlipHorizontal2Icon:Fq,FlipHorizontalIcon:zq,FlipVertical:$q,FlipVertical2:Bq,FlipVertical2Icon:Bq,FlipVerticalIcon:$q,Flower:Uq,Flower2:ng,Flower2Icon:ng,FlowerIcon:Uq,Focus:qq,FocusIcon:qq,FoldHorizontal:Vq,FoldHorizontalIcon:Vq,FoldVertical:Hq,FoldVerticalIcon:Hq,Folder:yV,FolderArchive:Wq,FolderArchiveIcon:Wq,FolderCheck:Gq,FolderCheckIcon:Gq,FolderClock:Kq,FolderClockIcon:Kq,FolderClosed:Zq,FolderClosedIcon:Zq,FolderCode:Yq,FolderCodeIcon:Yq,FolderCog:Rw,FolderCog2:Rw,FolderCog2Icon:Rw,FolderCogIcon:Rw,FolderDot:Xq,FolderDotIcon:Xq,FolderDown:Qq,FolderDownIcon:Qq,FolderEdit:Fw,FolderEditIcon:Fw,FolderGit:eV,FolderGit2:Jq,FolderGit2Icon:Jq,FolderGitIcon:eV,FolderHeart:tV,FolderHeartIcon:tV,FolderIcon:yV,FolderInput:sV,FolderInputIcon:sV,FolderKanban:rV,FolderKanbanIcon:rV,FolderKey:nV,FolderKeyIcon:nV,FolderLock:aV,FolderLockIcon:aV,FolderMinus:iV,FolderMinusIcon:iV,FolderOpen:om,FolderOpenDot:oV,FolderOpenDotIcon:oV,FolderOpenIcon:om,FolderOutput:lV,FolderOutputIcon:lV,FolderPen:Fw,FolderPenIcon:Fw,FolderPlus:cV,FolderPlusIcon:cV,FolderRoot:dV,FolderRootIcon:dV,FolderSearch:hV,FolderSearch2:uV,FolderSearch2Icon:uV,FolderSearchIcon:hV,FolderSymlink:mV,FolderSymlinkIcon:mV,FolderSync:pV,FolderSyncIcon:pV,FolderTree:fV,FolderTreeIcon:fV,FolderUp:gV,FolderUpIcon:gV,FolderX:xV,FolderXIcon:xV,Folders:vV,FoldersIcon:vV,Footprints:_V,FootprintsIcon:_V,ForkKnife:Tj,ForkKnifeCrossed:Mj,ForkKnifeCrossedIcon:Mj,ForkKnifeIcon:Tj,Forklift:bV,ForkliftIcon:bV,FormInput:d2,FormInputIcon:d2,Forward:wV,ForwardIcon:wV,Frame:jV,FrameIcon:jV,Framer:kV,FramerIcon:kV,Frown:NV,FrownIcon:NV,Fuel:SV,FuelIcon:SV,Fullscreen:CV,FullscreenIcon:CV,FunctionSquare:H2,FunctionSquareIcon:H2,GalleryHorizontal:TV,GalleryHorizontalEnd:MV,GalleryHorizontalEndIcon:MV,GalleryHorizontalIcon:TV,GalleryThumbnails:AV,GalleryThumbnailsIcon:AV,GalleryVertical:IV,GalleryVerticalEnd:EV,GalleryVerticalEndIcon:EV,GalleryVerticalIcon:IV,Gamepad:LV,Gamepad2:PV,Gamepad2Icon:PV,GamepadIcon:LV,GanttChart:Hb,GanttChartIcon:Hb,GanttChartSquare:sx,GanttChartSquareIcon:sx,Gauge:DV,GaugeCircle:ow,GaugeCircleIcon:ow,GaugeIcon:DV,Gavel:OV,GavelIcon:OV,Gem:RV,GemIcon:RV,Ghost:jk,GhostIcon:jk,Gift:oo,GiftIcon:oo,GitBranch:zV,GitBranchIcon:zV,GitBranchPlus:FV,GitBranchPlusIcon:FV,GitCommit:zw,GitCommitHorizontal:zw,GitCommitHorizontalIcon:zw,GitCommitIcon:zw,GitCommitVertical:BV,GitCommitVerticalIcon:BV,GitCompare:UV,GitCompareArrows:$V,GitCompareArrowsIcon:$V,GitCompareIcon:UV,GitFork:qV,GitForkIcon:qV,GitGraph:VV,GitGraphIcon:VV,GitMerge:HV,GitMergeIcon:HV,GitPullRequest:XV,GitPullRequestArrow:WV,GitPullRequestArrowIcon:WV,GitPullRequestClosed:GV,GitPullRequestClosedIcon:GV,GitPullRequestCreate:ZV,GitPullRequestCreateArrow:KV,GitPullRequestCreateArrowIcon:KV,GitPullRequestCreateIcon:ZV,GitPullRequestDraft:YV,GitPullRequestDraftIcon:YV,GitPullRequestIcon:XV,Github:QV,GithubIcon:QV,Gitlab:JV,GitlabIcon:JV,GlassWater:eH,GlassWaterIcon:eH,Glasses:tH,GlassesIcon:tH,Globe:pg,Globe2:Mw,Globe2Icon:Mw,GlobeIcon:pg,GlobeLock:sH,GlobeLockIcon:sH,Goal:rH,GoalIcon:rH,Grab:nH,GrabIcon:nH,GraduationCap:C1,GraduationCapIcon:C1,Grape:aH,GrapeIcon:aH,Grid:Im,Grid2X2:$w,Grid2X2Icon:$w,Grid2X2Plus:Bw,Grid2X2PlusIcon:Bw,Grid2x2:$w,Grid2x2Check:iH,Grid2x2CheckIcon:iH,Grid2x2Icon:$w,Grid2x2Plus:Bw,Grid2x2PlusIcon:Bw,Grid2x2X:oH,Grid2x2XIcon:oH,Grid3X3:Im,Grid3X3Icon:Im,Grid3x3:Im,Grid3x3Icon:Im,GridIcon:Im,Grip:cH,GripHorizontal:lH,GripHorizontalIcon:lH,GripIcon:cH,GripVertical:lm,GripVerticalIcon:lm,Group:dH,GroupIcon:dH,Guitar:uH,GuitarIcon:uH,Ham:hH,HamIcon:hH,Hammer:mH,HammerIcon:mH,Hand:NE,HandCoins:pH,HandCoinsIcon:pH,HandHeart:fH,HandHeartIcon:fH,HandHelping:Uw,HandHelpingIcon:Uw,HandIcon:NE,HandMetal:gH,HandMetalIcon:gH,HandPlatter:xH,HandPlatterIcon:xH,Handshake:yH,HandshakeIcon:yH,HardDrive:SE,HardDriveDownload:vH,HardDriveDownloadIcon:vH,HardDriveIcon:SE,HardDriveUpload:_H,HardDriveUploadIcon:_H,HardHat:bH,HardHatIcon:bH,Hash:E4,HashIcon:E4,Haze:wH,HazeIcon:wH,HdmiPort:jH,HdmiPortIcon:jH,Heading:MH,Heading1:CE,Heading1Icon:CE,Heading2:ME,Heading2Icon:ME,Heading3:kH,Heading3Icon:kH,Heading4:NH,Heading4Icon:NH,Heading5:SH,Heading5Icon:SH,Heading6:CH,Heading6Icon:CH,HeadingIcon:MH,HeadphoneOff:TH,HeadphoneOffIcon:TH,Headphones:AH,HeadphonesIcon:AH,Headset:EH,HeadsetIcon:EH,Heart:Ti,HeartCrack:IH,HeartCrackIcon:IH,HeartHandshake:PH,HeartHandshakeIcon:PH,HeartIcon:Ti,HeartOff:LH,HeartOffIcon:LH,HeartPulse:DH,HeartPulseIcon:DH,Heater:OH,HeaterIcon:OH,HelpCircle:Dy,HelpCircleIcon:Dy,HelpingHand:Uw,HelpingHandIcon:Uw,Hexagon:RH,HexagonIcon:RH,Highlighter:FH,HighlighterIcon:FH,History:I4,HistoryIcon:I4,Home:Zn,HomeIcon:Zn,Hop:BH,HopIcon:BH,HopOff:zH,HopOffIcon:zH,Hospital:$H,HospitalIcon:$H,Hotel:UH,HotelIcon:UH,Hourglass:qH,HourglassIcon:qH,House:Zn,HouseIcon:Zn,HousePlug:VH,HousePlugIcon:VH,HousePlus:HH,HousePlusIcon:HH,IceCream:Vw,IceCream2:qw,IceCream2Icon:qw,IceCreamBowl:qw,IceCreamBowlIcon:qw,IceCreamCone:Vw,IceCreamConeIcon:Vw,IceCreamIcon:Vw,Icon:MOe,IdCard:WH,IdCardIcon:WH,Image:fl,ImageDown:GH,ImageDownIcon:GH,ImageIcon:fl,ImageMinus:KH,ImageMinusIcon:KH,ImageOff:ZH,ImageOffIcon:ZH,ImagePlay:YH,ImagePlayIcon:YH,ImagePlus:M1,ImagePlusIcon:M1,ImageUp:XH,ImageUpIcon:XH,ImageUpscale:QH,ImageUpscaleIcon:QH,Images:JH,ImagesIcon:JH,Import:eW,ImportIcon:eW,Inbox:tW,InboxIcon:tW,Indent:Ww,IndentDecrease:Hw,IndentDecreaseIcon:Hw,IndentIcon:Ww,IndentIncrease:Ww,IndentIncreaseIcon:Ww,IndianRupee:sW,IndianRupeeIcon:sW,Infinity:rW,InfinityIcon:rW,Info:nW,InfoIcon:nW,Inspect:X2,InspectIcon:X2,InspectionPanel:aW,InspectionPanelIcon:aW,Instagram:vu,InstagramIcon:vu,Italic:P4,ItalicIcon:P4,IterationCcw:iW,IterationCcwIcon:iW,IterationCw:oW,IterationCwIcon:oW,JapaneseYen:lW,JapaneseYenIcon:lW,Joystick:cW,JoystickIcon:cW,Kanban:Sx,KanbanIcon:Sx,KanbanSquare:W2,KanbanSquareDashed:z2,KanbanSquareDashedIcon:z2,KanbanSquareIcon:W2,Key:Xm,KeyIcon:Xm,KeyRound:kk,KeyRoundIcon:kk,KeySquare:dW,KeySquareIcon:dW,Keyboard:mW,KeyboardIcon:mW,KeyboardMusic:uW,KeyboardMusicIcon:uW,KeyboardOff:hW,KeyboardOffIcon:hW,Lamp:vW,LampCeiling:pW,LampCeilingIcon:pW,LampDesk:fW,LampDeskIcon:fW,LampFloor:gW,LampFloorIcon:gW,LampIcon:vW,LampWallDown:xW,LampWallDownIcon:xW,LampWallUp:yW,LampWallUpIcon:yW,LandPlot:_W,LandPlotIcon:_W,Landmark:bW,LandmarkIcon:bW,Languages:wW,LanguagesIcon:wW,Laptop:kW,Laptop2:Gw,Laptop2Icon:Gw,LaptopIcon:kW,LaptopMinimal:Gw,LaptopMinimalCheck:jW,LaptopMinimalCheckIcon:jW,LaptopMinimalIcon:Gw,Lasso:SW,LassoIcon:SW,LassoSelect:NW,LassoSelectIcon:NW,Laugh:CW,LaughIcon:CW,Layers:AW,Layers2:MW,Layers2Icon:MW,Layers3:TW,Layers3Icon:TW,LayersIcon:AW,Layout:Av,LayoutDashboard:Nk,LayoutDashboardIcon:Nk,LayoutGrid:Qm,LayoutGridIcon:Qm,LayoutIcon:Av,LayoutList:EW,LayoutListIcon:EW,LayoutPanelLeft:IW,LayoutPanelLeftIcon:IW,LayoutPanelTop:PW,LayoutPanelTopIcon:PW,LayoutTemplate:Sk,LayoutTemplateIcon:Sk,Leaf:LW,LeafIcon:LW,LeafyGreen:DW,LeafyGreenIcon:DW,Lectern:OW,LecternIcon:OW,LetterText:RW,LetterTextIcon:RW,Library:L4,LibraryBig:FW,LibraryBigIcon:FW,LibraryIcon:L4,LibrarySquare:G2,LibrarySquareIcon:G2,LifeBuoy:D4,LifeBuoyIcon:D4,Ligature:zW,LigatureIcon:zW,Lightbulb:t0,LightbulbIcon:t0,LightbulbOff:BW,LightbulbOffIcon:BW,LineChart:Ub,LineChartIcon:Ub,Link:Ro,Link2:Jm,Link2Icon:Jm,Link2Off:$W,Link2OffIcon:$W,LinkIcon:Ro,Linkedin:cm,LinkedinIcon:cm,List:dm,ListCheck:UW,ListCheckIcon:UW,ListChecks:qW,ListChecksIcon:qW,ListCollapse:VW,ListCollapseIcon:VW,ListEnd:HW,ListEndIcon:HW,ListFilter:WW,ListFilterIcon:WW,ListIcon:dm,ListMinus:GW,ListMinusIcon:GW,ListMusic:KW,ListMusicIcon:KW,ListOrdered:O4,ListOrderedIcon:O4,ListPlus:ZW,ListPlusIcon:ZW,ListRestart:YW,ListRestartIcon:YW,ListStart:XW,ListStartIcon:XW,ListTodo:QW,ListTodoIcon:QW,ListTree:JW,ListTreeIcon:JW,ListVideo:eG,ListVideoIcon:eG,ListX:tG,ListXIcon:tG,Loader:rG,Loader2:Us,Loader2Icon:Us,LoaderCircle:Us,LoaderCircleIcon:Us,LoaderIcon:rG,LoaderPinwheel:sG,LoaderPinwheelIcon:sG,Locate:TE,LocateFixed:nG,LocateFixedIcon:nG,LocateIcon:TE,LocateOff:aG,LocateOffIcon:aG,Lock:zu,LockIcon:zu,LockKeyhole:iG,LockKeyholeIcon:iG,LockKeyholeOpen:Kw,LockKeyholeOpenIcon:Kw,LockOpen:Zw,LockOpenIcon:Zw,LogIn:R4,LogInIcon:R4,LogOut:F4,LogOutIcon:F4,Logs:oG,LogsIcon:oG,Lollipop:lG,LollipopIcon:lG,LucideAArrowDown:Q8,LucideAArrowUp:J8,LucideALargeSmall:eR,LucideAccessibility:tR,LucideActivity:wx,LucideActivitySquare:y2,LucideAirVent:sR,LucideAirplay:rR,LucideAlarmCheck:_b,LucideAlarmClock:aR,LucideAlarmClockCheck:_b,LucideAlarmClockMinus:bb,LucideAlarmClockOff:nR,LucideAlarmClockPlus:wb,LucideAlarmMinus:bb,LucideAlarmPlus:wb,LucideAlarmSmoke:iR,LucideAlbum:oR,LucideAlertCircle:Qo,LucideAlertOctagon:Qw,LucideAlertTriangle:Lu,LucideAlignCenter:w4,LucideAlignCenterHorizontal:lR,LucideAlignCenterVertical:cR,LucideAlignEndHorizontal:dR,LucideAlignEndVertical:uR,LucideAlignHorizontalDistributeCenter:hR,LucideAlignHorizontalDistributeEnd:mR,LucideAlignHorizontalDistributeStart:pR,LucideAlignHorizontalJustifyCenter:fR,LucideAlignHorizontalJustifyEnd:gR,LucideAlignHorizontalJustifyStart:xR,LucideAlignHorizontalSpaceAround:yR,LucideAlignHorizontalSpaceBetween:vR,LucideAlignJustify:_R,LucideAlignLeft:j4,LucideAlignRight:k4,LucideAlignStartHorizontal:bR,LucideAlignStartVertical:wR,LucideAlignVerticalDistributeCenter:jR,LucideAlignVerticalDistributeEnd:kR,LucideAlignVerticalDistributeStart:NR,LucideAlignVerticalJustifyCenter:SR,LucideAlignVerticalJustifyEnd:CR,LucideAlignVerticalJustifyStart:MR,LucideAlignVerticalSpaceAround:TR,LucideAlignVerticalSpaceBetween:AR,LucideAmbulance:ER,LucideAmpersand:IR,LucideAmpersands:PR,LucideAmphora:LR,LucideAnchor:DR,LucideAngry:OR,LucideAnnoyed:RR,LucideAntenna:FR,LucideAnvil:zR,LucideAperture:BR,LucideAppWindow:yE,LucideAppWindowMac:$R,LucideApple:UR,LucideArchive:N4,LucideArchiveRestore:vE,LucideArchiveX:qR,LucideAreaChart:Ob,LucideArmchair:VR,LucideArrowBigDown:WR,LucideArrowBigDownDash:HR,LucideArrowBigLeft:KR,LucideArrowBigLeftDash:GR,LucideArrowBigRight:YR,LucideArrowBigRightDash:ZR,LucideArrowBigUp:QR,LucideArrowBigUpDash:XR,LucideArrowDown:jx,LucideArrowDown01:JR,LucideArrowDown10:eF,LucideArrowDownAZ:jb,LucideArrowDownAz:jb,LucideArrowDownCircle:Kb,LucideArrowDownFromLine:tF,LucideArrowDownLeft:sF,LucideArrowDownLeftFromCircle:Yb,LucideArrowDownLeftFromSquare:j2,LucideArrowDownLeftSquare:v2,LucideArrowDownNarrowWide:rF,LucideArrowDownRight:nF,LucideArrowDownRightFromCircle:Xb,LucideArrowDownRightFromSquare:k2,LucideArrowDownRightSquare:_2,LucideArrowDownSquare:b2,LucideArrowDownToDot:aF,LucideArrowDownToLine:iF,LucideArrowDownUp:oF,LucideArrowDownWideNarrow:kb,LucideArrowDownZA:Nb,LucideArrowDownZa:Nb,LucideArrowLeft:bi,LucideArrowLeftCircle:Zb,LucideArrowLeftFromLine:lF,LucideArrowLeftRight:cF,LucideArrowLeftSquare:w2,LucideArrowLeftToLine:dF,LucideArrowRight:qi,LucideArrowRightCircle:ew,LucideArrowRightFromLine:uF,LucideArrowRightLeft:Zy,LucideArrowRightSquare:C2,LucideArrowRightToLine:hF,LucideArrowUp:Wm,LucideArrowUp01:mF,LucideArrowUp10:pF,LucideArrowUpAZ:Sb,LucideArrowUpAz:Sb,LucideArrowUpCircle:tw,LucideArrowUpDown:Hp,LucideArrowUpFromDot:fF,LucideArrowUpFromLine:gF,LucideArrowUpLeft:xF,LucideArrowUpLeftFromCircle:Qb,LucideArrowUpLeftFromSquare:N2,LucideArrowUpLeftSquare:M2,LucideArrowUpNarrowWide:Cb,LucideArrowUpRight:yF,LucideArrowUpRightFromCircle:Jb,LucideArrowUpRightFromSquare:S2,LucideArrowUpRightSquare:T2,LucideArrowUpSquare:A2,LucideArrowUpToLine:vF,LucideArrowUpWideNarrow:_F,LucideArrowUpZA:Mb,LucideArrowUpZa:Mb,LucideArrowsUpFromLine:bF,LucideAsterisk:wF,LucideAsteriskSquare:E2,LucideAtSign:jF,LucideAtom:kF,LucideAudioLines:NF,LucideAudioWaveform:SF,LucideAward:nc,LucideAxe:CF,LucideAxis3D:Tb,LucideAxis3d:Tb,LucideBaby:MF,LucideBackpack:TF,LucideBadge:HF,LucideBadgeAlert:AF,LucideBadgeCent:EF,LucideBadgeCheck:Ab,LucideBadgeDollarSign:IF,LucideBadgeEuro:PF,LucideBadgeHelp:LF,LucideBadgeIndianRupee:DF,LucideBadgeInfo:OF,LucideBadgeJapaneseYen:RF,LucideBadgeMinus:FF,LucideBadgePercent:zF,LucideBadgePlus:BF,LucideBadgePoundSterling:$F,LucideBadgeRussianRuble:UF,LucideBadgeSwissFranc:qF,LucideBadgeX:VF,LucideBaggageClaim:WF,LucideBan:GF,LucideBanana:KF,LucideBandage:ZF,LucideBanknote:YF,LucideBarChart:qb,LucideBarChart2:Vb,LucideBarChart3:Sc,LucideBarChart4:$b,LucideBarChartBig:Bb,LucideBarChartHorizontal:Fb,LucideBarChartHorizontalBig:Rb,LucideBarcode:XF,LucideBaseline:QF,LucideBath:j1,LucideBattery:nz,LucideBatteryCharging:JF,LucideBatteryFull:ez,LucideBatteryLow:tz,LucideBatteryMedium:sz,LucideBatteryWarning:rz,LucideBeaker:az,LucideBean:oz,LucideBeanOff:iz,LucideBed:k1,LucideBedDouble:lz,LucideBedSingle:cz,LucideBeef:dz,LucideBeer:hz,LucideBeerOff:uz,LucideBell:dg,LucideBellDot:mz,LucideBellElectric:pz,LucideBellMinus:fz,LucideBellOff:xk,LucideBellPlus:gz,LucideBellRing:xz,LucideBetweenHorizonalEnd:Eb,LucideBetweenHorizonalStart:Ib,LucideBetweenHorizontalEnd:Eb,LucideBetweenHorizontalStart:Ib,LucideBetweenVerticalEnd:yz,LucideBetweenVerticalStart:vz,LucideBicepsFlexed:_z,LucideBike:bz,LucideBinary:wz,LucideBinoculars:jz,LucideBiohazard:kz,LucideBird:Nz,LucideBitcoin:Sz,LucideBlend:Cz,LucideBlinds:Mz,LucideBlocks:Tz,LucideBluetooth:Pz,LucideBluetoothConnected:Az,LucideBluetoothOff:Ez,LucideBluetoothSearching:Iz,LucideBold:S4,LucideBolt:Lz,LucideBomb:Dz,LucideBone:Oz,LucideBook:n7,LucideBookA:Rz,LucideBookAudio:Fz,LucideBookCheck:zz,LucideBookCopy:Bz,LucideBookDashed:Pb,LucideBookDown:$z,LucideBookHeadphones:Uz,LucideBookHeart:qz,LucideBookImage:Vz,LucideBookKey:Hz,LucideBookLock:Wz,LucideBookMarked:Gz,LucideBookMinus:Kz,LucideBookOpen:Yy,LucideBookOpenCheck:Zz,LucideBookOpenText:Yz,LucideBookPlus:Xz,LucideBookTemplate:Pb,LucideBookText:Qz,LucideBookType:Jz,LucideBookUp:t7,LucideBookUp2:e7,LucideBookUser:s7,LucideBookX:r7,LucideBookmark:ug,LucideBookmarkCheck:a7,LucideBookmarkMinus:i7,LucideBookmarkPlus:_E,LucideBookmarkX:o7,LucideBoomBox:l7,LucideBot:C4,LucideBotMessageSquare:c7,LucideBotOff:d7,LucideBox:u7,LucideBoxSelect:$2,LucideBoxes:h7,LucideBraces:Lb,LucideBrackets:m7,LucideBrain:bE,LucideBrainCircuit:p7,LucideBrainCog:f7,LucideBrickWall:g7,LucideBriefcase:Fu,LucideBriefcaseBusiness:x7,LucideBriefcaseConveyorBelt:y7,LucideBriefcaseMedical:v7,LucideBringToFront:_7,LucideBrush:b7,LucideBug:k7,LucideBugOff:w7,LucideBugPlay:j7,LucideBuilding:yk,LucideBuilding2:Ya,LucideBus:S7,LucideBusFront:N7,LucideCable:M7,LucideCableCar:C7,LucideCake:Gm,LucideCakeSlice:T7,LucideCalculator:A7,LucideCalendar:xn,LucideCalendar1:E7,LucideCalendarArrowDown:I7,LucideCalendarArrowUp:P7,LucideCalendarCheck:D7,LucideCalendarCheck2:L7,LucideCalendarClock:wE,LucideCalendarCog:O7,LucideCalendarDays:Km,LucideCalendarFold:R7,LucideCalendarHeart:F7,LucideCalendarMinus:B7,LucideCalendarMinus2:z7,LucideCalendarOff:$7,LucideCalendarPlus:N1,LucideCalendarPlus2:U7,LucideCalendarRange:q7,LucideCalendarSearch:V7,LucideCalendarSync:H7,LucideCalendarX:G7,LucideCalendarX2:W7,LucideCamera:hg,LucideCameraOff:K7,LucideCandlestickChart:zb,LucideCandy:X7,LucideCandyCane:Z7,LucideCandyOff:Y7,LucideCannabis:Q7,LucideCaptions:Db,LucideCaptionsOff:J7,LucideCar:sB,LucideCarFront:eB,LucideCarTaxiFront:tB,LucideCaravan:rB,LucideCarrot:nB,LucideCaseLower:aB,LucideCaseSensitive:iB,LucideCaseUpper:oB,LucideCassetteTape:lB,LucideCast:cB,LucideCastle:dB,LucideCat:uB,LucideCctv:hB,LucideChartArea:Ob,LucideChartBar:Fb,LucideChartBarBig:Rb,LucideChartBarDecreasing:mB,LucideChartBarIncreasing:pB,LucideChartBarStacked:fB,LucideChartCandlestick:zb,LucideChartColumn:Sc,LucideChartColumnBig:Bb,LucideChartColumnDecreasing:gB,LucideChartColumnIncreasing:$b,LucideChartColumnStacked:xB,LucideChartGantt:yB,LucideChartLine:Ub,LucideChartNetwork:vB,LucideChartNoAxesColumn:Vb,LucideChartNoAxesColumnDecreasing:_B,LucideChartNoAxesColumnIncreasing:qb,LucideChartNoAxesCombined:bB,LucideChartNoAxesGantt:Hb,LucideChartPie:Wb,LucideChartScatter:Gb,LucideChartSpline:wB,LucideCheck:ma,LucideCheckCheck:jB,LucideCheckCircle:yi,LucideCheckCircle2:oi,LucideCheckSquare:Oy,LucideCheckSquare2:P2,LucideChefHat:kB,LucideCherry:NB,LucideChevronDown:Gc,LucideChevronDownCircle:sw,LucideChevronDownSquare:L2,LucideChevronFirst:SB,LucideChevronLast:CB,LucideChevronLeft:hc,LucideChevronLeftCircle:rw,LucideChevronLeftSquare:D2,LucideChevronRight:Ri,LucideChevronRightCircle:nw,LucideChevronRightSquare:O2,LucideChevronUp:kx,LucideChevronUpCircle:aw,LucideChevronUpSquare:R2,LucideChevronsDown:TB,LucideChevronsDownUp:MB,LucideChevronsLeft:IB,LucideChevronsLeftRight:EB,LucideChevronsLeftRightEllipsis:AB,LucideChevronsRight:LB,LucideChevronsRightLeft:PB,LucideChevronsUp:DB,LucideChevronsUpDown:mg,LucideChrome:OB,LucideChurch:RB,LucideCigarette:zB,LucideCigaretteOff:FB,LucideCircle:Td,LucideCircleAlert:Qo,LucideCircleArrowDown:Kb,LucideCircleArrowLeft:Zb,LucideCircleArrowOutDownLeft:Yb,LucideCircleArrowOutDownRight:Xb,LucideCircleArrowOutUpLeft:Qb,LucideCircleArrowOutUpRight:Jb,LucideCircleArrowRight:ew,LucideCircleArrowUp:tw,LucideCircleCheck:oi,LucideCircleCheckBig:yi,LucideCircleChevronDown:sw,LucideCircleChevronLeft:rw,LucideCircleChevronRight:nw,LucideCircleChevronUp:aw,LucideCircleDashed:BB,LucideCircleDivide:iw,LucideCircleDollarSign:$B,LucideCircleDot:qB,LucideCircleDotDashed:UB,LucideCircleEllipsis:VB,LucideCircleEqual:HB,LucideCircleFadingArrowUp:WB,LucideCircleFadingPlus:GB,LucideCircleGauge:ow,LucideCircleHelp:Dy,LucideCircleMinus:lw,LucideCircleOff:KB,LucideCircleParking:dw,LucideCircleParkingOff:cw,LucideCirclePause:uw,LucideCirclePercent:hw,LucideCirclePlay:Om,LucideCirclePlus:mw,LucideCirclePower:pw,LucideCircleSlash:ZB,LucideCircleSlash2:fw,LucideCircleSlashed:fw,LucideCircleStop:gw,LucideCircleUser:yw,LucideCircleUserRound:xw,LucideCircleX:Cc,LucideCircuitBoard:YB,LucideCitrus:XB,LucideClapperboard:QB,LucideClipboard:a9,LucideClipboardCheck:M4,LucideClipboardCopy:JB,LucideClipboardEdit:_w,LucideClipboardList:jE,LucideClipboardMinus:e9,LucideClipboardPaste:t9,LucideClipboardPen:_w,LucideClipboardPenLine:vw,LucideClipboardPlus:s9,LucideClipboardSignature:vw,LucideClipboardType:r9,LucideClipboardX:n9,LucideClock:ca,LucideClock1:i9,LucideClock10:o9,LucideClock11:l9,LucideClock12:c9,LucideClock2:d9,LucideClock3:u9,LucideClock4:h9,LucideClock5:m9,LucideClock6:p9,LucideClock7:f9,LucideClock8:g9,LucideClock9:x9,LucideClockAlert:y9,LucideClockArrowDown:v9,LucideClockArrowUp:_9,LucideCloud:D9,LucideCloudAlert:b9,LucideCloudCog:w9,LucideCloudDownload:bw,LucideCloudDrizzle:j9,LucideCloudFog:k9,LucideCloudHail:N9,LucideCloudLightning:S9,LucideCloudMoon:M9,LucideCloudMoonRain:C9,LucideCloudOff:T9,LucideCloudRain:E9,LucideCloudRainWind:A9,LucideCloudSnow:I9,LucideCloudSun:L9,LucideCloudSunRain:P9,LucideCloudUpload:ww,LucideCloudy:O9,LucideClover:qy,LucideClub:R9,LucideCode:vk,LucideCode2:jw,LucideCodeSquare:F2,LucideCodeXml:jw,LucideCodepen:F9,LucideCodesandbox:z9,LucideCoffee:_k,LucideCog:B9,LucideCoins:$9,LucideColumns:kw,LucideColumns2:kw,LucideColumns3:Nw,LucideColumns4:U9,LucideCombine:q9,LucideCommand:V9,LucideCompass:H9,LucideComponent:W9,LucideComputer:G9,LucideConciergeBell:K9,LucideCone:Z9,LucideConstruction:Y9,LucideContact:bk,LucideContact2:Sw,LucideContactRound:Sw,LucideContainer:X9,LucideContrast:Q9,LucideCookie:J9,LucideCookingPot:e$,LucideCopy:Di,LucideCopyCheck:t$,LucideCopyMinus:s$,LucideCopyPlus:r$,LucideCopySlash:n$,LucideCopyX:a$,LucideCopyleft:i$,LucideCopyright:o$,LucideCornerDownLeft:l$,LucideCornerDownRight:c$,LucideCornerLeftDown:d$,LucideCornerLeftUp:u$,LucideCornerRightDown:h$,LucideCornerRightUp:m$,LucideCornerUpLeft:p$,LucideCornerUpRight:f$,LucideCpu:g$,LucideCreativeCommons:x$,LucideCreditCard:Zm,LucideCroissant:y$,LucideCrop:v$,LucideCross:_$,LucideCrosshair:b$,LucideCrown:kh,LucideCuboid:w$,LucideCupSoda:j$,LucideCurlyBraces:Lb,LucideCurrency:k$,LucideCylinder:N$,LucideDam:S$,LucideDatabase:T$,LucideDatabaseBackup:C$,LucideDatabaseZap:M$,LucideDelete:A$,LucideDessert:E$,LucideDiameter:I$,LucideDiamond:D$,LucideDiamondMinus:P$,LucideDiamondPercent:Cw,LucideDiamondPlus:L$,LucideDice1:O$,LucideDice2:R$,LucideDice3:F$,LucideDice4:z$,LucideDice5:B$,LucideDice6:$$,LucideDices:U$,LucideDiff:q$,LucideDisc:G$,LucideDisc2:V$,LucideDisc3:H$,LucideDiscAlbum:W$,LucideDivide:K$,LucideDivideCircle:iw,LucideDivideSquare:U2,LucideDna:Y$,LucideDnaOff:Z$,LucideDock:X$,LucideDog:Q$,LucideDollarSign:Ad,LucideDonut:J$,LucideDoorClosed:eU,LucideDoorOpen:Xy,LucideDot:tU,LucideDotSquare:q2,LucideDownload:Vi,LucideDownloadCloud:bw,LucideDraftingCompass:sU,LucideDrama:rU,LucideDribbble:nU,LucideDrill:aU,LucideDroplet:iU,LucideDroplets:Nx,LucideDrum:oU,LucideDrumstick:lU,LucideDumbbell:cU,LucideEar:uU,LucideEarOff:dU,LucideEarth:Mw,LucideEarthLock:hU,LucideEclipse:mU,LucideEdit:_c,LucideEdit2:Iv,LucideEdit3:Ev,LucideEgg:T4,LucideEggFried:pU,LucideEggOff:fU,LucideEllipsis:Rp,LucideEllipsisVertical:hx,LucideEqual:yU,LucideEqualApproximately:gU,LucideEqualNot:xU,LucideEqualSquare:V2,LucideEraser:vU,LucideEthernetPort:_U,LucideEuro:bU,LucideExpand:wU,LucideExternalLink:bn,LucideEye:wi,LucideEyeClosed:jU,LucideEyeOff:Wp,LucideFacebook:Qd,LucideFactory:kU,LucideFan:NU,LucideFastForward:SU,LucideFeather:CU,LucideFence:MU,LucideFerrisWheel:TU,LucideFigma:AU,LucideFile:A4,LucideFileArchive:EU,LucideFileAudio:PU,LucideFileAudio2:IU,LucideFileAxis3D:Tw,LucideFileAxis3d:Tw,LucideFileBadge:DU,LucideFileBadge2:LU,LucideFileBarChart:Aw,LucideFileBarChart2:Ew,LucideFileBox:OU,LucideFileChartColumn:Ew,LucideFileChartColumnIncreasing:Aw,LucideFileChartLine:Iw,LucideFileChartPie:Pw,LucideFileCheck:FU,LucideFileCheck2:RU,LucideFileClock:zU,LucideFileCode:$U,LucideFileCode2:BU,LucideFileCog:Lw,LucideFileCog2:Lw,LucideFileDiff:UU,LucideFileDigit:qU,LucideFileDown:VU,LucideFileEdit:Ow,LucideFileHeart:HU,LucideFileImage:S1,LucideFileInput:WU,LucideFileJson:KU,LucideFileJson2:GU,LucideFileKey:YU,LucideFileKey2:ZU,LucideFileLineChart:Iw,LucideFileLock:QU,LucideFileLock2:XU,LucideFileMinus:eq,LucideFileMinus2:JU,LucideFileMusic:tq,LucideFileOutput:sq,LucideFilePen:Ow,LucideFilePenLine:Dw,LucideFilePieChart:Pw,LucideFilePlus:nq,LucideFilePlus2:rq,LucideFileQuestion:aq,LucideFileScan:iq,LucideFileSearch:lq,LucideFileSearch2:oq,LucideFileSignature:Dw,LucideFileSliders:cq,LucideFileSpreadsheet:Qy,LucideFileStack:kE,LucideFileSymlink:dq,LucideFileTerminal:uq,LucideFileText:Yn,LucideFileType:mq,LucideFileType2:hq,LucideFileUp:pq,LucideFileUser:fq,LucideFileVideo:xq,LucideFileVideo2:gq,LucideFileVolume:vq,LucideFileVolume2:yq,LucideFileWarning:_q,LucideFileX:wq,LucideFileX2:bq,LucideFiles:jq,LucideFilm:Wd,LucideFilter:Jy,LucideFilterX:kq,LucideFingerprint:Nq,LucideFireExtinguisher:Sq,LucideFish:Tq,LucideFishOff:Cq,LucideFishSymbol:Mq,LucideFlag:e0,LucideFlagOff:Aq,LucideFlagTriangleLeft:Eq,LucideFlagTriangleRight:Iq,LucideFlame:Ym,LucideFlameKindling:Pq,LucideFlashlight:Dq,LucideFlashlightOff:Lq,LucideFlaskConical:wk,LucideFlaskConicalOff:Oq,LucideFlaskRound:Rq,LucideFlipHorizontal:zq,LucideFlipHorizontal2:Fq,LucideFlipVertical:$q,LucideFlipVertical2:Bq,LucideFlower:Uq,LucideFlower2:ng,LucideFocus:qq,LucideFoldHorizontal:Vq,LucideFoldVertical:Hq,LucideFolder:yV,LucideFolderArchive:Wq,LucideFolderCheck:Gq,LucideFolderClock:Kq,LucideFolderClosed:Zq,LucideFolderCode:Yq,LucideFolderCog:Rw,LucideFolderCog2:Rw,LucideFolderDot:Xq,LucideFolderDown:Qq,LucideFolderEdit:Fw,LucideFolderGit:eV,LucideFolderGit2:Jq,LucideFolderHeart:tV,LucideFolderInput:sV,LucideFolderKanban:rV,LucideFolderKey:nV,LucideFolderLock:aV,LucideFolderMinus:iV,LucideFolderOpen:om,LucideFolderOpenDot:oV,LucideFolderOutput:lV,LucideFolderPen:Fw,LucideFolderPlus:cV,LucideFolderRoot:dV,LucideFolderSearch:hV,LucideFolderSearch2:uV,LucideFolderSymlink:mV,LucideFolderSync:pV,LucideFolderTree:fV,LucideFolderUp:gV,LucideFolderX:xV,LucideFolders:vV,LucideFootprints:_V,LucideForkKnife:Tj,LucideForkKnifeCrossed:Mj,LucideForklift:bV,LucideFormInput:d2,LucideForward:wV,LucideFrame:jV,LucideFramer:kV,LucideFrown:NV,LucideFuel:SV,LucideFullscreen:CV,LucideFunctionSquare:H2,LucideGalleryHorizontal:TV,LucideGalleryHorizontalEnd:MV,LucideGalleryThumbnails:AV,LucideGalleryVertical:IV,LucideGalleryVerticalEnd:EV,LucideGamepad:LV,LucideGamepad2:PV,LucideGanttChart:Hb,LucideGanttChartSquare:sx,LucideGauge:DV,LucideGaugeCircle:ow,LucideGavel:OV,LucideGem:RV,LucideGhost:jk,LucideGift:oo,LucideGitBranch:zV,LucideGitBranchPlus:FV,LucideGitCommit:zw,LucideGitCommitHorizontal:zw,LucideGitCommitVertical:BV,LucideGitCompare:UV,LucideGitCompareArrows:$V,LucideGitFork:qV,LucideGitGraph:VV,LucideGitMerge:HV,LucideGitPullRequest:XV,LucideGitPullRequestArrow:WV,LucideGitPullRequestClosed:GV,LucideGitPullRequestCreate:ZV,LucideGitPullRequestCreateArrow:KV,LucideGitPullRequestDraft:YV,LucideGithub:QV,LucideGitlab:JV,LucideGlassWater:eH,LucideGlasses:tH,LucideGlobe:pg,LucideGlobe2:Mw,LucideGlobeLock:sH,LucideGoal:rH,LucideGrab:nH,LucideGraduationCap:C1,LucideGrape:aH,LucideGrid:Im,LucideGrid2X2:$w,LucideGrid2X2Plus:Bw,LucideGrid2x2:$w,LucideGrid2x2Check:iH,LucideGrid2x2Plus:Bw,LucideGrid2x2X:oH,LucideGrid3X3:Im,LucideGrid3x3:Im,LucideGrip:cH,LucideGripHorizontal:lH,LucideGripVertical:lm,LucideGroup:dH,LucideGuitar:uH,LucideHam:hH,LucideHammer:mH,LucideHand:NE,LucideHandCoins:pH,LucideHandHeart:fH,LucideHandHelping:Uw,LucideHandMetal:gH,LucideHandPlatter:xH,LucideHandshake:yH,LucideHardDrive:SE,LucideHardDriveDownload:vH,LucideHardDriveUpload:_H,LucideHardHat:bH,LucideHash:E4,LucideHaze:wH,LucideHdmiPort:jH,LucideHeading:MH,LucideHeading1:CE,LucideHeading2:ME,LucideHeading3:kH,LucideHeading4:NH,LucideHeading5:SH,LucideHeading6:CH,LucideHeadphoneOff:TH,LucideHeadphones:AH,LucideHeadset:EH,LucideHeart:Ti,LucideHeartCrack:IH,LucideHeartHandshake:PH,LucideHeartOff:LH,LucideHeartPulse:DH,LucideHeater:OH,LucideHelpCircle:Dy,LucideHelpingHand:Uw,LucideHexagon:RH,LucideHighlighter:FH,LucideHistory:I4,LucideHome:Zn,LucideHop:BH,LucideHopOff:zH,LucideHospital:$H,LucideHotel:UH,LucideHourglass:qH,LucideHouse:Zn,LucideHousePlug:VH,LucideHousePlus:HH,LucideIceCream:Vw,LucideIceCream2:qw,LucideIceCreamBowl:qw,LucideIceCreamCone:Vw,LucideIdCard:WH,LucideImage:fl,LucideImageDown:GH,LucideImageMinus:KH,LucideImageOff:ZH,LucideImagePlay:YH,LucideImagePlus:M1,LucideImageUp:XH,LucideImageUpscale:QH,LucideImages:JH,LucideImport:eW,LucideInbox:tW,LucideIndent:Ww,LucideIndentDecrease:Hw,LucideIndentIncrease:Ww,LucideIndianRupee:sW,LucideInfinity:rW,LucideInfo:nW,LucideInspect:X2,LucideInspectionPanel:aW,LucideInstagram:vu,LucideItalic:P4,LucideIterationCcw:iW,LucideIterationCw:oW,LucideJapaneseYen:lW,LucideJoystick:cW,LucideKanban:Sx,LucideKanbanSquare:W2,LucideKanbanSquareDashed:z2,LucideKey:Xm,LucideKeyRound:kk,LucideKeySquare:dW,LucideKeyboard:mW,LucideKeyboardMusic:uW,LucideKeyboardOff:hW,LucideLamp:vW,LucideLampCeiling:pW,LucideLampDesk:fW,LucideLampFloor:gW,LucideLampWallDown:xW,LucideLampWallUp:yW,LucideLandPlot:_W,LucideLandmark:bW,LucideLanguages:wW,LucideLaptop:kW,LucideLaptop2:Gw,LucideLaptopMinimal:Gw,LucideLaptopMinimalCheck:jW,LucideLasso:SW,LucideLassoSelect:NW,LucideLaugh:CW,LucideLayers:AW,LucideLayers2:MW,LucideLayers3:TW,LucideLayout:Av,LucideLayoutDashboard:Nk,LucideLayoutGrid:Qm,LucideLayoutList:EW,LucideLayoutPanelLeft:IW,LucideLayoutPanelTop:PW,LucideLayoutTemplate:Sk,LucideLeaf:LW,LucideLeafyGreen:DW,LucideLectern:OW,LucideLetterText:RW,LucideLibrary:L4,LucideLibraryBig:FW,LucideLibrarySquare:G2,LucideLifeBuoy:D4,LucideLigature:zW,LucideLightbulb:t0,LucideLightbulbOff:BW,LucideLineChart:Ub,LucideLink:Ro,LucideLink2:Jm,LucideLink2Off:$W,LucideLinkedin:cm,LucideList:dm,LucideListCheck:UW,LucideListChecks:qW,LucideListCollapse:VW,LucideListEnd:HW,LucideListFilter:WW,LucideListMinus:GW,LucideListMusic:KW,LucideListOrdered:O4,LucideListPlus:ZW,LucideListRestart:YW,LucideListStart:XW,LucideListTodo:QW,LucideListTree:JW,LucideListVideo:eG,LucideListX:tG,LucideLoader:rG,LucideLoader2:Us,LucideLoaderCircle:Us,LucideLoaderPinwheel:sG,LucideLocate:TE,LucideLocateFixed:nG,LucideLocateOff:aG,LucideLock:zu,LucideLockKeyhole:iG,LucideLockKeyholeOpen:Kw,LucideLockOpen:Zw,LucideLogIn:R4,LucideLogOut:F4,LucideLogs:oG,LucideLollipop:lG,LucideLuggage:cG,LucideMSquare:K2,LucideMagnet:dG,LucideMail:zr,LucideMailCheck:uG,LucideMailMinus:hG,LucideMailOpen:mG,LucideMailPlus:pG,LucideMailQuestion:fG,LucideMailSearch:gG,LucideMailWarning:xG,LucideMailX:AE,LucideMailbox:yG,LucideMails:vG,LucideMap:EG,LucideMapPin:Gi,LucideMapPinCheck:bG,LucideMapPinCheckInside:_G,LucideMapPinHouse:wG,LucideMapPinMinus:kG,LucideMapPinMinusInside:jG,LucideMapPinOff:NG,LucideMapPinPlus:CG,LucideMapPinPlusInside:SG,LucideMapPinX:TG,LucideMapPinXInside:MG,LucideMapPinned:AG,LucideMartini:IG,LucideMaximize:LG,LucideMaximize2:PG,LucideMedal:s0,LucideMegaphone:fg,LucideMegaphoneOff:DG,LucideMeh:OG,LucideMemoryStick:RG,LucideMenu:EE,LucideMenuSquare:Z2,LucideMerge:FG,LucideMessageCircle:Gl,LucideMessageCircleCode:zG,LucideMessageCircleDashed:BG,LucideMessageCircleHeart:z4,LucideMessageCircleMore:$G,LucideMessageCircleOff:UG,LucideMessageCirclePlus:qG,LucideMessageCircleQuestion:IE,LucideMessageCircleReply:VG,LucideMessageCircleWarning:HG,LucideMessageCircleX:WG,LucideMessageSquare:Eo,LucideMessageSquareCode:GG,LucideMessageSquareDashed:KG,LucideMessageSquareDiff:ZG,LucideMessageSquareDot:YG,LucideMessageSquareHeart:PE,LucideMessageSquareLock:XG,LucideMessageSquareMore:QG,LucideMessageSquareOff:JG,LucideMessageSquarePlus:B4,LucideMessageSquareQuote:LE,LucideMessageSquareReply:eK,LucideMessageSquareShare:tK,LucideMessageSquareText:sK,LucideMessageSquareWarning:rK,LucideMessageSquareX:nK,LucideMessagesSquare:aK,LucideMic:DE,LucideMic2:Yw,LucideMicOff:iK,LucideMicVocal:Yw,LucideMicrochip:oK,LucideMicroscope:lK,LucideMicrowave:cK,LucideMilestone:dK,LucideMilk:hK,LucideMilkOff:uK,LucideMinimize:pK,LucideMinimize2:mK,LucideMinus:T1,LucideMinusCircle:lw,LucideMinusSquare:Y2,LucideMonitor:Ck,LucideMonitorCheck:fK,LucideMonitorCog:gK,LucideMonitorDot:xK,LucideMonitorDown:yK,LucideMonitorOff:vK,LucideMonitorPause:_K,LucideMonitorPlay:bK,LucideMonitorSmartphone:wK,LucideMonitorSpeaker:jK,LucideMonitorStop:kK,LucideMonitorUp:NK,LucideMonitorX:SK,LucideMoon:MK,LucideMoonStar:CK,LucideMoreHorizontal:Rp,LucideMoreVertical:hx,LucideMountain:AK,LucideMountainSnow:TK,LucideMouse:DK,LucideMouseOff:EK,LucideMousePointer:LK,LucideMousePointer2:IK,LucideMousePointerBan:PK,LucideMousePointerClick:A1,LucideMousePointerSquareDashed:B2,LucideMove:KK,LucideMove3D:Xw,LucideMove3d:Xw,LucideMoveDiagonal:RK,LucideMoveDiagonal2:OK,LucideMoveDown:BK,LucideMoveDownLeft:FK,LucideMoveDownRight:zK,LucideMoveHorizontal:$K,LucideMoveLeft:UK,LucideMoveRight:qK,LucideMoveUp:WK,LucideMoveUpLeft:VK,LucideMoveUpRight:HK,LucideMoveVertical:GK,LucideMusic:QK,LucideMusic2:ZK,LucideMusic3:YK,LucideMusic4:XK,LucideNavigation:OE,LucideNavigation2:eZ,LucideNavigation2Off:JK,LucideNavigationOff:tZ,LucideNetwork:sZ,LucideNewspaper:r0,LucideNfc:rZ,LucideNotebook:oZ,LucideNotebookPen:nZ,LucideNotebookTabs:aZ,LucideNotebookText:iZ,LucideNotepadText:cZ,LucideNotepadTextDashed:lZ,LucideNut:uZ,LucideNutOff:dZ,LucideOctagon:mZ,LucideOctagonAlert:Qw,LucideOctagonMinus:hZ,LucideOctagonPause:Jw,LucideOctagonX:e2,LucideOmega:pZ,LucideOption:fZ,LucideOrbit:gZ,LucideOrigami:xZ,LucideOutdent:Hw,LucidePackage:mc,LucidePackage2:yZ,LucidePackageCheck:vZ,LucidePackageMinus:_Z,LucidePackageOpen:bZ,LucidePackagePlus:wZ,LucidePackageSearch:jZ,LucidePackageX:kZ,LucidePaintBucket:NZ,LucidePaintRoller:SZ,LucidePaintbrush:CZ,LucidePaintbrush2:t2,LucidePaintbrushVertical:t2,LucidePalette:hd,LucidePalmtree:yj,LucidePanelBottom:AZ,LucidePanelBottomClose:MZ,LucidePanelBottomDashed:s2,LucidePanelBottomInactive:s2,LucidePanelBottomOpen:TZ,LucidePanelLeft:i2,LucidePanelLeftClose:r2,LucidePanelLeftDashed:n2,LucidePanelLeftInactive:n2,LucidePanelLeftOpen:a2,LucidePanelRight:PZ,LucidePanelRightClose:EZ,LucidePanelRightDashed:o2,LucidePanelRightInactive:o2,LucidePanelRightOpen:IZ,LucidePanelTop:OZ,LucidePanelTopClose:LZ,LucidePanelTopDashed:l2,LucidePanelTopInactive:l2,LucidePanelTopOpen:DZ,LucidePanelsLeftBottom:RZ,LucidePanelsLeftRight:Nw,LucidePanelsRightBottom:FZ,LucidePanelsTopBottom:m2,LucidePanelsTopLeft:Av,LucidePaperclip:Mk,LucideParentheses:zZ,LucideParkingCircle:dw,LucideParkingCircleOff:cw,LucideParkingMeter:BZ,LucideParkingSquare:J2,LucideParkingSquareOff:Q2,LucidePartyPopper:md,LucidePause:ep,LucidePauseCircle:uw,LucidePauseOctagon:Jw,LucidePawPrint:$Z,LucidePcCase:UZ,LucidePen:Iv,LucidePenBox:_c,LucidePenLine:Ev,LucidePenOff:qZ,LucidePenSquare:_c,LucidePenTool:Tk,LucidePencil:Xa,LucidePencilLine:VZ,LucidePencilOff:HZ,LucidePencilRuler:WZ,LucidePentagon:GZ,LucidePercent:$4,LucidePercentCircle:hw,LucidePercentDiamond:Cw,LucidePercentSquare:ej,LucidePersonStanding:KZ,LucidePhilippinePeso:ZZ,LucidePhone:Ha,LucidePhoneCall:YZ,LucidePhoneForwarded:XZ,LucidePhoneIncoming:QZ,LucidePhoneMissed:JZ,LucidePhoneOff:eY,LucidePhoneOutgoing:tY,LucidePi:sY,LucidePiSquare:tj,LucidePiano:rY,LucidePickaxe:nY,LucidePictureInPicture:iY,LucidePictureInPicture2:aY,LucidePieChart:Wb,LucidePiggyBank:oY,LucidePilcrow:dY,LucidePilcrowLeft:lY,LucidePilcrowRight:cY,LucidePilcrowSquare:sj,LucidePill:hY,LucidePillBottle:uY,LucidePin:E1,LucidePinOff:RE,LucidePipette:mY,LucidePizza:pY,LucidePlane:xY,LucidePlaneLanding:fY,LucidePlaneTakeoff:gY,LucidePlay:Kl,LucidePlayCircle:Om,LucidePlaySquare:rj,LucidePlug:FE,LucidePlug2:yY,LucidePlugZap:c2,LucidePlugZap2:c2,LucidePlus:ar,LucidePlusCircle:mw,LucidePlusSquare:nj,LucidePocket:_Y,LucidePocketKnife:vY,LucidePodcast:bY,LucidePointer:jY,LucidePointerOff:wY,LucidePopcorn:kY,LucidePopsicle:NY,LucidePoundSterling:SY,LucidePower:MY,LucidePowerCircle:pw,LucidePowerOff:CY,LucidePowerSquare:aj,LucidePresentation:Gp,LucidePrinter:zE,LucidePrinterCheck:TY,LucideProjector:AY,LucideProportions:EY,LucidePuzzle:IY,LucidePyramid:PY,LucideQrCode:Ak,LucideQuote:U4,LucideRabbit:LY,LucideRadar:DY,LucideRadiation:OY,LucideRadical:RY,LucideRadio:Ek,LucideRadioReceiver:FY,LucideRadioTower:zY,LucideRadius:BY,LucideRailSymbol:$Y,LucideRainbow:UY,LucideRat:qY,LucideRatio:VY,LucideReceipt:JY,LucideReceiptCent:HY,LucideReceiptEuro:WY,LucideReceiptIndianRupee:GY,LucideReceiptJapaneseYen:KY,LucideReceiptPoundSterling:ZY,LucideReceiptRussianRuble:YY,LucideReceiptSwissFranc:XY,LucideReceiptText:QY,LucideRectangleEllipsis:d2,LucideRectangleHorizontal:eX,LucideRectangleVertical:tX,LucideRecycle:sX,LucideRedo:q4,LucideRedo2:rX,LucideRedoDot:nX,LucideRefreshCcw:iX,LucideRefreshCcwDot:aX,LucideRefreshCw:el,LucideRefreshCwOff:oX,LucideRefrigerator:lX,LucideRegex:cX,LucideRemoveFormatting:dX,LucideRepeat:BE,LucideRepeat1:uX,LucideRepeat2:hX,LucideReplace:pX,LucideReplaceAll:mX,LucideReply:$E,LucideReplyAll:fX,LucideRewind:gX,LucideRibbon:xX,LucideRocket:Cx,LucideRockingChair:yX,LucideRollerCoaster:vX,LucideRotate3D:u2,LucideRotate3d:u2,LucideRotateCcw:Ik,LucideRotateCcwSquare:_X,LucideRotateCw:UE,LucideRotateCwSquare:bX,LucideRoute:jX,LucideRouteOff:wX,LucideRouter:kX,LucideRows:h2,LucideRows2:h2,LucideRows3:m2,LucideRows4:NX,LucideRss:SX,LucideRuler:CX,LucideRussianRuble:MX,LucideSailboat:TX,LucideSalad:AX,LucideSandwich:EX,LucideSatellite:PX,LucideSatelliteDish:IX,LucideSave:um,LucideSaveAll:LX,LucideSaveOff:DX,LucideScale:OX,LucideScale3D:p2,LucideScale3d:p2,LucideScaling:RX,LucideScan:HX,LucideScanBarcode:FX,LucideScanEye:zX,LucideScanFace:BX,LucideScanLine:$X,LucideScanQrCode:UX,LucideScanSearch:qX,LucideScanText:VX,LucideScatterChart:Gb,LucideSchool:WX,LucideSchool2:_j,LucideScissors:KX,LucideScissorsLineDashed:GX,LucideScissorsSquare:ij,LucideScissorsSquareDashedBottom:I2,LucideScreenShare:YX,LucideScreenShareOff:ZX,LucideScroll:QX,LucideScrollText:XX,LucideSearch:On,LucideSearchCheck:JX,LucideSearchCode:eQ,LucideSearchSlash:tQ,LucideSearchX:sQ,LucideSection:rQ,LucideSend:Wa,LucideSendHorizonal:f2,LucideSendHorizontal:f2,LucideSendToBack:nQ,LucideSeparatorHorizontal:aQ,LucideSeparatorVertical:iQ,LucideServer:dQ,LucideServerCog:oQ,LucideServerCrash:lQ,LucideServerOff:cQ,LucideSettings:Ic,LucideSettings2:uQ,LucideShapes:hQ,LucideShare:qE,LucideShare2:Kc,LucideSheet:mQ,LucideShell:pQ,LucideShield:Bu,LucideShieldAlert:fQ,LucideShieldBan:gQ,LucideShieldCheck:VE,LucideShieldClose:g2,LucideShieldEllipsis:xQ,LucideShieldHalf:yQ,LucideShieldMinus:vQ,LucideShieldOff:_Q,LucideShieldPlus:bQ,LucideShieldQuestion:wQ,LucideShieldX:g2,LucideShip:kQ,LucideShipWheel:jQ,LucideShirt:NQ,LucideShoppingBag:Mx,LucideShoppingBasket:SQ,LucideShoppingCart:Jh,LucideShovel:CQ,LucideShowerHead:MQ,LucideShrink:TQ,LucideShrub:AQ,LucideShuffle:EQ,LucideSidebar:i2,LucideSidebarClose:r2,LucideSidebarOpen:a2,LucideSigma:IQ,LucideSigmaSquare:oj,LucideSignal:RQ,LucideSignalHigh:PQ,LucideSignalLow:LQ,LucideSignalMedium:DQ,LucideSignalZero:OQ,LucideSignature:FQ,LucideSignpost:BQ,LucideSignpostBig:zQ,LucideSiren:$Q,LucideSkipBack:UQ,LucideSkipForward:qQ,LucideSkull:VQ,LucideSlack:HQ,LucideSlash:WQ,LucideSlashSquare:lj,LucideSlice:GQ,LucideSliders:x2,LucideSlidersHorizontal:HE,LucideSlidersVertical:x2,LucideSmartphone:n0,LucideSmartphoneCharging:KQ,LucideSmartphoneNfc:ZQ,LucideSmile:XQ,LucideSmilePlus:YQ,LucideSnail:QQ,LucideSnowflake:o1,LucideSofa:JQ,LucideSortAsc:Cb,LucideSortDesc:kb,LucideSoup:eJ,LucideSpace:tJ,LucideSpade:sJ,LucideSparkle:rJ,LucideSparkles:Sn,LucideSpeaker:nJ,LucideSpeech:aJ,LucideSpellCheck:oJ,LucideSpellCheck2:iJ,LucideSpline:lJ,LucideSplit:cJ,LucideSplitSquareHorizontal:cj,LucideSplitSquareVertical:dj,LucideSprayCan:dJ,LucideSprout:uJ,LucideSquare:Tx,LucideSquareActivity:y2,LucideSquareArrowDown:b2,LucideSquareArrowDownLeft:v2,LucideSquareArrowDownRight:_2,LucideSquareArrowLeft:w2,LucideSquareArrowOutDownLeft:j2,LucideSquareArrowOutDownRight:k2,LucideSquareArrowOutUpLeft:N2,LucideSquareArrowOutUpRight:S2,LucideSquareArrowRight:C2,LucideSquareArrowUp:A2,LucideSquareArrowUpLeft:M2,LucideSquareArrowUpRight:T2,LucideSquareAsterisk:E2,LucideSquareBottomDashedScissors:I2,LucideSquareChartGantt:sx,LucideSquareCheck:P2,LucideSquareCheckBig:Oy,LucideSquareChevronDown:L2,LucideSquareChevronLeft:D2,LucideSquareChevronRight:O2,LucideSquareChevronUp:R2,LucideSquareCode:F2,LucideSquareDashed:$2,LucideSquareDashedBottom:mJ,LucideSquareDashedBottomCode:hJ,LucideSquareDashedKanban:z2,LucideSquareDashedMousePointer:B2,LucideSquareDivide:U2,LucideSquareDot:q2,LucideSquareEqual:V2,LucideSquareFunction:H2,LucideSquareGanttChart:sx,LucideSquareKanban:W2,LucideSquareLibrary:G2,LucideSquareM:K2,LucideSquareMenu:Z2,LucideSquareMinus:Y2,LucideSquareMousePointer:X2,LucideSquareParking:J2,LucideSquareParkingOff:Q2,LucideSquarePen:_c,LucideSquarePercent:ej,LucideSquarePi:tj,LucideSquarePilcrow:sj,LucideSquarePlay:rj,LucideSquarePlus:nj,LucideSquarePower:aj,LucideSquareRadical:pJ,LucideSquareScissors:ij,LucideSquareSigma:oj,LucideSquareSlash:lj,LucideSquareSplitHorizontal:cj,LucideSquareSplitVertical:dj,LucideSquareSquare:fJ,LucideSquareStack:gJ,LucideSquareTerminal:uj,LucideSquareUser:mj,LucideSquareUserRound:hj,LucideSquareX:pj,LucideSquircle:xJ,LucideSquirrel:yJ,LucideStamp:vJ,LucideStar:qn,LucideStarHalf:_J,LucideStarOff:bJ,LucideStars:Sn,LucideStepBack:wJ,LucideStepForward:jJ,LucideStethoscope:kJ,LucideSticker:NJ,LucideStickyNote:SJ,LucideStopCircle:gw,LucideStore:CJ,LucideStretchHorizontal:MJ,LucideStretchVertical:TJ,LucideStrikethrough:AJ,LucideSubscript:EJ,LucideSubtitles:Db,LucideSun:I1,LucideSunDim:IJ,LucideSunMedium:PJ,LucideSunMoon:LJ,LucideSunSnow:DJ,LucideSunrise:OJ,LucideSunset:RJ,LucideSuperscript:FJ,LucideSwatchBook:zJ,LucideSwissFranc:BJ,LucideSwitchCamera:$J,LucideSword:UJ,LucideSwords:qJ,LucideSyringe:VJ,LucideTable:WE,LucideTable2:V4,LucideTableCellsMerge:HJ,LucideTableCellsSplit:WJ,LucideTableColumnsSplit:GJ,LucideTableOfContents:KJ,LucideTableProperties:ZJ,LucideTableRowsSplit:YJ,LucideTablet:QJ,LucideTabletSmartphone:XJ,LucideTablets:JJ,LucideTag:Kp,LucideTags:eee,LucideTally1:tee,LucideTally2:see,LucideTally3:ree,LucideTally4:nee,LucideTally5:aee,LucideTangent:iee,LucideTarget:hm,LucideTelescope:oee,LucideTent:cee,LucideTentTree:lee,LucideTerminal:dee,LucideTerminalSquare:uj,LucideTestTube:uee,LucideTestTube2:fj,LucideTestTubeDiagonal:fj,LucideTestTubes:hee,LucideText:xee,LucideTextCursor:pee,LucideTextCursorInput:mee,LucideTextQuote:fee,LucideTextSearch:gee,LucideTextSelect:gj,LucideTextSelection:gj,LucideTheater:yee,LucideThermometer:bee,LucideThermometerSnowflake:vee,LucideThermometerSun:_ee,LucideThumbsDown:GE,LucideThumbsUp:Ed,LucideTicket:KE,LucideTicketCheck:wee,LucideTicketMinus:jee,LucideTicketPercent:kee,LucideTicketPlus:Nee,LucideTicketSlash:See,LucideTicketX:Cee,LucideTickets:Tee,LucideTicketsPlane:Mee,LucideTimer:Iee,LucideTimerOff:Aee,LucideTimerReset:Eee,LucideToggleLeft:Pee,LucideToggleRight:Lee,LucideToilet:Dee,LucideTornado:Oee,LucideTorus:Ree,LucideTouchpad:zee,LucideTouchpadOff:Fee,LucideTowerControl:Bee,LucideToyBrick:$ee,LucideTractor:Uee,LucideTrafficCone:qee,LucideTrain:xj,LucideTrainFront:Hee,LucideTrainFrontTunnel:Vee,LucideTrainTrack:Wee,LucideTramFront:xj,LucideTrash:Gee,LucideTrash2:Ir,LucideTreeDeciduous:Kee,LucideTreePalm:yj,LucideTreePine:P1,LucideTrees:Zee,LucideTrello:Yee,LucideTrendingDown:Pk,LucideTrendingUp:Jd,LucideTrendingUpDown:Xee,LucideTriangle:Jee,LucideTriangleAlert:Lu,LucideTriangleRight:Qee,LucideTrophy:vo,LucideTruck:ZE,LucideTurtle:ete,LucideTv:ste,LucideTv2:vj,LucideTvMinimal:vj,LucideTvMinimalPlay:tte,LucideTwitch:rte,LucideTwitter:nte,LucideType:ite,LucideTypeOutline:ate,LucideUmbrella:lte,LucideUmbrellaOff:ote,LucideUnderline:cte,LucideUndo:H4,LucideUndo2:dte,LucideUndoDot:ute,LucideUnfoldHorizontal:hte,LucideUnfoldVertical:mte,LucideUngroup:pte,LucideUniversity:_j,LucideUnlink:YE,LucideUnlink2:fte,LucideUnlock:Zw,LucideUnlockKeyhole:Kw,LucideUnplug:gte,LucideUpload:ji,LucideUploadCloud:ww,LucideUsb:xte,LucideUser:Wo,LucideUser2:Sj,LucideUserCheck:Lk,LucideUserCheck2:bj,LucideUserCircle:yw,LucideUserCircle2:xw,LucideUserCog:XE,LucideUserCog2:wj,LucideUserMinus:QE,LucideUserMinus2:jj,LucideUserPen:yte,LucideUserPlus:Zc,LucideUserPlus2:kj,LucideUserRound:Sj,LucideUserRoundCheck:bj,LucideUserRoundCog:wj,LucideUserRoundMinus:jj,LucideUserRoundPen:vte,LucideUserRoundPlus:kj,LucideUserRoundSearch:_te,LucideUserRoundX:Nj,LucideUserSearch:bte,LucideUserSquare:mj,LucideUserSquare2:hj,LucideUserX:wte,LucideUserX2:Nj,LucideUsers:br,LucideUsers2:Cj,LucideUsersRound:Cj,LucideUtensils:Tj,LucideUtensilsCrossed:Mj,LucideUtilityPole:jte,LucideVariable:JE,LucideVault:kte,LucideVegan:Nte,LucideVenetianMask:Ste,LucideVerified:Ab,LucideVibrate:Mte,LucideVibrateOff:Cte,LucideVideo:Wn,LucideVideoOff:Tte,LucideVideotape:Ate,LucideView:Ete,LucideVoicemail:Ite,LucideVolleyball:Pte,LucideVolume:Fte,LucideVolume1:Lte,LucideVolume2:Dte,LucideVolumeOff:Ote,LucideVolumeX:Rte,LucideVote:zte,LucideWallet:$te,LucideWallet2:Aj,LucideWalletCards:Bte,LucideWalletMinimal:Aj,LucideWallpaper:Ute,LucideWand:qte,LucideWand2:Ej,LucideWandSparkles:Ej,LucideWarehouse:Vte,LucideWashingMachine:Hte,LucideWatch:Wte,LucideWaves:Gte,LucideWaypoints:Kte,LucideWebcam:Zte,LucideWebhook:Xte,LucideWebhookOff:Yte,LucideWeight:Qte,LucideWheat:ese,LucideWheatOff:Jte,LucideWholeWord:tse,LucideWifi:ise,LucideWifiHigh:sse,LucideWifiLow:rse,LucideWifiOff:nse,LucideWifiZero:ase,LucideWind:lse,LucideWindArrowDown:ose,LucideWine:dse,LucideWineOff:cse,LucideWorkflow:use,LucideWorm:hse,LucideWrapText:mse,LucideWrench:a0,LucideX:Xr,LucideXCircle:Cc,LucideXOctagon:e2,LucideXSquare:pj,LucideYoutube:pse,LucideZap:Ax,LucideZapOff:fse,LucideZoomIn:W4,LucideZoomOut:G4,Luggage:cG,LuggageIcon:cG,MSquare:K2,MSquareIcon:K2,Magnet:dG,MagnetIcon:dG,Mail:zr,MailCheck:uG,MailCheckIcon:uG,MailIcon:zr,MailMinus:hG,MailMinusIcon:hG,MailOpen:mG,MailOpenIcon:mG,MailPlus:pG,MailPlusIcon:pG,MailQuestion:fG,MailQuestionIcon:fG,MailSearch:gG,MailSearchIcon:gG,MailWarning:xG,MailWarningIcon:xG,MailX:AE,MailXIcon:AE,Mailbox:yG,MailboxIcon:yG,Mails:vG,MailsIcon:vG,Map:EG,MapIcon:EG,MapPin:Gi,MapPinCheck:bG,MapPinCheckIcon:bG,MapPinCheckInside:_G,MapPinCheckInsideIcon:_G,MapPinHouse:wG,MapPinHouseIcon:wG,MapPinIcon:Gi,MapPinMinus:kG,MapPinMinusIcon:kG,MapPinMinusInside:jG,MapPinMinusInsideIcon:jG,MapPinOff:NG,MapPinOffIcon:NG,MapPinPlus:CG,MapPinPlusIcon:CG,MapPinPlusInside:SG,MapPinPlusInsideIcon:SG,MapPinX:TG,MapPinXIcon:TG,MapPinXInside:MG,MapPinXInsideIcon:MG,MapPinned:AG,MapPinnedIcon:AG,Martini:IG,MartiniIcon:IG,Maximize:LG,Maximize2:PG,Maximize2Icon:PG,MaximizeIcon:LG,Medal:s0,MedalIcon:s0,Megaphone:fg,MegaphoneIcon:fg,MegaphoneOff:DG,MegaphoneOffIcon:DG,Meh:OG,MehIcon:OG,MemoryStick:RG,MemoryStickIcon:RG,Menu:EE,MenuIcon:EE,MenuSquare:Z2,MenuSquareIcon:Z2,Merge:FG,MergeIcon:FG,MessageCircle:Gl,MessageCircleCode:zG,MessageCircleCodeIcon:zG,MessageCircleDashed:BG,MessageCircleDashedIcon:BG,MessageCircleHeart:z4,MessageCircleHeartIcon:z4,MessageCircleIcon:Gl,MessageCircleMore:$G,MessageCircleMoreIcon:$G,MessageCircleOff:UG,MessageCircleOffIcon:UG,MessageCirclePlus:qG,MessageCirclePlusIcon:qG,MessageCircleQuestion:IE,MessageCircleQuestionIcon:IE,MessageCircleReply:VG,MessageCircleReplyIcon:VG,MessageCircleWarning:HG,MessageCircleWarningIcon:HG,MessageCircleX:WG,MessageCircleXIcon:WG,MessageSquare:Eo,MessageSquareCode:GG,MessageSquareCodeIcon:GG,MessageSquareDashed:KG,MessageSquareDashedIcon:KG,MessageSquareDiff:ZG,MessageSquareDiffIcon:ZG,MessageSquareDot:YG,MessageSquareDotIcon:YG,MessageSquareHeart:PE,MessageSquareHeartIcon:PE,MessageSquareIcon:Eo,MessageSquareLock:XG,MessageSquareLockIcon:XG,MessageSquareMore:QG,MessageSquareMoreIcon:QG,MessageSquareOff:JG,MessageSquareOffIcon:JG,MessageSquarePlus:B4,MessageSquarePlusIcon:B4,MessageSquareQuote:LE,MessageSquareQuoteIcon:LE,MessageSquareReply:eK,MessageSquareReplyIcon:eK,MessageSquareShare:tK,MessageSquareShareIcon:tK,MessageSquareText:sK,MessageSquareTextIcon:sK,MessageSquareWarning:rK,MessageSquareWarningIcon:rK,MessageSquareX:nK,MessageSquareXIcon:nK,MessagesSquare:aK,MessagesSquareIcon:aK,Mic:DE,Mic2:Yw,Mic2Icon:Yw,MicIcon:DE,MicOff:iK,MicOffIcon:iK,MicVocal:Yw,MicVocalIcon:Yw,Microchip:oK,MicrochipIcon:oK,Microscope:lK,MicroscopeIcon:lK,Microwave:cK,MicrowaveIcon:cK,Milestone:dK,MilestoneIcon:dK,Milk:hK,MilkIcon:hK,MilkOff:uK,MilkOffIcon:uK,Minimize:pK,Minimize2:mK,Minimize2Icon:mK,MinimizeIcon:pK,Minus:T1,MinusCircle:lw,MinusCircleIcon:lw,MinusIcon:T1,MinusSquare:Y2,MinusSquareIcon:Y2,Monitor:Ck,MonitorCheck:fK,MonitorCheckIcon:fK,MonitorCog:gK,MonitorCogIcon:gK,MonitorDot:xK,MonitorDotIcon:xK,MonitorDown:yK,MonitorDownIcon:yK,MonitorIcon:Ck,MonitorOff:vK,MonitorOffIcon:vK,MonitorPause:_K,MonitorPauseIcon:_K,MonitorPlay:bK,MonitorPlayIcon:bK,MonitorSmartphone:wK,MonitorSmartphoneIcon:wK,MonitorSpeaker:jK,MonitorSpeakerIcon:jK,MonitorStop:kK,MonitorStopIcon:kK,MonitorUp:NK,MonitorUpIcon:NK,MonitorX:SK,MonitorXIcon:SK,Moon:MK,MoonIcon:MK,MoonStar:CK,MoonStarIcon:CK,MoreHorizontal:Rp,MoreHorizontalIcon:Rp,MoreVertical:hx,MoreVerticalIcon:hx,Mountain:AK,MountainIcon:AK,MountainSnow:TK,MountainSnowIcon:TK,Mouse:DK,MouseIcon:DK,MouseOff:EK,MouseOffIcon:EK,MousePointer:LK,MousePointer2:IK,MousePointer2Icon:IK,MousePointerBan:PK,MousePointerBanIcon:PK,MousePointerClick:A1,MousePointerClickIcon:A1,MousePointerIcon:LK,MousePointerSquareDashed:B2,MousePointerSquareDashedIcon:B2,Move:KK,Move3D:Xw,Move3DIcon:Xw,Move3d:Xw,Move3dIcon:Xw,MoveDiagonal:RK,MoveDiagonal2:OK,MoveDiagonal2Icon:OK,MoveDiagonalIcon:RK,MoveDown:BK,MoveDownIcon:BK,MoveDownLeft:FK,MoveDownLeftIcon:FK,MoveDownRight:zK,MoveDownRightIcon:zK,MoveHorizontal:$K,MoveHorizontalIcon:$K,MoveIcon:KK,MoveLeft:UK,MoveLeftIcon:UK,MoveRight:qK,MoveRightIcon:qK,MoveUp:WK,MoveUpIcon:WK,MoveUpLeft:VK,MoveUpLeftIcon:VK,MoveUpRight:HK,MoveUpRightIcon:HK,MoveVertical:GK,MoveVerticalIcon:GK,Music:QK,Music2:ZK,Music2Icon:ZK,Music3:YK,Music3Icon:YK,Music4:XK,Music4Icon:XK,MusicIcon:QK,Navigation:OE,Navigation2:eZ,Navigation2Icon:eZ,Navigation2Off:JK,Navigation2OffIcon:JK,NavigationIcon:OE,NavigationOff:tZ,NavigationOffIcon:tZ,Network:sZ,NetworkIcon:sZ,Newspaper:r0,NewspaperIcon:r0,Nfc:rZ,NfcIcon:rZ,Notebook:oZ,NotebookIcon:oZ,NotebookPen:nZ,NotebookPenIcon:nZ,NotebookTabs:aZ,NotebookTabsIcon:aZ,NotebookText:iZ,NotebookTextIcon:iZ,NotepadText:cZ,NotepadTextDashed:lZ,NotepadTextDashedIcon:lZ,NotepadTextIcon:cZ,Nut:uZ,NutIcon:uZ,NutOff:dZ,NutOffIcon:dZ,Octagon:mZ,OctagonAlert:Qw,OctagonAlertIcon:Qw,OctagonIcon:mZ,OctagonMinus:hZ,OctagonMinusIcon:hZ,OctagonPause:Jw,OctagonPauseIcon:Jw,OctagonX:e2,OctagonXIcon:e2,Omega:pZ,OmegaIcon:pZ,Option:fZ,OptionIcon:fZ,Orbit:gZ,OrbitIcon:gZ,Origami:xZ,OrigamiIcon:xZ,Outdent:Hw,OutdentIcon:Hw,Package:mc,Package2:yZ,Package2Icon:yZ,PackageCheck:vZ,PackageCheckIcon:vZ,PackageIcon:mc,PackageMinus:_Z,PackageMinusIcon:_Z,PackageOpen:bZ,PackageOpenIcon:bZ,PackagePlus:wZ,PackagePlusIcon:wZ,PackageSearch:jZ,PackageSearchIcon:jZ,PackageX:kZ,PackageXIcon:kZ,PaintBucket:NZ,PaintBucketIcon:NZ,PaintRoller:SZ,PaintRollerIcon:SZ,Paintbrush:CZ,Paintbrush2:t2,Paintbrush2Icon:t2,PaintbrushIcon:CZ,PaintbrushVertical:t2,PaintbrushVerticalIcon:t2,Palette:hd,PaletteIcon:hd,Palmtree:yj,PalmtreeIcon:yj,PanelBottom:AZ,PanelBottomClose:MZ,PanelBottomCloseIcon:MZ,PanelBottomDashed:s2,PanelBottomDashedIcon:s2,PanelBottomIcon:AZ,PanelBottomInactive:s2,PanelBottomInactiveIcon:s2,PanelBottomOpen:TZ,PanelBottomOpenIcon:TZ,PanelLeft:i2,PanelLeftClose:r2,PanelLeftCloseIcon:r2,PanelLeftDashed:n2,PanelLeftDashedIcon:n2,PanelLeftIcon:i2,PanelLeftInactive:n2,PanelLeftInactiveIcon:n2,PanelLeftOpen:a2,PanelLeftOpenIcon:a2,PanelRight:PZ,PanelRightClose:EZ,PanelRightCloseIcon:EZ,PanelRightDashed:o2,PanelRightDashedIcon:o2,PanelRightIcon:PZ,PanelRightInactive:o2,PanelRightInactiveIcon:o2,PanelRightOpen:IZ,PanelRightOpenIcon:IZ,PanelTop:OZ,PanelTopClose:LZ,PanelTopCloseIcon:LZ,PanelTopDashed:l2,PanelTopDashedIcon:l2,PanelTopIcon:OZ,PanelTopInactive:l2,PanelTopInactiveIcon:l2,PanelTopOpen:DZ,PanelTopOpenIcon:DZ,PanelsLeftBottom:RZ,PanelsLeftBottomIcon:RZ,PanelsLeftRight:Nw,PanelsLeftRightIcon:Nw,PanelsRightBottom:FZ,PanelsRightBottomIcon:FZ,PanelsTopBottom:m2,PanelsTopBottomIcon:m2,PanelsTopLeft:Av,PanelsTopLeftIcon:Av,Paperclip:Mk,PaperclipIcon:Mk,Parentheses:zZ,ParenthesesIcon:zZ,ParkingCircle:dw,ParkingCircleIcon:dw,ParkingCircleOff:cw,ParkingCircleOffIcon:cw,ParkingMeter:BZ,ParkingMeterIcon:BZ,ParkingSquare:J2,ParkingSquareIcon:J2,ParkingSquareOff:Q2,ParkingSquareOffIcon:Q2,PartyPopper:md,PartyPopperIcon:md,Pause:ep,PauseCircle:uw,PauseCircleIcon:uw,PauseIcon:ep,PauseOctagon:Jw,PauseOctagonIcon:Jw,PawPrint:$Z,PawPrintIcon:$Z,PcCase:UZ,PcCaseIcon:UZ,Pen:Iv,PenBox:_c,PenBoxIcon:_c,PenIcon:Iv,PenLine:Ev,PenLineIcon:Ev,PenOff:qZ,PenOffIcon:qZ,PenSquare:_c,PenSquareIcon:_c,PenTool:Tk,PenToolIcon:Tk,Pencil:Xa,PencilIcon:Xa,PencilLine:VZ,PencilLineIcon:VZ,PencilOff:HZ,PencilOffIcon:HZ,PencilRuler:WZ,PencilRulerIcon:WZ,Pentagon:GZ,PentagonIcon:GZ,Percent:$4,PercentCircle:hw,PercentCircleIcon:hw,PercentDiamond:Cw,PercentDiamondIcon:Cw,PercentIcon:$4,PercentSquare:ej,PercentSquareIcon:ej,PersonStanding:KZ,PersonStandingIcon:KZ,PhilippinePeso:ZZ,PhilippinePesoIcon:ZZ,Phone:Ha,PhoneCall:YZ,PhoneCallIcon:YZ,PhoneForwarded:XZ,PhoneForwardedIcon:XZ,PhoneIcon:Ha,PhoneIncoming:QZ,PhoneIncomingIcon:QZ,PhoneMissed:JZ,PhoneMissedIcon:JZ,PhoneOff:eY,PhoneOffIcon:eY,PhoneOutgoing:tY,PhoneOutgoingIcon:tY,Pi:sY,PiIcon:sY,PiSquare:tj,PiSquareIcon:tj,Piano:rY,PianoIcon:rY,Pickaxe:nY,PickaxeIcon:nY,PictureInPicture:iY,PictureInPicture2:aY,PictureInPicture2Icon:aY,PictureInPictureIcon:iY,PieChart:Wb,PieChartIcon:Wb,PiggyBank:oY,PiggyBankIcon:oY,Pilcrow:dY,PilcrowIcon:dY,PilcrowLeft:lY,PilcrowLeftIcon:lY,PilcrowRight:cY,PilcrowRightIcon:cY,PilcrowSquare:sj,PilcrowSquareIcon:sj,Pill:hY,PillBottle:uY,PillBottleIcon:uY,PillIcon:hY,Pin:E1,PinIcon:E1,PinOff:RE,PinOffIcon:RE,Pipette:mY,PipetteIcon:mY,Pizza:pY,PizzaIcon:pY,Plane:xY,PlaneIcon:xY,PlaneLanding:fY,PlaneLandingIcon:fY,PlaneTakeoff:gY,PlaneTakeoffIcon:gY,Play:Kl,PlayCircle:Om,PlayCircleIcon:Om,PlayIcon:Kl,PlaySquare:rj,PlaySquareIcon:rj,Plug:FE,Plug2:yY,Plug2Icon:yY,PlugIcon:FE,PlugZap:c2,PlugZap2:c2,PlugZap2Icon:c2,PlugZapIcon:c2,Plus:ar,PlusCircle:mw,PlusCircleIcon:mw,PlusIcon:ar,PlusSquare:nj,PlusSquareIcon:nj,Pocket:_Y,PocketIcon:_Y,PocketKnife:vY,PocketKnifeIcon:vY,Podcast:bY,PodcastIcon:bY,Pointer:jY,PointerIcon:jY,PointerOff:wY,PointerOffIcon:wY,Popcorn:kY,PopcornIcon:kY,Popsicle:NY,PopsicleIcon:NY,PoundSterling:SY,PoundSterlingIcon:SY,Power:MY,PowerCircle:pw,PowerCircleIcon:pw,PowerIcon:MY,PowerOff:CY,PowerOffIcon:CY,PowerSquare:aj,PowerSquareIcon:aj,Presentation:Gp,PresentationIcon:Gp,Printer:zE,PrinterCheck:TY,PrinterCheckIcon:TY,PrinterIcon:zE,Projector:AY,ProjectorIcon:AY,Proportions:EY,ProportionsIcon:EY,Puzzle:IY,PuzzleIcon:IY,Pyramid:PY,PyramidIcon:PY,QrCode:Ak,QrCodeIcon:Ak,Quote:U4,QuoteIcon:U4,Rabbit:LY,RabbitIcon:LY,Radar:DY,RadarIcon:DY,Radiation:OY,RadiationIcon:OY,Radical:RY,RadicalIcon:RY,Radio:Ek,RadioIcon:Ek,RadioReceiver:FY,RadioReceiverIcon:FY,RadioTower:zY,RadioTowerIcon:zY,Radius:BY,RadiusIcon:BY,RailSymbol:$Y,RailSymbolIcon:$Y,Rainbow:UY,RainbowIcon:UY,Rat:qY,RatIcon:qY,Ratio:VY,RatioIcon:VY,Receipt:JY,ReceiptCent:HY,ReceiptCentIcon:HY,ReceiptEuro:WY,ReceiptEuroIcon:WY,ReceiptIcon:JY,ReceiptIndianRupee:GY,ReceiptIndianRupeeIcon:GY,ReceiptJapaneseYen:KY,ReceiptJapaneseYenIcon:KY,ReceiptPoundSterling:ZY,ReceiptPoundSterlingIcon:ZY,ReceiptRussianRuble:YY,ReceiptRussianRubleIcon:YY,ReceiptSwissFranc:XY,ReceiptSwissFrancIcon:XY,ReceiptText:QY,ReceiptTextIcon:QY,RectangleEllipsis:d2,RectangleEllipsisIcon:d2,RectangleHorizontal:eX,RectangleHorizontalIcon:eX,RectangleVertical:tX,RectangleVerticalIcon:tX,Recycle:sX,RecycleIcon:sX,Redo:q4,Redo2:rX,Redo2Icon:rX,RedoDot:nX,RedoDotIcon:nX,RedoIcon:q4,RefreshCcw:iX,RefreshCcwDot:aX,RefreshCcwDotIcon:aX,RefreshCcwIcon:iX,RefreshCw:el,RefreshCwIcon:el,RefreshCwOff:oX,RefreshCwOffIcon:oX,Refrigerator:lX,RefrigeratorIcon:lX,Regex:cX,RegexIcon:cX,RemoveFormatting:dX,RemoveFormattingIcon:dX,Repeat:BE,Repeat1:uX,Repeat1Icon:uX,Repeat2:hX,Repeat2Icon:hX,RepeatIcon:BE,Replace:pX,ReplaceAll:mX,ReplaceAllIcon:mX,ReplaceIcon:pX,Reply:$E,ReplyAll:fX,ReplyAllIcon:fX,ReplyIcon:$E,Rewind:gX,RewindIcon:gX,Ribbon:xX,RibbonIcon:xX,Rocket:Cx,RocketIcon:Cx,RockingChair:yX,RockingChairIcon:yX,RollerCoaster:vX,RollerCoasterIcon:vX,Rotate3D:u2,Rotate3DIcon:u2,Rotate3d:u2,Rotate3dIcon:u2,RotateCcw:Ik,RotateCcwIcon:Ik,RotateCcwSquare:_X,RotateCcwSquareIcon:_X,RotateCw:UE,RotateCwIcon:UE,RotateCwSquare:bX,RotateCwSquareIcon:bX,Route:jX,RouteIcon:jX,RouteOff:wX,RouteOffIcon:wX,Router:kX,RouterIcon:kX,Rows:h2,Rows2:h2,Rows2Icon:h2,Rows3:m2,Rows3Icon:m2,Rows4:NX,Rows4Icon:NX,RowsIcon:h2,Rss:SX,RssIcon:SX,Ruler:CX,RulerIcon:CX,RussianRuble:MX,RussianRubleIcon:MX,Sailboat:TX,SailboatIcon:TX,Salad:AX,SaladIcon:AX,Sandwich:EX,SandwichIcon:EX,Satellite:PX,SatelliteDish:IX,SatelliteDishIcon:IX,SatelliteIcon:PX,Save:um,SaveAll:LX,SaveAllIcon:LX,SaveIcon:um,SaveOff:DX,SaveOffIcon:DX,Scale:OX,Scale3D:p2,Scale3DIcon:p2,Scale3d:p2,Scale3dIcon:p2,ScaleIcon:OX,Scaling:RX,ScalingIcon:RX,Scan:HX,ScanBarcode:FX,ScanBarcodeIcon:FX,ScanEye:zX,ScanEyeIcon:zX,ScanFace:BX,ScanFaceIcon:BX,ScanIcon:HX,ScanLine:$X,ScanLineIcon:$X,ScanQrCode:UX,ScanQrCodeIcon:UX,ScanSearch:qX,ScanSearchIcon:qX,ScanText:VX,ScanTextIcon:VX,ScatterChart:Gb,ScatterChartIcon:Gb,School:WX,School2:_j,School2Icon:_j,SchoolIcon:WX,Scissors:KX,ScissorsIcon:KX,ScissorsLineDashed:GX,ScissorsLineDashedIcon:GX,ScissorsSquare:ij,ScissorsSquareDashedBottom:I2,ScissorsSquareDashedBottomIcon:I2,ScissorsSquareIcon:ij,ScreenShare:YX,ScreenShareIcon:YX,ScreenShareOff:ZX,ScreenShareOffIcon:ZX,Scroll:QX,ScrollIcon:QX,ScrollText:XX,ScrollTextIcon:XX,Search:On,SearchCheck:JX,SearchCheckIcon:JX,SearchCode:eQ,SearchCodeIcon:eQ,SearchIcon:On,SearchSlash:tQ,SearchSlashIcon:tQ,SearchX:sQ,SearchXIcon:sQ,Section:rQ,SectionIcon:rQ,Send:Wa,SendHorizonal:f2,SendHorizonalIcon:f2,SendHorizontal:f2,SendHorizontalIcon:f2,SendIcon:Wa,SendToBack:nQ,SendToBackIcon:nQ,SeparatorHorizontal:aQ,SeparatorHorizontalIcon:aQ,SeparatorVertical:iQ,SeparatorVerticalIcon:iQ,Server:dQ,ServerCog:oQ,ServerCogIcon:oQ,ServerCrash:lQ,ServerCrashIcon:lQ,ServerIcon:dQ,ServerOff:cQ,ServerOffIcon:cQ,Settings:Ic,Settings2:uQ,Settings2Icon:uQ,SettingsIcon:Ic,Shapes:hQ,ShapesIcon:hQ,Share:qE,Share2:Kc,Share2Icon:Kc,ShareIcon:qE,Sheet:mQ,SheetIcon:mQ,Shell:pQ,ShellIcon:pQ,Shield:Bu,ShieldAlert:fQ,ShieldAlertIcon:fQ,ShieldBan:gQ,ShieldBanIcon:gQ,ShieldCheck:VE,ShieldCheckIcon:VE,ShieldClose:g2,ShieldCloseIcon:g2,ShieldEllipsis:xQ,ShieldEllipsisIcon:xQ,ShieldHalf:yQ,ShieldHalfIcon:yQ,ShieldIcon:Bu,ShieldMinus:vQ,ShieldMinusIcon:vQ,ShieldOff:_Q,ShieldOffIcon:_Q,ShieldPlus:bQ,ShieldPlusIcon:bQ,ShieldQuestion:wQ,ShieldQuestionIcon:wQ,ShieldX:g2,ShieldXIcon:g2,Ship:kQ,ShipIcon:kQ,ShipWheel:jQ,ShipWheelIcon:jQ,Shirt:NQ,ShirtIcon:NQ,ShoppingBag:Mx,ShoppingBagIcon:Mx,ShoppingBasket:SQ,ShoppingBasketIcon:SQ,ShoppingCart:Jh,ShoppingCartIcon:Jh,Shovel:CQ,ShovelIcon:CQ,ShowerHead:MQ,ShowerHeadIcon:MQ,Shrink:TQ,ShrinkIcon:TQ,Shrub:AQ,ShrubIcon:AQ,Shuffle:EQ,ShuffleIcon:EQ,Sidebar:i2,SidebarClose:r2,SidebarCloseIcon:r2,SidebarIcon:i2,SidebarOpen:a2,SidebarOpenIcon:a2,Sigma:IQ,SigmaIcon:IQ,SigmaSquare:oj,SigmaSquareIcon:oj,Signal:RQ,SignalHigh:PQ,SignalHighIcon:PQ,SignalIcon:RQ,SignalLow:LQ,SignalLowIcon:LQ,SignalMedium:DQ,SignalMediumIcon:DQ,SignalZero:OQ,SignalZeroIcon:OQ,Signature:FQ,SignatureIcon:FQ,Signpost:BQ,SignpostBig:zQ,SignpostBigIcon:zQ,SignpostIcon:BQ,Siren:$Q,SirenIcon:$Q,SkipBack:UQ,SkipBackIcon:UQ,SkipForward:qQ,SkipForwardIcon:qQ,Skull:VQ,SkullIcon:VQ,Slack:HQ,SlackIcon:HQ,Slash:WQ,SlashIcon:WQ,SlashSquare:lj,SlashSquareIcon:lj,Slice:GQ,SliceIcon:GQ,Sliders:x2,SlidersHorizontal:HE,SlidersHorizontalIcon:HE,SlidersIcon:x2,SlidersVertical:x2,SlidersVerticalIcon:x2,Smartphone:n0,SmartphoneCharging:KQ,SmartphoneChargingIcon:KQ,SmartphoneIcon:n0,SmartphoneNfc:ZQ,SmartphoneNfcIcon:ZQ,Smile:XQ,SmileIcon:XQ,SmilePlus:YQ,SmilePlusIcon:YQ,Snail:QQ,SnailIcon:QQ,Snowflake:o1,SnowflakeIcon:o1,Sofa:JQ,SofaIcon:JQ,SortAsc:Cb,SortAscIcon:Cb,SortDesc:kb,SortDescIcon:kb,Soup:eJ,SoupIcon:eJ,Space:tJ,SpaceIcon:tJ,Spade:sJ,SpadeIcon:sJ,Sparkle:rJ,SparkleIcon:rJ,Sparkles:Sn,SparklesIcon:Sn,Speaker:nJ,SpeakerIcon:nJ,Speech:aJ,SpeechIcon:aJ,SpellCheck:oJ,SpellCheck2:iJ,SpellCheck2Icon:iJ,SpellCheckIcon:oJ,Spline:lJ,SplineIcon:lJ,Split:cJ,SplitIcon:cJ,SplitSquareHorizontal:cj,SplitSquareHorizontalIcon:cj,SplitSquareVertical:dj,SplitSquareVerticalIcon:dj,SprayCan:dJ,SprayCanIcon:dJ,Sprout:uJ,SproutIcon:uJ,Square:Tx,SquareActivity:y2,SquareActivityIcon:y2,SquareArrowDown:b2,SquareArrowDownIcon:b2,SquareArrowDownLeft:v2,SquareArrowDownLeftIcon:v2,SquareArrowDownRight:_2,SquareArrowDownRightIcon:_2,SquareArrowLeft:w2,SquareArrowLeftIcon:w2,SquareArrowOutDownLeft:j2,SquareArrowOutDownLeftIcon:j2,SquareArrowOutDownRight:k2,SquareArrowOutDownRightIcon:k2,SquareArrowOutUpLeft:N2,SquareArrowOutUpLeftIcon:N2,SquareArrowOutUpRight:S2,SquareArrowOutUpRightIcon:S2,SquareArrowRight:C2,SquareArrowRightIcon:C2,SquareArrowUp:A2,SquareArrowUpIcon:A2,SquareArrowUpLeft:M2,SquareArrowUpLeftIcon:M2,SquareArrowUpRight:T2,SquareArrowUpRightIcon:T2,SquareAsterisk:E2,SquareAsteriskIcon:E2,SquareBottomDashedScissors:I2,SquareBottomDashedScissorsIcon:I2,SquareChartGantt:sx,SquareChartGanttIcon:sx,SquareCheck:P2,SquareCheckBig:Oy,SquareCheckBigIcon:Oy,SquareCheckIcon:P2,SquareChevronDown:L2,SquareChevronDownIcon:L2,SquareChevronLeft:D2,SquareChevronLeftIcon:D2,SquareChevronRight:O2,SquareChevronRightIcon:O2,SquareChevronUp:R2,SquareChevronUpIcon:R2,SquareCode:F2,SquareCodeIcon:F2,SquareDashed:$2,SquareDashedBottom:mJ,SquareDashedBottomCode:hJ,SquareDashedBottomCodeIcon:hJ,SquareDashedBottomIcon:mJ,SquareDashedIcon:$2,SquareDashedKanban:z2,SquareDashedKanbanIcon:z2,SquareDashedMousePointer:B2,SquareDashedMousePointerIcon:B2,SquareDivide:U2,SquareDivideIcon:U2,SquareDot:q2,SquareDotIcon:q2,SquareEqual:V2,SquareEqualIcon:V2,SquareFunction:H2,SquareFunctionIcon:H2,SquareGanttChart:sx,SquareGanttChartIcon:sx,SquareIcon:Tx,SquareKanban:W2,SquareKanbanIcon:W2,SquareLibrary:G2,SquareLibraryIcon:G2,SquareM:K2,SquareMIcon:K2,SquareMenu:Z2,SquareMenuIcon:Z2,SquareMinus:Y2,SquareMinusIcon:Y2,SquareMousePointer:X2,SquareMousePointerIcon:X2,SquareParking:J2,SquareParkingIcon:J2,SquareParkingOff:Q2,SquareParkingOffIcon:Q2,SquarePen:_c,SquarePenIcon:_c,SquarePercent:ej,SquarePercentIcon:ej,SquarePi:tj,SquarePiIcon:tj,SquarePilcrow:sj,SquarePilcrowIcon:sj,SquarePlay:rj,SquarePlayIcon:rj,SquarePlus:nj,SquarePlusIcon:nj,SquarePower:aj,SquarePowerIcon:aj,SquareRadical:pJ,SquareRadicalIcon:pJ,SquareScissors:ij,SquareScissorsIcon:ij,SquareSigma:oj,SquareSigmaIcon:oj,SquareSlash:lj,SquareSlashIcon:lj,SquareSplitHorizontal:cj,SquareSplitHorizontalIcon:cj,SquareSplitVertical:dj,SquareSplitVerticalIcon:dj,SquareSquare:fJ,SquareSquareIcon:fJ,SquareStack:gJ,SquareStackIcon:gJ,SquareTerminal:uj,SquareTerminalIcon:uj,SquareUser:mj,SquareUserIcon:mj,SquareUserRound:hj,SquareUserRoundIcon:hj,SquareX:pj,SquareXIcon:pj,Squircle:xJ,SquircleIcon:xJ,Squirrel:yJ,SquirrelIcon:yJ,Stamp:vJ,StampIcon:vJ,Star:qn,StarHalf:_J,StarHalfIcon:_J,StarIcon:qn,StarOff:bJ,StarOffIcon:bJ,Stars:Sn,StarsIcon:Sn,StepBack:wJ,StepBackIcon:wJ,StepForward:jJ,StepForwardIcon:jJ,Stethoscope:kJ,StethoscopeIcon:kJ,Sticker:NJ,StickerIcon:NJ,StickyNote:SJ,StickyNoteIcon:SJ,StopCircle:gw,StopCircleIcon:gw,Store:CJ,StoreIcon:CJ,StretchHorizontal:MJ,StretchHorizontalIcon:MJ,StretchVertical:TJ,StretchVerticalIcon:TJ,Strikethrough:AJ,StrikethroughIcon:AJ,Subscript:EJ,SubscriptIcon:EJ,Subtitles:Db,SubtitlesIcon:Db,Sun:I1,SunDim:IJ,SunDimIcon:IJ,SunIcon:I1,SunMedium:PJ,SunMediumIcon:PJ,SunMoon:LJ,SunMoonIcon:LJ,SunSnow:DJ,SunSnowIcon:DJ,Sunrise:OJ,SunriseIcon:OJ,Sunset:RJ,SunsetIcon:RJ,Superscript:FJ,SuperscriptIcon:FJ,SwatchBook:zJ,SwatchBookIcon:zJ,SwissFranc:BJ,SwissFrancIcon:BJ,SwitchCamera:$J,SwitchCameraIcon:$J,Sword:UJ,SwordIcon:UJ,Swords:qJ,SwordsIcon:qJ,Syringe:VJ,SyringeIcon:VJ,Table:WE,Table2:V4,Table2Icon:V4,TableCellsMerge:HJ,TableCellsMergeIcon:HJ,TableCellsSplit:WJ,TableCellsSplitIcon:WJ,TableColumnsSplit:GJ,TableColumnsSplitIcon:GJ,TableIcon:WE,TableOfContents:KJ,TableOfContentsIcon:KJ,TableProperties:ZJ,TablePropertiesIcon:ZJ,TableRowsSplit:YJ,TableRowsSplitIcon:YJ,Tablet:QJ,TabletIcon:QJ,TabletSmartphone:XJ,TabletSmartphoneIcon:XJ,Tablets:JJ,TabletsIcon:JJ,Tag:Kp,TagIcon:Kp,Tags:eee,TagsIcon:eee,Tally1:tee,Tally1Icon:tee,Tally2:see,Tally2Icon:see,Tally3:ree,Tally3Icon:ree,Tally4:nee,Tally4Icon:nee,Tally5:aee,Tally5Icon:aee,Tangent:iee,TangentIcon:iee,Target:hm,TargetIcon:hm,Telescope:oee,TelescopeIcon:oee,Tent:cee,TentIcon:cee,TentTree:lee,TentTreeIcon:lee,Terminal:dee,TerminalIcon:dee,TerminalSquare:uj,TerminalSquareIcon:uj,TestTube:uee,TestTube2:fj,TestTube2Icon:fj,TestTubeDiagonal:fj,TestTubeDiagonalIcon:fj,TestTubeIcon:uee,TestTubes:hee,TestTubesIcon:hee,Text:xee,TextCursor:pee,TextCursorIcon:pee,TextCursorInput:mee,TextCursorInputIcon:mee,TextIcon:xee,TextQuote:fee,TextQuoteIcon:fee,TextSearch:gee,TextSearchIcon:gee,TextSelect:gj,TextSelectIcon:gj,TextSelection:gj,TextSelectionIcon:gj,Theater:yee,TheaterIcon:yee,Thermometer:bee,ThermometerIcon:bee,ThermometerSnowflake:vee,ThermometerSnowflakeIcon:vee,ThermometerSun:_ee,ThermometerSunIcon:_ee,ThumbsDown:GE,ThumbsDownIcon:GE,ThumbsUp:Ed,ThumbsUpIcon:Ed,Ticket:KE,TicketCheck:wee,TicketCheckIcon:wee,TicketIcon:KE,TicketMinus:jee,TicketMinusIcon:jee,TicketPercent:kee,TicketPercentIcon:kee,TicketPlus:Nee,TicketPlusIcon:Nee,TicketSlash:See,TicketSlashIcon:See,TicketX:Cee,TicketXIcon:Cee,Tickets:Tee,TicketsIcon:Tee,TicketsPlane:Mee,TicketsPlaneIcon:Mee,Timer:Iee,TimerIcon:Iee,TimerOff:Aee,TimerOffIcon:Aee,TimerReset:Eee,TimerResetIcon:Eee,ToggleLeft:Pee,ToggleLeftIcon:Pee,ToggleRight:Lee,ToggleRightIcon:Lee,Toilet:Dee,ToiletIcon:Dee,Tornado:Oee,TornadoIcon:Oee,Torus:Ree,TorusIcon:Ree,Touchpad:zee,TouchpadIcon:zee,TouchpadOff:Fee,TouchpadOffIcon:Fee,TowerControl:Bee,TowerControlIcon:Bee,ToyBrick:$ee,ToyBrickIcon:$ee,Tractor:Uee,TractorIcon:Uee,TrafficCone:qee,TrafficConeIcon:qee,Train:xj,TrainFront:Hee,TrainFrontIcon:Hee,TrainFrontTunnel:Vee,TrainFrontTunnelIcon:Vee,TrainIcon:xj,TrainTrack:Wee,TrainTrackIcon:Wee,TramFront:xj,TramFrontIcon:xj,Trash:Gee,Trash2:Ir,Trash2Icon:Ir,TrashIcon:Gee,TreeDeciduous:Kee,TreeDeciduousIcon:Kee,TreePalm:yj,TreePalmIcon:yj,TreePine:P1,TreePineIcon:P1,Trees:Zee,TreesIcon:Zee,Trello:Yee,TrelloIcon:Yee,TrendingDown:Pk,TrendingDownIcon:Pk,TrendingUp:Jd,TrendingUpDown:Xee,TrendingUpDownIcon:Xee,TrendingUpIcon:Jd,Triangle:Jee,TriangleAlert:Lu,TriangleAlertIcon:Lu,TriangleIcon:Jee,TriangleRight:Qee,TriangleRightIcon:Qee,Trophy:vo,TrophyIcon:vo,Truck:ZE,TruckIcon:ZE,Turtle:ete,TurtleIcon:ete,Tv:ste,Tv2:vj,Tv2Icon:vj,TvIcon:ste,TvMinimal:vj,TvMinimalIcon:vj,TvMinimalPlay:tte,TvMinimalPlayIcon:tte,Twitch:rte,TwitchIcon:rte,Twitter:nte,TwitterIcon:nte,Type:ite,TypeIcon:ite,TypeOutline:ate,TypeOutlineIcon:ate,Umbrella:lte,UmbrellaIcon:lte,UmbrellaOff:ote,UmbrellaOffIcon:ote,Underline:cte,UnderlineIcon:cte,Undo:H4,Undo2:dte,Undo2Icon:dte,UndoDot:ute,UndoDotIcon:ute,UndoIcon:H4,UnfoldHorizontal:hte,UnfoldHorizontalIcon:hte,UnfoldVertical:mte,UnfoldVerticalIcon:mte,Ungroup:pte,UngroupIcon:pte,University:_j,UniversityIcon:_j,Unlink:YE,Unlink2:fte,Unlink2Icon:fte,UnlinkIcon:YE,Unlock:Zw,UnlockIcon:Zw,UnlockKeyhole:Kw,UnlockKeyholeIcon:Kw,Unplug:gte,UnplugIcon:gte,Upload:ji,UploadCloud:ww,UploadCloudIcon:ww,UploadIcon:ji,Usb:xte,UsbIcon:xte,User:Wo,User2:Sj,User2Icon:Sj,UserCheck:Lk,UserCheck2:bj,UserCheck2Icon:bj,UserCheckIcon:Lk,UserCircle:yw,UserCircle2:xw,UserCircle2Icon:xw,UserCircleIcon:yw,UserCog:XE,UserCog2:wj,UserCog2Icon:wj,UserCogIcon:XE,UserIcon:Wo,UserMinus:QE,UserMinus2:jj,UserMinus2Icon:jj,UserMinusIcon:QE,UserPen:yte,UserPenIcon:yte,UserPlus:Zc,UserPlus2:kj,UserPlus2Icon:kj,UserPlusIcon:Zc,UserRound:Sj,UserRoundCheck:bj,UserRoundCheckIcon:bj,UserRoundCog:wj,UserRoundCogIcon:wj,UserRoundIcon:Sj,UserRoundMinus:jj,UserRoundMinusIcon:jj,UserRoundPen:vte,UserRoundPenIcon:vte,UserRoundPlus:kj,UserRoundPlusIcon:kj,UserRoundSearch:_te,UserRoundSearchIcon:_te,UserRoundX:Nj,UserRoundXIcon:Nj,UserSearch:bte,UserSearchIcon:bte,UserSquare:mj,UserSquare2:hj,UserSquare2Icon:hj,UserSquareIcon:mj,UserX:wte,UserX2:Nj,UserX2Icon:Nj,UserXIcon:wte,Users:br,Users2:Cj,Users2Icon:Cj,UsersIcon:br,UsersRound:Cj,UsersRoundIcon:Cj,Utensils:Tj,UtensilsCrossed:Mj,UtensilsCrossedIcon:Mj,UtensilsIcon:Tj,UtilityPole:jte,UtilityPoleIcon:jte,Variable:JE,VariableIcon:JE,Vault:kte,VaultIcon:kte,Vegan:Nte,VeganIcon:Nte,VenetianMask:Ste,VenetianMaskIcon:Ste,Verified:Ab,VerifiedIcon:Ab,Vibrate:Mte,VibrateIcon:Mte,VibrateOff:Cte,VibrateOffIcon:Cte,Video:Wn,VideoIcon:Wn,VideoOff:Tte,VideoOffIcon:Tte,Videotape:Ate,VideotapeIcon:Ate,View:Ete,ViewIcon:Ete,Voicemail:Ite,VoicemailIcon:Ite,Volleyball:Pte,VolleyballIcon:Pte,Volume:Fte,Volume1:Lte,Volume1Icon:Lte,Volume2:Dte,Volume2Icon:Dte,VolumeIcon:Fte,VolumeOff:Ote,VolumeOffIcon:Ote,VolumeX:Rte,VolumeXIcon:Rte,Vote:zte,VoteIcon:zte,Wallet:$te,Wallet2:Aj,Wallet2Icon:Aj,WalletCards:Bte,WalletCardsIcon:Bte,WalletIcon:$te,WalletMinimal:Aj,WalletMinimalIcon:Aj,Wallpaper:Ute,WallpaperIcon:Ute,Wand:qte,Wand2:Ej,Wand2Icon:Ej,WandIcon:qte,WandSparkles:Ej,WandSparklesIcon:Ej,Warehouse:Vte,WarehouseIcon:Vte,WashingMachine:Hte,WashingMachineIcon:Hte,Watch:Wte,WatchIcon:Wte,Waves:Gte,WavesIcon:Gte,Waypoints:Kte,WaypointsIcon:Kte,Webcam:Zte,WebcamIcon:Zte,Webhook:Xte,WebhookIcon:Xte,WebhookOff:Yte,WebhookOffIcon:Yte,Weight:Qte,WeightIcon:Qte,Wheat:ese,WheatIcon:ese,WheatOff:Jte,WheatOffIcon:Jte,WholeWord:tse,WholeWordIcon:tse,Wifi:ise,WifiHigh:sse,WifiHighIcon:sse,WifiIcon:ise,WifiLow:rse,WifiLowIcon:rse,WifiOff:nse,WifiOffIcon:nse,WifiZero:ase,WifiZeroIcon:ase,Wind:lse,WindArrowDown:ose,WindArrowDownIcon:ose,WindIcon:lse,Wine:dse,WineIcon:dse,WineOff:cse,WineOffIcon:cse,Workflow:use,WorkflowIcon:use,Worm:hse,WormIcon:hse,WrapText:mse,WrapTextIcon:mse,Wrench:a0,WrenchIcon:a0,X:Xr,XCircle:Cc,XCircleIcon:Cc,XIcon:Xr,XOctagon:e2,XOctagonIcon:e2,XSquare:pj,XSquareIcon:pj,Youtube:pse,YoutubeIcon:pse,Zap:Ax,ZapIcon:Ax,ZapOff:fse,ZapOffIcon:fse,ZoomIn:W4,ZoomInIcon:W4,ZoomOut:G4,ZoomOutIcon:G4,createLucideIcon:H,icons:uat},Symbol.toStringTag,{value:"Module"})),J0e="-",hat=t=>{const s=pat(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(J0e);return i[0]===""&&i.length!==1&&i.shift(),AOe(i,s)||mat(l)},getConflictingClassGroupIds:(l,i)=>{const d=r[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},AOe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?AOe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(J0e);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},ZSe=/^\[(.+)\]$/,mat=t=>{if(ZSe.test(t)){const s=ZSe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},pat=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return gat(Object.entries(t.classGroups),r).forEach(([o,l])=>{zpe(l,n,o,s)}),n},zpe=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:YSe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(fat(a)){zpe(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{zpe(l,YSe(s,o),r,n)})})},YSe=(t,s)=>{let r=t;return s.split(J0e).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},fat=t=>t.isThemeGetter,gat=(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,xat=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)}}},EOe="!",yat=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const d=[];let h=0,f=0,g;for(let k=0;kf?g-f:void 0;return{modifiers:d,hasImportantModifier:_,baseClassName:j,maybePostfixModifierPosition:w}};return r?i=>r({className:i,parseClassName:l}):l},vat=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},_at=t=>({cache:xat(t.cacheSize),parseClassName:yat(t),...hat(t)}),bat=/\s+/,wat=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(bat);let i="";for(let d=l.length-1;d>=0;d-=1){const h=l[d],{modifiers:f,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:_}=r(h);let j=!!_,w=n(j?v.substring(0,_):v);if(!w){if(!j){i=h+(i.length>0?" "+i:i);continue}if(w=n(v),!w){i=h+(i.length>0?" "+i:i);continue}j=!1}const k=vat(f).join(":"),M=g?k+EOe:k,S=M+w;if(o.includes(S))continue;o.push(S);const E=a(w,j);for(let D=0;D0?" "+i:i)}return i};function jat(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;ng(f),t());return r=_at(h),n=r.cache.get,a=r.cache.set,o=i,i(d)}function i(d){const h=n(d);if(h)return h;const f=wat(d,r);return a(d,f),f}return function(){return o(jat.apply(null,arguments))}}const Cl=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},POe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Nat=/^\d+\/\d+$/,Sat=new Set(["px","full","screen"]),Cat=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Mat=/\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$/,Tat=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Aat=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Eat=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_y=t=>K4(t)||Sat.has(t)||Nat.test(t),gv=t=>T3(t,"length",zat),K4=t=>!!t&&!Number.isNaN(Number(t)),_ue=t=>T3(t,"number",K4),fA=t=>!!t&&Number.isInteger(Number(t)),Iat=t=>t.endsWith("%")&&K4(t.slice(0,-1)),Mi=t=>POe.test(t),xv=t=>Cat.test(t),Pat=new Set(["length","size","percentage"]),Lat=t=>T3(t,Pat,LOe),Dat=t=>T3(t,"position",LOe),Oat=new Set(["image","url"]),Rat=t=>T3(t,Oat,$at),Fat=t=>T3(t,"",Bat),gA=()=>!0,T3=(t,s,r)=>{const n=POe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},zat=t=>Mat.test(t)&&!Tat.test(t),LOe=()=>!1,Bat=t=>Aat.test(t),$at=t=>Eat.test(t),Uat=()=>{const t=Cl("colors"),s=Cl("spacing"),r=Cl("blur"),n=Cl("brightness"),a=Cl("borderColor"),o=Cl("borderRadius"),l=Cl("borderSpacing"),i=Cl("borderWidth"),d=Cl("contrast"),h=Cl("grayscale"),f=Cl("hueRotate"),g=Cl("invert"),v=Cl("gap"),_=Cl("gradientColorStops"),j=Cl("gradientColorStopPositions"),w=Cl("inset"),k=Cl("margin"),M=Cl("opacity"),S=Cl("padding"),E=Cl("saturate"),D=Cl("scale"),L=Cl("sepia"),B=Cl("skew"),$=Cl("space"),V=Cl("translate"),W=()=>["auto","contain","none"],G=()=>["auto","hidden","clip","visible","scroll"],J=()=>["auto",Mi,s],ne=()=>[Mi,s],ie=()=>["",_y,gv],ee=()=>["auto",K4,Mi],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],oe=()=>["solid","dashed","dotted","double","none"],ue=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>["start","end","center","between","around","evenly","stretch"],ge=()=>["","0",Mi],Te=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ve=()=>[K4,Mi];return{cacheSize:500,separator:":",theme:{colors:[gA],spacing:[_y,gv],blur:["none","",xv,Mi],brightness:ve(),borderColor:[t],borderRadius:["none","","full",xv,Mi],borderSpacing:ne(),borderWidth:ie(),contrast:ve(),grayscale:ge(),hueRotate:ve(),invert:ge(),gap:ne(),gradientColorStops:[t],gradientColorStopPositions:[Iat,gv],inset:J(),margin:J(),opacity:ve(),padding:ne(),saturate:ve(),scale:ve(),sepia:ge(),skew:ve(),space:ne(),translate:ne()},classGroups:{aspect:[{aspect:["auto","square","video",Mi]}],container:["container"],columns:[{columns:[xv]}],"break-after":[{"break-after":Te()}],"break-before":[{"break-before":Te()}],"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(),Mi]}],overflow:[{overflow:G()}],"overflow-x":[{"overflow-x":G()}],"overflow-y":[{"overflow-y":G()}],overscroll:[{overscroll:W()}],"overscroll-x":[{"overscroll-x":W()}],"overscroll-y":[{"overscroll-y":W()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",fA,Mi]}],basis:[{basis:J()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Mi]}],grow:[{grow:ge()}],shrink:[{shrink:ge()}],order:[{order:["first","last","none",fA,Mi]}],"grid-cols":[{"grid-cols":[gA]}],"col-start-end":[{col:["auto",{span:["full",fA,Mi]},Mi]}],"col-start":[{"col-start":ee()}],"col-end":[{"col-end":ee()}],"grid-rows":[{"grid-rows":[gA]}],"row-start-end":[{row:["auto",{span:[fA,Mi]},Mi]}],"row-start":[{"row-start":ee()}],"row-end":[{"row-end":ee()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Mi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Mi]}],gap:[{gap:[v]}],"gap-x":[{"gap-x":[v]}],"gap-y":[{"gap-y":[v]}],"justify-content":[{justify:["normal",...ce()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ce(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ce(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[k]}],mx:[{mx:[k]}],my:[{my:[k]}],ms:[{ms:[k]}],me:[{me:[k]}],mt:[{mt:[k]}],mr:[{mr:[k]}],mb:[{mb:[k]}],ml:[{ml:[k]}],"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",Mi,s]}],"min-w":[{"min-w":[Mi,s,"min","max","fit"]}],"max-w":[{"max-w":[Mi,s,"none","full","min","max","fit","prose",{screen:[xv]},xv]}],h:[{h:[Mi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Mi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Mi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Mi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",xv,gv]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",_ue]}],"font-family":[{font:[gA]}],"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",Mi]}],"line-clamp":[{"line-clamp":["none",K4,_ue]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",_y,Mi]}],"list-image":[{"list-image":["none",Mi]}],"list-style-type":[{list:["none","disc","decimal",Mi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[M]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[M]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",_y,gv]}],"underline-offset":[{"underline-offset":["auto",_y,Mi]}],"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:ne()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Mi]}],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",Mi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[M]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...de(),Dat]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Lat]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Rat]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[j]}],"gradient-via-pos":[{via:[j]}],"gradient-to-pos":[{to:[j]}],"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":[M]}],"border-style":[{border:[...oe(),"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":[M]}],"divide-style":[{divide:oe()}],"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:["",...oe()]}],"outline-offset":[{"outline-offset":[_y,Mi]}],"outline-w":[{outline:[_y,gv]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:ie()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[M]}],"ring-offset-w":[{"ring-offset":[_y,gv]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",xv,Fat]}],"shadow-color":[{shadow:[gA]}],opacity:[{opacity:[M]}],"mix-blend":[{"mix-blend":[...ue(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ue()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",xv,Mi]}],grayscale:[{grayscale:[h]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[g]}],saturate:[{saturate:[E]}],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":[h]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[M]}],"backdrop-saturate":[{"backdrop-saturate":[E]}],"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",Mi]}],duration:[{duration:ve()}],ease:[{ease:["linear","in","out","in-out",Mi]}],delay:[{delay:ve()}],animate:[{animate:["none","spin","ping","pulse","bounce",Mi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[D]}],"scale-x":[{"scale-x":[D]}],"scale-y":[{"scale-y":[D]}],rotate:[{rotate:[fA,Mi]}],"translate-x":[{"translate-x":[V]}],"translate-y":[{"translate-y":[V]}],"skew-x":[{"skew-x":[B]}],"skew-y":[{"skew-y":[B]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Mi]}],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",Mi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":ne()}],"scroll-mx":[{"scroll-mx":ne()}],"scroll-my":[{"scroll-my":ne()}],"scroll-ms":[{"scroll-ms":ne()}],"scroll-me":[{"scroll-me":ne()}],"scroll-mt":[{"scroll-mt":ne()}],"scroll-mr":[{"scroll-mr":ne()}],"scroll-mb":[{"scroll-mb":ne()}],"scroll-ml":[{"scroll-ml":ne()}],"scroll-p":[{"scroll-p":ne()}],"scroll-px":[{"scroll-px":ne()}],"scroll-py":[{"scroll-py":ne()}],"scroll-ps":[{"scroll-ps":ne()}],"scroll-pe":[{"scroll-pe":ne()}],"scroll-pt":[{"scroll-pt":ne()}],"scroll-pr":[{"scroll-pr":ne()}],"scroll-pb":[{"scroll-pb":ne()}],"scroll-pl":[{"scroll-pl":ne()}],"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",Mi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[_y,gv,_ue]}],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"]}}},qat=kat(Uat);function $t(...t){return qat(Ai(t))}function fu(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 XSe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function pie(t){return t?t.replace(/<[^>]*>/g,""):""}const Vat=lat,DOe=T.forwardRef(({className:t,...s},r)=>e.jsx(_Oe,{ref:r,className:$t("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}));DOe.displayName=_Oe.displayName;const Hat=M3("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"}}),OOe=T.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(bOe,{ref:n,className:$t(Hat({variant:s}),t),...r}));OOe.displayName=bOe.displayName;const Wat=T.forwardRef(({className:t,...s},r)=>e.jsx(kOe,{ref:r,className:$t("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}));Wat.displayName=kOe.displayName;const ROe=T.forwardRef(({className:t,...s},r)=>e.jsx(NOe,{ref:r,className:$t("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(Xr,{className:"h-4 w-4"})}));ROe.displayName=NOe.displayName;const FOe=T.forwardRef(({className:t,...s},r)=>e.jsx(wOe,{ref:r,className:$t("text-sm font-semibold",t),...s}));FOe.displayName=wOe.displayName;const zOe=T.forwardRef(({className:t,...s},r)=>e.jsx(jOe,{ref:r,className:$t("text-sm opacity-90",t),...s}));zOe.displayName=jOe.displayName;function Gat(){const{toasts:t}=Sa();return e.jsxs(Vat,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(OOe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(FOe,{children:r}),n&&e.jsx(zOe,{children:n})]}),a,e.jsx(ROe,{})]},s)}),e.jsx(DOe,{})]})}var QSe=["light","dark"],Kat="(prefers-color-scheme: dark)",Zat=T.createContext(void 0),Yat={setTheme:t=>{},themes:[]},Xat=()=>{var t;return(t=T.useContext(Zat))!=null?t:Yat};T.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:d})=>{let h=o==="system",f=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(j=>`'${j}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,g=a?QSe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",v=(j,w=!1,k=!0)=>{let M=l?l[j]:j,S=w?j+"|| ''":`'${M}'`,E="";return a&&k&&!w&&QSe.includes(j)&&(E+=`d.style.colorScheme = '${j}';`),r==="class"?w||M?E+=`c.add(${S})`:E+="null":M&&(E+=`d[s](n,${S})`),E},_=t?`!function(){${f}${v(t)}}()`:n?`!function(){try{${f}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${h})){var t='${Kat}',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)}}${h?"":"else{"+v(o,!1,!1)+"}"}${g}}catch(e){}}()`:`!function(){try{${f}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 T.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var Qat=t=>{switch(t){case"success":return tit;case"info":return rit;case"warning":return sit;case"error":return nit;default:return null}},Jat=Array(12).fill(0),eit=({visible:t,className:s})=>lt.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},lt.createElement("div",{className:"sonner-spinner"},Jat.map((r,n)=>lt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),tit=lt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},lt.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"})),sit=lt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},lt.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"})),rit=lt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},lt.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"})),nit=lt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},lt.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"})),ait=lt.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"},lt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),lt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),iit=()=>{let[t,s]=lt.useState(document.hidden);return lt.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Bpe=1,oit=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:Bpe++,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],lt.isValidElement(d))a=!1,this.create({id:r,type:"default",message:d});else if(cit(d)&&!d.ok){a=!1;let h=typeof s.error=="function"?await s.error(`HTTP error! status: ${d.status}`):s.error,f=typeof s.description=="function"?await s.description(`HTTP error! status: ${d.status}`):s.description;this.create({id:r,type:"error",message:h,description:f})}else if(s.success!==void 0){a=!1;let h=typeof s.success=="function"?await s.success(d):s.success,f=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"success",message:h,description:f})}}).catch(async d=>{if(o=["reject",d],s.error!==void 0){a=!1;let h=typeof s.error=="function"?await s.error(d):s.error,f=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"error",message:h,description:f})}}).finally(()=>{var d;a&&(this.dismiss(r),r=void 0),(d=s.finally)==null||d.call(s)}),i=()=>new Promise((d,h)=>l.then(()=>o[0]==="reject"?h(o[1]):d(o[1])).catch(h));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)||Bpe++;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}},Gh=new oit,lit=(t,s)=>{let r=(s==null?void 0:s.id)||Bpe++;return Gh.addToast({title:t,...s,id:r}),r},cit=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",dit=lit,uit=()=>Gh.toasts,hit=()=>Gh.getActiveToasts(),be=Object.assign(dit,{success:Gh.success,info:Gh.info,warning:Gh.warning,error:Gh.error,custom:Gh.custom,message:Gh.message,promise:Gh.promise,dismiss:Gh.dismiss,loading:Gh.loading},{getHistory:uit,getToasts:hit});function mit(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))}mit(`: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 MO(t){return t.label!==void 0}var pit=3,fit="32px",git="16px",JSe=4e3,xit=356,yit=14,vit=20,_it=200;function Rf(...t){return t.filter(Boolean).join(" ")}function bit(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var wit=t=>{var s,r,n,a,o,l,i,d,h,f,g;let{invert:v,toast:_,unstyled:j,interacting:w,setHeights:k,visibleToasts:M,heights:S,index:E,toasts:D,expanded:L,removeToast:B,defaultRichColors:$,closeButton:V,style:W,cancelButtonStyle:G,actionButtonStyle:J,className:ne="",descriptionClassName:ie="",duration:ee,position:de,gap:oe,loadingIcon:ue,expandByDefault:ce,classNames:ge,icons:Te,closeButtonAriaLabel:ve="Close toast",pauseWhenPageIsHidden:ye}=t,[Se,Ke]=lt.useState(null),[Ae,Ee]=lt.useState(null),[He,Ue]=lt.useState(!1),[De,Ge]=lt.useState(!1),[wt,Ie]=lt.useState(!1),[st,he]=lt.useState(!1),[We,et]=lt.useState(!1),[Ye,ke]=lt.useState(0),[at,Fe]=lt.useState(0),it=lt.useRef(_.duration||ee||JSe),dt=lt.useRef(null),tt=lt.useRef(null),ut=E===0,xt=E+1<=M,_t=_.type,qe=_.dismissible!==!1,Lt=_.className||"",Rt=_.descriptionClassName||"",Kt=lt.useMemo(()=>S.findIndex(lr=>lr.toastId===_.id)||0,[S,_.id]),Xt=lt.useMemo(()=>{var lr;return(lr=_.closeButton)!=null?lr:V},[_.closeButton,V]),ss=lt.useMemo(()=>_.duration||ee||JSe,[_.duration,ee]),fs=lt.useRef(0),fr=lt.useRef(0),yt=lt.useRef(0),bs=lt.useRef(null),[gr,Br]=de.split("-"),na=lt.useMemo(()=>S.reduce((lr,Vr,Pr)=>Pr>=Kt?lr:lr+Vr.height,0),[S,Kt]),za=iit(),go=_.invert||v,Ia=_t==="loading";fr.current=lt.useMemo(()=>Kt*oe+na,[Kt,na]),lt.useEffect(()=>{it.current=ss},[ss]),lt.useEffect(()=>{Ue(!0)},[]),lt.useEffect(()=>{let lr=tt.current;if(lr){let Vr=lr.getBoundingClientRect().height;return Fe(Vr),k(Pr=>[{toastId:_.id,height:Vr,position:_.position},...Pr]),()=>k(Pr=>Pr.filter(on=>on.toastId!==_.id))}},[k,_.id]),lt.useLayoutEffect(()=>{if(!He)return;let lr=tt.current,Vr=lr.style.height;lr.style.height="auto";let Pr=lr.getBoundingClientRect().height;lr.style.height=Vr,Fe(Pr),k(on=>on.find(cs=>cs.toastId===_.id)?on.map(cs=>cs.toastId===_.id?{...cs,height:Pr}:cs):[{toastId:_.id,height:Pr,position:_.position},...on])},[He,_.title,_.description,k,_.id]);let nn=lt.useCallback(()=>{Ge(!0),ke(fr.current),k(lr=>lr.filter(Vr=>Vr.toastId!==_.id)),setTimeout(()=>{B(_)},_it)},[_,B,k,fr]);lt.useEffect(()=>{if(_.promise&&_t==="loading"||_.duration===1/0||_.type==="loading")return;let lr;return L||w||ye&&za?(()=>{if(yt.current{var Vr;(Vr=_.onAutoClose)==null||Vr.call(_,_),nn()},it.current)),()=>clearTimeout(lr)},[L,w,_,_t,ye,za,nn]),lt.useEffect(()=>{_.delete&&nn()},[nn,_.delete]);function Qt(){var lr,Vr,Pr;return Te!=null&&Te.loading?lt.createElement("div",{className:Rf(ge==null?void 0:ge.loader,(lr=_==null?void 0:_.classNames)==null?void 0:lr.loader,"sonner-loader"),"data-visible":_t==="loading"},Te.loading):ue?lt.createElement("div",{className:Rf(ge==null?void 0:ge.loader,(Vr=_==null?void 0:_.classNames)==null?void 0:Vr.loader,"sonner-loader"),"data-visible":_t==="loading"},ue):lt.createElement(eit,{className:Rf(ge==null?void 0:ge.loader,(Pr=_==null?void 0:_.classNames)==null?void 0:Pr.loader),visible:_t==="loading"})}return lt.createElement("li",{tabIndex:0,ref:tt,className:Rf(ne,Lt,ge==null?void 0:ge.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,ge==null?void 0:ge.default,ge==null?void 0:ge[_t],(r=_==null?void 0:_.classNames)==null?void 0:r[_t]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:$,"data-styled":!(_.jsx||_.unstyled||j),"data-mounted":He,"data-promise":!!_.promise,"data-swiped":We,"data-removed":De,"data-visible":xt,"data-y-position":gr,"data-x-position":Br,"data-index":E,"data-front":ut,"data-swiping":wt,"data-dismissible":qe,"data-type":_t,"data-invert":go,"data-swipe-out":st,"data-swipe-direction":Ae,"data-expanded":!!(L||ce&&He),style:{"--index":E,"--toasts-before":E,"--z-index":D.length-E,"--offset":`${De?Ye:fr.current}px`,"--initial-height":ce?"auto":`${at}px`,...W,..._.style},onDragEnd:()=>{Ie(!1),Ke(null),bs.current=null},onPointerDown:lr=>{Ia||!qe||(dt.current=new Date,ke(fr.current),lr.target.setPointerCapture(lr.pointerId),lr.target.tagName!=="BUTTON"&&(Ie(!0),bs.current={x:lr.clientX,y:lr.clientY}))},onPointerUp:()=>{var lr,Vr,Pr,on;if(st||!qe)return;bs.current=null;let cs=Number(((lr=tt.current)==null?void 0:lr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ka=Number(((Vr=tt.current)==null?void 0:Vr.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),zi=new Date().getTime()-((Pr=dt.current)==null?void 0:Pr.getTime()),li=Se==="x"?cs:ka,Or=Math.abs(li)/zi;if(Math.abs(li)>=vit||Or>.11){ke(fr.current),(on=_.onDismiss)==null||on.call(_,_),Ee(Se==="x"?cs>0?"right":"left":ka>0?"down":"up"),nn(),he(!0),et(!1);return}Ie(!1),Ke(null)},onPointerMove:lr=>{var Vr,Pr,on,cs;if(!bs.current||!qe||((Vr=window.getSelection())==null?void 0:Vr.toString().length)>0)return;let ka=lr.clientY-bs.current.y,zi=lr.clientX-bs.current.x,li=(Pr=t.swipeDirections)!=null?Pr:bit(de);!Se&&(Math.abs(zi)>1||Math.abs(ka)>1)&&Ke(Math.abs(zi)>Math.abs(ka)?"x":"y");let Or={x:0,y:0};Se==="y"?(li.includes("top")||li.includes("bottom"))&&(li.includes("top")&&ka<0||li.includes("bottom")&&ka>0)&&(Or.y=ka):Se==="x"&&(li.includes("left")||li.includes("right"))&&(li.includes("left")&&zi<0||li.includes("right")&&zi>0)&&(Or.x=zi),(Math.abs(Or.x)>0||Math.abs(Or.y)>0)&&et(!0),(on=tt.current)==null||on.style.setProperty("--swipe-amount-x",`${Or.x}px`),(cs=tt.current)==null||cs.style.setProperty("--swipe-amount-y",`${Or.y}px`)}},Xt&&!_.jsx?lt.createElement("button",{"aria-label":ve,"data-disabled":Ia,"data-close-button":!0,onClick:Ia||!qe?()=>{}:()=>{var lr;nn(),(lr=_.onDismiss)==null||lr.call(_,_)},className:Rf(ge==null?void 0:ge.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=Te==null?void 0:Te.close)!=null?o:ait):null,_.jsx||T.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:lt.createElement(lt.Fragment,null,_t||_.icon||_.promise?lt.createElement("div",{"data-icon":"",className:Rf(ge==null?void 0:ge.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||Qt():null,_.type!=="loading"?_.icon||(Te==null?void 0:Te[_t])||Qat(_t):null):null,lt.createElement("div",{"data-content":"",className:Rf(ge==null?void 0:ge.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},lt.createElement("div",{"data-title":"",className:Rf(ge==null?void 0:ge.title,(d=_==null?void 0:_.classNames)==null?void 0:d.title)},typeof _.title=="function"?_.title():_.title),_.description?lt.createElement("div",{"data-description":"",className:Rf(ie,Rt,ge==null?void 0:ge.description,(h=_==null?void 0:_.classNames)==null?void 0:h.description)},typeof _.description=="function"?_.description():_.description):null),T.isValidElement(_.cancel)?_.cancel:_.cancel&&MO(_.cancel)?lt.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||G,onClick:lr=>{var Vr,Pr;MO(_.cancel)&&qe&&((Pr=(Vr=_.cancel).onClick)==null||Pr.call(Vr,lr),nn())},className:Rf(ge==null?void 0:ge.cancelButton,(f=_==null?void 0:_.classNames)==null?void 0:f.cancelButton)},_.cancel.label):null,T.isValidElement(_.action)?_.action:_.action&&MO(_.action)?lt.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||J,onClick:lr=>{var Vr,Pr;MO(_.action)&&((Pr=(Vr=_.action).onClick)==null||Pr.call(Vr,lr),!lr.defaultPrevented&&nn())},className:Rf(ge==null?void 0:ge.actionButton,(g=_==null?void 0:_.classNames)==null?void 0:g.actionButton)},_.action.label):null))};function eCe(){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 jit(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?git:fit;function d(h){["top","right","bottom","left"].forEach(f=>{r[`${l}-${f}`]=typeof h=="number"?`${h}px`:h})}typeof n=="number"||typeof n=="string"?d(n):typeof n=="object"?["top","right","bottom","left"].forEach(h=>{n[h]===void 0?r[`${l}-${h}`]=i:r[`${l}-${h}`]=typeof n[h]=="number"?`${n[h]}px`:n[h]}):d(i)}),r}var kit=T.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:d,mobileOffset:h,theme:f="light",richColors:g,duration:v,style:_,visibleToasts:j=pit,toastOptions:w,dir:k=eCe(),gap:M=yit,loadingIcon:S,icons:E,containerAriaLabel:D="Notifications",pauseWhenPageIsHidden:L}=t,[B,$]=lt.useState([]),V=lt.useMemo(()=>Array.from(new Set([n].concat(B.filter(ye=>ye.position).map(ye=>ye.position)))),[B,n]),[W,G]=lt.useState([]),[J,ne]=lt.useState(!1),[ie,ee]=lt.useState(!1),[de,oe]=lt.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ue=lt.useRef(null),ce=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),ge=lt.useRef(null),Te=lt.useRef(!1),ve=lt.useCallback(ye=>{$(Se=>{var Ke;return(Ke=Se.find(Ae=>Ae.id===ye.id))!=null&&Ke.delete||Gh.dismiss(ye.id),Se.filter(({id:Ae})=>Ae!==ye.id)})},[]);return lt.useEffect(()=>Gh.subscribe(ye=>{if(ye.dismiss){$(Se=>Se.map(Ke=>Ke.id===ye.id?{...Ke,delete:!0}:Ke));return}setTimeout(()=>{G0e.flushSync(()=>{$(Se=>{let Ke=Se.findIndex(Ae=>Ae.id===ye.id);return Ke!==-1?[...Se.slice(0,Ke),{...Se[Ke],...ye},...Se.slice(Ke+1)]:[ye,...Se]})})})}),[]),lt.useEffect(()=>{if(f!=="system"){oe(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?oe("dark"):oe("light")),typeof window>"u")return;let ye=window.matchMedia("(prefers-color-scheme: dark)");try{ye.addEventListener("change",({matches:Se})=>{oe(Se?"dark":"light")})}catch{ye.addListener(({matches:Ke})=>{try{oe(Ke?"dark":"light")}catch(Ae){console.error(Ae)}})}},[f]),lt.useEffect(()=>{B.length<=1&&ne(!1)},[B]),lt.useEffect(()=>{let ye=Se=>{var Ke,Ae;a.every(Ee=>Se[Ee]||Se.code===Ee)&&(ne(!0),(Ke=ue.current)==null||Ke.focus()),Se.code==="Escape"&&(document.activeElement===ue.current||(Ae=ue.current)!=null&&Ae.contains(document.activeElement))&&ne(!1)};return document.addEventListener("keydown",ye),()=>document.removeEventListener("keydown",ye)},[a]),lt.useEffect(()=>{if(ue.current)return()=>{ge.current&&(ge.current.focus({preventScroll:!0}),ge.current=null,Te.current=!1)}},[ue.current]),lt.createElement("section",{ref:s,"aria-label":`${D} ${ce}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},V.map((ye,Se)=>{var Ke;let[Ae,Ee]=ye.split("-");return B.length?lt.createElement("ol",{key:ye,dir:k==="auto"?eCe():k,tabIndex:-1,ref:ue,className:i,"data-sonner-toaster":!0,"data-theme":de,"data-y-position":Ae,"data-lifted":J&&B.length>1&&!o,"data-x-position":Ee,style:{"--front-toast-height":`${((Ke=W[0])==null?void 0:Ke.height)||0}px`,"--width":`${xit}px`,"--gap":`${M}px`,..._,...jit(d,h)},onBlur:He=>{Te.current&&!He.currentTarget.contains(He.relatedTarget)&&(Te.current=!1,ge.current&&(ge.current.focus({preventScroll:!0}),ge.current=null))},onFocus:He=>{He.target instanceof HTMLElement&&He.target.dataset.dismissible==="false"||Te.current||(Te.current=!0,ge.current=He.relatedTarget)},onMouseEnter:()=>ne(!0),onMouseMove:()=>ne(!0),onMouseLeave:()=>{ie||ne(!1)},onDragEnd:()=>ne(!1),onPointerDown:He=>{He.target instanceof HTMLElement&&He.target.dataset.dismissible==="false"||ee(!0)},onPointerUp:()=>ee(!1)},B.filter(He=>!He.position&&Se===0||He.position===ye).map((He,Ue)=>{var De,Ge;return lt.createElement(wit,{key:He.id,icons:E,index:Ue,toast:He,defaultRichColors:g,duration:(De=w==null?void 0:w.duration)!=null?De:v,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:r,visibleToasts:j,closeButton:(Ge=w==null?void 0:w.closeButton)!=null?Ge:l,interacting:ie,position:ye,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:ve,toasts:B.filter(wt=>wt.position==He.position),heights:W.filter(wt=>wt.position==He.position),setHeights:G,expandByDefault:o,gap:M,loadingIcon:S,expanded:J,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const Nit=({...t})=>{const{theme:s="system"}=Xat();return e.jsx(kit,{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 Sit=s0e[" useId ".trim().toString()]||(()=>{}),Cit=0;function Id(t){const[s,r]=T.useState(Sit());return Pc(()=>{r(n=>n??String(Cit++))},[t]),s?`radix-${s}`:""}const Mit=["top","right","bottom","left"],G1=Math.min,Rm=Math.max,mre=Math.round,TO=Math.floor,Ex=t=>({x:t,y:t}),Tit={left:"right",right:"left",bottom:"top",top:"bottom"},Ait={start:"end",end:"start"};function $pe(t,s,r){return Rm(t,G1(s,r))}function g0(t,s){return typeof t=="function"?t(s):t}function x0(t){return t.split("-")[0]}function A3(t){return t.split("-")[1]}function eve(t){return t==="x"?"y":"x"}function tve(t){return t==="y"?"height":"width"}const Eit=new Set(["top","bottom"]);function gx(t){return Eit.has(x0(t))?"y":"x"}function sve(t){return eve(gx(t))}function Iit(t,s,r){r===void 0&&(r=!1);const n=A3(t),a=sve(t),o=tve(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=pre(l)),[l,pre(l)]}function Pit(t){const s=pre(t);return[Upe(t),s,Upe(s)]}function Upe(t){return t.replace(/start|end/g,s=>Ait[s])}const tCe=["left","right"],sCe=["right","left"],Lit=["top","bottom"],Dit=["bottom","top"];function Oit(t,s,r){switch(t){case"top":case"bottom":return r?s?sCe:tCe:s?tCe:sCe;case"left":case"right":return s?Lit:Dit;default:return[]}}function Rit(t,s,r,n){const a=A3(t);let o=Oit(x0(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Upe)))),o}function pre(t){return t.replace(/left|right|bottom|top/g,s=>Tit[s])}function Fit(t){return{top:0,right:0,bottom:0,left:0,...t}}function BOe(t){return typeof t!="number"?Fit(t):{top:t,right:t,bottom:t,left:t}}function fre(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 rCe(t,s,r){let{reference:n,floating:a}=t;const o=gx(s),l=sve(s),i=tve(l),d=x0(s),h=o==="y",f=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:f,y:n.y-a.height};break;case"bottom":_={x:f,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(A3(s)){case"start":_[l]-=v*(r&&h?-1:1);break;case"end":_[l]+=v*(r&&h?-1:1);break}return _}const zit=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 h=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:f,y:g}=rCe(h,n,d),v=n,_={},j=0;for(let w=0;w({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:d}=s,{element:h,padding:f=0}=g0(t,s)||{};if(h==null)return{};const g=BOe(f),v={x:r,y:n},_=sve(a),j=tve(_),w=await l.getDimensions(h),k=_==="y",M=k?"top":"left",S=k?"bottom":"right",E=k?"clientHeight":"clientWidth",D=o.reference[j]+o.reference[_]-v[_]-o.floating[j],L=v[_]-o.reference[_],B=await(l.getOffsetParent==null?void 0:l.getOffsetParent(h));let $=B?B[E]:0;(!$||!await(l.isElement==null?void 0:l.isElement(B)))&&($=i.floating[E]||o.floating[j]);const V=D/2-L/2,W=$/2-w[j]/2-1,G=G1(g[M],W),J=G1(g[S],W),ne=G,ie=$-w[j]-J,ee=$/2-w[j]/2+V,de=$pe(ne,ee,ie),oe=!d.arrow&&A3(a)!=null&&ee!==de&&o.reference[j]/2-(eeee<=0)){var J,ne;const ee=(((J=o.flip)==null?void 0:J.index)||0)+1,de=$[ee];if(de&&(!(g==="alignment"?S!==gx(de):!1)||G.every(ce=>ce.overflows[0]>0&&gx(ce.placement)===S)))return{data:{index:ee,overflows:G},reset:{placement:de}};let oe=(ne=G.filter(ue=>ue.overflows[0]<=0).sort((ue,ce)=>ue.overflows[1]-ce.overflows[1])[0])==null?void 0:ne.placement;if(!oe)switch(_){case"bestFit":{var ie;const ue=(ie=G.filter(ce=>{if(B){const ge=gx(ce.placement);return ge===S||ge==="y"}return!0}).map(ce=>[ce.placement,ce.overflows.filter(ge=>ge>0).reduce((ge,Te)=>ge+Te,0)]).sort((ce,ge)=>ce[1]-ge[1])[0])==null?void 0:ie[0];ue&&(oe=ue);break}case"initialPlacement":oe=i;break}if(a!==oe)return{reset:{placement:oe}}}return{}}}};function nCe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function aCe(t){return Mit.some(s=>t[s]>=0)}const Uit=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=g0(t,s);switch(n){case"referenceHidden":{const o=await KI(s,{...a,elementContext:"reference"}),l=nCe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:aCe(l)}}}case"escaped":{const o=await KI(s,{...a,altBoundary:!0}),l=nCe(o,r.floating);return{data:{escapedOffsets:l,escaped:aCe(l)}}}default:return{}}}}},$Oe=new Set(["left","top"]);async function qit(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=x0(r),i=A3(r),d=gx(r)==="y",h=$Oe.has(l)?-1:1,f=o&&d?-1:1,g=g0(s,t);let{mainAxis:v,crossAxis:_,alignmentAxis:j}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return i&&typeof j=="number"&&(_=i==="end"?j*-1:j),d?{x:_*f,y:v*h}:{x:v*h,y:_*f}}const Vit=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 qit(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}}}}},Hit=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:k=>{let{x:M,y:S}=k;return{x:M,y:S}}},...d}=g0(t,s),h={x:r,y:n},f=await KI(s,d),g=gx(x0(a)),v=eve(g);let _=h[v],j=h[g];if(o){const k=v==="y"?"top":"left",M=v==="y"?"bottom":"right",S=_+f[k],E=_-f[M];_=$pe(S,_,E)}if(l){const k=g==="y"?"top":"left",M=g==="y"?"bottom":"right",S=j+f[k],E=j-f[M];j=$pe(S,j,E)}const w=i.fn({...s,[v]:_,[g]:j});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[v]:o,[g]:l}}}}}},Wit=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:h=!0}=g0(t,s),f={x:r,y:n},g=gx(a),v=eve(g);let _=f[v],j=f[g];const w=g0(i,s),k=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const E=v==="y"?"height":"width",D=o.reference[v]-o.floating[E]+k.mainAxis,L=o.reference[v]+o.reference[E]-k.mainAxis;_L&&(_=L)}if(h){var M,S;const E=v==="y"?"width":"height",D=$Oe.has(x0(a)),L=o.reference[g]-o.floating[E]+(D&&((M=l.offset)==null?void 0:M[g])||0)+(D?0:k.crossAxis),B=o.reference[g]+o.reference[E]+(D?0:((S=l.offset)==null?void 0:S[g])||0)-(D?k.crossAxis:0);jB&&(j=B)}return{[v]:_,[g]:j}}}},Git=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=()=>{},...h}=g0(t,s),f=await KI(s,h),g=x0(a),v=A3(a),_=gx(a)==="y",{width:j,height:w}=o.floating;let k,M;g==="top"||g==="bottom"?(k=g,M=v===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(M=g,k=v==="end"?"top":"bottom");const S=w-f.top-f.bottom,E=j-f.left-f.right,D=G1(w-f[k],S),L=G1(j-f[M],E),B=!s.middlewareData.shift;let $=D,V=L;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(V=E),(n=s.middlewareData.shift)!=null&&n.enabled.y&&($=S),B&&!v){const G=Rm(f.left,0),J=Rm(f.right,0),ne=Rm(f.top,0),ie=Rm(f.bottom,0);_?V=j-2*(G!==0||J!==0?G+J:Rm(f.left,f.right)):$=w-2*(ne!==0||ie!==0?ne+ie:Rm(f.top,f.bottom))}await d({...s,availableWidth:V,availableHeight:$});const W=await l.getDimensions(i.floating);return j!==W.width||w!==W.height?{reset:{rects:!0}}:{}}}};function fie(){return typeof window<"u"}function E3(t){return UOe(t)?(t.nodeName||"").toLowerCase():"#document"}function tp(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function Hx(t){var s;return(s=(UOe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function UOe(t){return fie()?t instanceof Node||t instanceof tp(t).Node:!1}function vg(t){return fie()?t instanceof Element||t instanceof tp(t).Element:!1}function Rx(t){return fie()?t instanceof HTMLElement||t instanceof tp(t).HTMLElement:!1}function iCe(t){return!fie()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof tp(t).ShadowRoot}const Kit=new Set(["inline","contents"]);function j6(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=_g(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!Kit.has(a)}const Zit=new Set(["table","td","th"]);function Yit(t){return Zit.has(E3(t))}const Xit=[":popover-open",":modal"];function gie(t){return Xit.some(s=>{try{return t.matches(s)}catch{return!1}})}const Qit=["transform","translate","scale","rotate","perspective"],Jit=["transform","translate","scale","rotate","perspective","filter"],eot=["paint","layout","strict","content"];function rve(t){const s=nve(),r=vg(t)?_g(t):t;return Qit.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)||Jit.some(n=>(r.willChange||"").includes(n))||eot.some(n=>(r.contain||"").includes(n))}function tot(t){let s=K1(t);for(;Rx(s)&&!I5(s);){if(rve(s))return s;if(gie(s))return null;s=K1(s)}return null}function nve(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const sot=new Set(["html","body","#document"]);function I5(t){return sot.has(E3(t))}function _g(t){return tp(t).getComputedStyle(t)}function xie(t){return vg(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function K1(t){if(E3(t)==="html")return t;const s=t.assignedSlot||t.parentNode||iCe(t)&&t.host||Hx(t);return iCe(s)?s.host:s}function qOe(t){const s=K1(t);return I5(s)?t.ownerDocument?t.ownerDocument.body:t.body:Rx(s)&&j6(s)?s:qOe(s)}function ZI(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=qOe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=tp(a);if(o){const i=qpe(l);return s.concat(l,l.visualViewport||[],j6(a)?a:[],i&&r?ZI(i):[])}return s.concat(a,ZI(a,[],r))}function qpe(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function VOe(t){const s=_g(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=Rx(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=mre(r)!==o||mre(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function ave(t){return vg(t)?t:t.contextElement}function Z4(t){const s=ave(t);if(!Rx(s))return Ex(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=VOe(s);let l=(o?mre(r.width):r.width)/n,i=(o?mre(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const rot=Ex(0);function HOe(t){const s=tp(t);return!nve()||!s.visualViewport?rot:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function not(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==tp(t)?!1:s}function Xk(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=ave(t);let l=Ex(1);s&&(n?vg(n)&&(l=Z4(n)):l=Z4(t));const i=not(o,r,n)?HOe(o):Ex(0);let d=(a.left+i.x)/l.x,h=(a.top+i.y)/l.y,f=a.width/l.x,g=a.height/l.y;if(o){const v=tp(o),_=n&&vg(n)?tp(n):n;let j=v,w=qpe(j);for(;w&&n&&_!==j;){const k=Z4(w),M=w.getBoundingClientRect(),S=_g(w),E=M.left+(w.clientLeft+parseFloat(S.paddingLeft))*k.x,D=M.top+(w.clientTop+parseFloat(S.paddingTop))*k.y;d*=k.x,h*=k.y,f*=k.x,g*=k.y,d+=E,h+=D,j=tp(w),w=qpe(j)}}return fre({width:f,height:g,x:d,y:h})}function ive(t,s){const r=xie(t).scrollLeft;return s?s.left+r:Xk(Hx(t)).left+r}function WOe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:ive(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function aot(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=Hx(n),i=s?gie(s.floating):!1;if(n===l||i&&o)return r;let d={scrollLeft:0,scrollTop:0},h=Ex(1);const f=Ex(0),g=Rx(n);if((g||!g&&!o)&&((E3(n)!=="body"||j6(l))&&(d=xie(n)),Rx(n))){const _=Xk(n);h=Z4(n),f.x=_.x+n.clientLeft,f.y=_.y+n.clientTop}const v=l&&!g&&!o?WOe(l,d,!0):Ex(0);return{width:r.width*h.x,height:r.height*h.y,x:r.x*h.x-d.scrollLeft*h.x+f.x+v.x,y:r.y*h.y-d.scrollTop*h.y+f.y+v.y}}function iot(t){return Array.from(t.getClientRects())}function oot(t){const s=Hx(t),r=xie(t),n=t.ownerDocument.body,a=Rm(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=Rm(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+ive(t);const i=-r.scrollTop;return _g(n).direction==="rtl"&&(l+=Rm(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function lot(t,s){const r=tp(t),n=Hx(t),a=r.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,d=0;if(a){o=a.width,l=a.height;const h=nve();(!h||h&&s==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}return{width:o,height:l,x:i,y:d}}const cot=new Set(["absolute","fixed"]);function dot(t,s){const r=Xk(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=Rx(t)?Z4(t):Ex(1),l=t.clientWidth*o.x,i=t.clientHeight*o.y,d=a*o.x,h=n*o.y;return{width:l,height:i,x:d,y:h}}function oCe(t,s,r){let n;if(s==="viewport")n=lot(t,r);else if(s==="document")n=oot(Hx(t));else if(vg(s))n=dot(s,r);else{const a=HOe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return fre(n)}function GOe(t,s){const r=K1(t);return r===s||!vg(r)||I5(r)?!1:_g(r).position==="fixed"||GOe(r,s)}function uot(t,s){const r=s.get(t);if(r)return r;let n=ZI(t,[],!1).filter(i=>vg(i)&&E3(i)!=="body"),a=null;const o=_g(t).position==="fixed";let l=o?K1(t):t;for(;vg(l)&&!I5(l);){const i=_g(l),d=rve(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&cot.has(a.position)||j6(l)&&!d&&GOe(t,l))?n=n.filter(f=>f!==l):a=i,l=K1(l)}return s.set(t,n),n}function hot(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?gie(s)?[]:uot(s,this._c):[].concat(r),n],i=l[0],d=l.reduce((h,f)=>{const g=oCe(s,f,a);return h.top=Rm(g.top,h.top),h.right=G1(g.right,h.right),h.bottom=G1(g.bottom,h.bottom),h.left=Rm(g.left,h.left),h},oCe(s,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function mot(t){const{width:s,height:r}=VOe(t);return{width:s,height:r}}function pot(t,s,r){const n=Rx(s),a=Hx(s),o=r==="fixed",l=Xk(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const d=Ex(0);function h(){d.x=ive(a)}if(n||!n&&!o)if((E3(s)!=="body"||j6(a))&&(i=xie(s)),n){const _=Xk(s,!0,o,s);d.x=_.x+s.clientLeft,d.y=_.y+s.clientTop}else a&&h();o&&!n&&a&&h();const f=a&&!n&&!o?WOe(a,i):Ex(0),g=l.left+i.scrollLeft-d.x-f.x,v=l.top+i.scrollTop-d.y-f.y;return{x:g,y:v,width:l.width,height:l.height}}function bue(t){return _g(t).position==="static"}function lCe(t,s){if(!Rx(t)||_g(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return Hx(t)===r&&(r=r.ownerDocument.body),r}function KOe(t,s){const r=tp(t);if(gie(t))return r;if(!Rx(t)){let a=K1(t);for(;a&&!I5(a);){if(vg(a)&&!bue(a))return a;a=K1(a)}return r}let n=lCe(t,s);for(;n&&Yit(n)&&bue(n);)n=lCe(n,s);return n&&I5(n)&&bue(n)&&!rve(n)?r:n||tot(t)||r}const fot=async function(t){const s=this.getOffsetParent||KOe,r=this.getDimensions,n=await r(t.floating);return{reference:pot(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function got(t){return _g(t).direction==="rtl"}const xot={convertOffsetParentRelativeRectToViewportRelativeRect:aot,getDocumentElement:Hx,getClippingRect:hot,getOffsetParent:KOe,getElementRects:fot,getClientRects:iot,getDimensions:mot,getScale:Z4,isElement:vg,isRTL:got};function ZOe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function yot(t,s){let r=null,n;const a=Hx(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 h=t.getBoundingClientRect(),{left:f,top:g,width:v,height:_}=h;if(i||s(),!v||!_)return;const j=TO(g),w=TO(a.clientWidth-(f+v)),k=TO(a.clientHeight-(g+_)),M=TO(f),E={rootMargin:-j+"px "+-w+"px "+-k+"px "+-M+"px",threshold:Rm(0,G1(1,d))||1};let D=!0;function L(B){const $=B[0].intersectionRatio;if($!==d){if(!D)return l();$?l(!1,$):n=setTimeout(()=>{l(!1,1e-7)},1e3)}$===1&&!ZOe(h,t.getBoundingClientRect())&&l(),D=!1}try{r=new IntersectionObserver(L,{...E,root:a.ownerDocument})}catch{r=new IntersectionObserver(L,E)}r.observe(t)}return l(!0),o}function vot(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,h=ave(t),f=a||o?[...h?ZI(h):[],...ZI(s)]:[];f.forEach(M=>{a&&M.addEventListener("scroll",r,{passive:!0}),o&&M.addEventListener("resize",r)});const g=h&&i?yot(h,r):null;let v=-1,_=null;l&&(_=new ResizeObserver(M=>{let[S]=M;S&&S.target===h&&_&&(_.unobserve(s),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var E;(E=_)==null||E.observe(s)})),r()}),h&&!d&&_.observe(h),_.observe(s));let j,w=d?Xk(t):null;d&&k();function k(){const M=Xk(t);w&&!ZOe(w,M)&&r(),w=M,j=requestAnimationFrame(k)}return r(),()=>{var M;f.forEach(S=>{a&&S.removeEventListener("scroll",r),o&&S.removeEventListener("resize",r)}),g==null||g(),(M=_)==null||M.disconnect(),_=null,d&&cancelAnimationFrame(j)}}const _ot=Vit,bot=Hit,wot=$it,jot=Git,kot=Uit,cCe=Bit,Not=Wit,Sot=(t,s,r)=>{const n=new Map,a={platform:xot,...r},o={...a.platform,_c:n};return zit(t,s,{...a,platform:o})};var Cot=typeof document<"u",Mot=function(){},gse=Cot?T.useLayoutEffect:Mot;function gre(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(!gre(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)&&!gre(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function YOe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function dCe(t,s){const r=YOe(t);return Math.round(s*r)/r}function wue(t){const s=T.useRef(t);return gse(()=>{s.current=t}),s}function Tot(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:h}=t,[f,g]=T.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[v,_]=T.useState(n);gre(v,n)||_(n);const[j,w]=T.useState(null),[k,M]=T.useState(null),S=T.useCallback(ce=>{ce!==B.current&&(B.current=ce,w(ce))},[]),E=T.useCallback(ce=>{ce!==$.current&&($.current=ce,M(ce))},[]),D=o||j,L=l||k,B=T.useRef(null),$=T.useRef(null),V=T.useRef(f),W=d!=null,G=wue(d),J=wue(a),ne=wue(h),ie=T.useCallback(()=>{if(!B.current||!$.current)return;const ce={placement:s,strategy:r,middleware:v};J.current&&(ce.platform=J.current),Sot(B.current,$.current,ce).then(ge=>{const Te={...ge,isPositioned:ne.current!==!1};ee.current&&!gre(V.current,Te)&&(V.current=Te,Qh.flushSync(()=>{g(Te)}))})},[v,s,r,J,ne]);gse(()=>{h===!1&&V.current.isPositioned&&(V.current.isPositioned=!1,g(ce=>({...ce,isPositioned:!1})))},[h]);const ee=T.useRef(!1);gse(()=>(ee.current=!0,()=>{ee.current=!1}),[]),gse(()=>{if(D&&(B.current=D),L&&($.current=L),D&&L){if(G.current)return G.current(D,L,ie);ie()}},[D,L,ie,G,W]);const de=T.useMemo(()=>({reference:B,floating:$,setReference:S,setFloating:E}),[S,E]),oe=T.useMemo(()=>({reference:D,floating:L}),[D,L]),ue=T.useMemo(()=>{const ce={position:r,left:0,top:0};if(!oe.floating)return ce;const ge=dCe(oe.floating,f.x),Te=dCe(oe.floating,f.y);return i?{...ce,transform:"translate("+ge+"px, "+Te+"px)",...YOe(oe.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:ge,top:Te}},[r,i,oe.floating,f.x,f.y]);return T.useMemo(()=>({...f,update:ie,refs:de,elements:oe,floatingStyles:ue}),[f,ie,de,oe,ue])}const Aot=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?cCe({element:n.current,padding:a}).fn(r):{}:n?cCe({element:n,padding:a}).fn(r):{}}}},Eot=(t,s)=>({..._ot(t),options:[t,s]}),Iot=(t,s)=>({...bot(t),options:[t,s]}),Pot=(t,s)=>({...Not(t),options:[t,s]}),Lot=(t,s)=>({...wot(t),options:[t,s]}),Dot=(t,s)=>({...jot(t),options:[t,s]}),Oot=(t,s)=>({...kot(t),options:[t,s]}),Rot=(t,s)=>({...Aot(t),options:[t,s]});var Fot="Arrow",XOe=T.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"})})});XOe.displayName=Fot;var zot=XOe;function k6(t){const[s,r]=T.useState(void 0);return Pc(()=>{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,h=Array.isArray(d)?d[0]:d;l=h.inlineSize,i=h.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 ove="Popper",[QOe,Wx]=Dc(ove),[Bot,JOe]=QOe(ove),e8e=t=>{const{__scopePopper:s,children:r}=t,[n,a]=T.useState(null);return e.jsx(Bot,{scope:s,anchor:n,onAnchorChange:a,children:r})};e8e.displayName=ove;var t8e="PopperAnchor",s8e=T.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=JOe(t8e,r),l=T.useRef(null),i=ba(s,l);return T.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(Qr.div,{...a,ref:i})});s8e.displayName=t8e;var lve="PopperContent",[$ot,Uot]=QOe(lve),r8e=T.forwardRef((t,s)=>{var He,Ue,De,Ge,wt,Ie;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:g="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:j,...w}=t,k=JOe(lve,r),[M,S]=T.useState(null),E=ba(s,st=>S(st)),[D,L]=T.useState(null),B=k6(D),$=(B==null?void 0:B.width)??0,V=(B==null?void 0:B.height)??0,W=n+(o!=="center"?"-"+o:""),G=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},J=Array.isArray(h)?h:[h],ne=J.length>0,ie={padding:G,boundary:J.filter(Vot),altBoundary:ne},{refs:ee,floatingStyles:de,placement:oe,isPositioned:ue,middlewareData:ce}=Tot({strategy:"fixed",placement:W,whileElementsMounted:(...st)=>vot(...st,{animationFrame:_==="always"}),elements:{reference:k.anchor},middleware:[Eot({mainAxis:a+V,alignmentAxis:l}),d&&Iot({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?Pot():void 0,...ie}),d&&Lot({...ie}),Dot({...ie,apply:({elements:st,rects:he,availableWidth:We,availableHeight:et})=>{const{width:Ye,height:ke}=he.reference,at=st.floating.style;at.setProperty("--radix-popper-available-width",`${We}px`),at.setProperty("--radix-popper-available-height",`${et}px`),at.setProperty("--radix-popper-anchor-width",`${Ye}px`),at.setProperty("--radix-popper-anchor-height",`${ke}px`)}}),D&&Rot({element:D,padding:i}),Hot({arrowWidth:$,arrowHeight:V}),v&&Oot({strategy:"referenceHidden",...ie})]}),[ge,Te]=i8e(oe),ve=Ac(j);Pc(()=>{ue&&(ve==null||ve())},[ue,ve]);const ye=(He=ce.arrow)==null?void 0:He.x,Se=(Ue=ce.arrow)==null?void 0:Ue.y,Ke=((De=ce.arrow)==null?void 0:De.centerOffset)!==0,[Ae,Ee]=T.useState();return Pc(()=>{M&&Ee(window.getComputedStyle(M).zIndex)},[M]),e.jsx("div",{ref:ee.setFloating,"data-radix-popper-content-wrapper":"",style:{...de,transform:ue?de.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(Ge=ce.transformOrigin)==null?void 0:Ge.x,(wt=ce.transformOrigin)==null?void 0:wt.y].join(" "),...((Ie=ce.hide)==null?void 0:Ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx($ot,{scope:r,placedSide:ge,onArrowChange:L,arrowX:ye,arrowY:Se,shouldHideArrow:Ke,children:e.jsx(Qr.div,{"data-side":ge,"data-align":Te,...w,ref:E,style:{...w.style,animation:ue?void 0:"none"}})})})});r8e.displayName=lve;var n8e="PopperArrow",qot={top:"bottom",right:"left",bottom:"top",left:"right"},a8e=T.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=Uot(n8e,n),l=qot[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(zot,{...a,ref:r,style:{...a.style,display:"block"}})})});a8e.displayName=n8e;function Vot(t){return t!==null}var Hot=t=>({name:"transformOrigin",options:t,fn(s){var k,M,S;const{placement:r,rects:n,middlewareData:a}=s,l=((k=a.arrow)==null?void 0:k.centerOffset)!==0,i=l?0:t.arrowWidth,d=l?0:t.arrowHeight,[h,f]=i8e(r),g={start:"0%",center:"50%",end:"100%"}[f],v=(((M=a.arrow)==null?void 0:M.x)??0)+i/2,_=(((S=a.arrow)==null?void 0:S.y)??0)+d/2;let j="",w="";return h==="bottom"?(j=l?g:`${v}px`,w=`${-d}px`):h==="top"?(j=l?g:`${v}px`,w=`${n.floating.height+d}px`):h==="right"?(j=`${-d}px`,w=l?g:`${_}px`):h==="left"&&(j=`${n.floating.width+d}px`,w=l?g:`${_}px`),{data:{x:j,y:w}}}});function i8e(t){const[s,r="center"]=t.split("-");return[s,r]}var N6=e8e,I3=s8e,S6=r8e,C6=a8e,[yie]=Dc("Tooltip",[Wx]),vie=Wx(),o8e="TooltipProvider",Wot=700,Vpe="tooltip.open",[Got,cve]=yie(o8e),l8e=t=>{const{__scopeTooltip:s,delayDuration:r=Wot,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=T.useRef(!0),i=T.useRef(!1),d=T.useRef(0);return T.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),e.jsx(Got,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:T.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:T.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:T.useCallback(h=>{i.current=h},[]),disableHoverableContent:a,children:o})};l8e.displayName=o8e;var YI="Tooltip",[Kot,_ie]=yie(YI),c8e=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,d=cve(YI,t.__scopeTooltip),h=vie(s),[f,g]=T.useState(null),v=Id(),_=T.useRef(0),j=l??d.disableHoverableContent,w=i??d.delayDuration,k=T.useRef(!1),[M,S]=Sh({prop:n,defaultProp:a??!1,onChange:$=>{$?(d.onOpen(),document.dispatchEvent(new CustomEvent(Vpe))):d.onClose(),o==null||o($)},caller:YI}),E=T.useMemo(()=>M?k.current?"delayed-open":"instant-open":"closed",[M]),D=T.useCallback(()=>{window.clearTimeout(_.current),_.current=0,k.current=!1,S(!0)},[S]),L=T.useCallback(()=>{window.clearTimeout(_.current),_.current=0,S(!1)},[S]),B=T.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{k.current=!0,S(!0),_.current=0},w)},[w,S]);return T.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(N6,{...h,children:e.jsx(Kot,{scope:s,contentId:v,open:M,stateAttribute:E,trigger:f,onTriggerChange:g,onTriggerEnter:T.useCallback(()=>{d.isOpenDelayedRef.current?B():D()},[d.isOpenDelayedRef,B,D]),onTriggerLeave:T.useCallback(()=>{j?L():(window.clearTimeout(_.current),_.current=0)},[L,j]),onOpen:D,onClose:L,disableHoverableContent:j,children:r})})};c8e.displayName=YI;var Hpe="TooltipTrigger",d8e=T.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=_ie(Hpe,r),o=cve(Hpe,r),l=vie(r),i=T.useRef(null),d=ba(s,i,a.onTriggerChange),h=T.useRef(!1),f=T.useRef(!1),g=T.useCallback(()=>h.current=!1,[]);return T.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),e.jsx(I3,{asChild:!0,...l,children:e.jsx(Qr.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:kr(t.onPointerMove,v=>{v.pointerType!=="touch"&&!f.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),f.current=!0)}),onPointerLeave:kr(t.onPointerLeave,()=>{a.onTriggerLeave(),f.current=!1}),onPointerDown:kr(t.onPointerDown,()=>{a.open&&a.onClose(),h.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:kr(t.onFocus,()=>{h.current||a.onOpen()}),onBlur:kr(t.onBlur,a.onClose),onClick:kr(t.onClick,a.onClose)})})});d8e.displayName=Hpe;var Zot="TooltipPortal",[Bfs,Yot]=yie(Zot,{forceMount:void 0}),P5="TooltipContent",u8e=T.forwardRef((t,s)=>{const r=Yot(P5,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=_ie(P5,t.__scopeTooltip);return e.jsx(Qc,{present:n||l.open,children:l.disableHoverableContent?e.jsx(h8e,{side:a,...o,ref:s}):e.jsx(Xot,{side:a,...o,ref:s})})}),Xot=T.forwardRef((t,s)=>{const r=_ie(P5,t.__scopeTooltip),n=cve(P5,t.__scopeTooltip),a=T.useRef(null),o=ba(s,a),[l,i]=T.useState(null),{trigger:d,onClose:h}=r,f=a.current,{onPointerInTransitChange:g}=n,v=T.useCallback(()=>{i(null),g(!1)},[g]),_=T.useCallback((j,w)=>{const k=j.currentTarget,M={x:j.clientX,y:j.clientY},S=slt(M,k.getBoundingClientRect()),E=rlt(M,S),D=nlt(w.getBoundingClientRect()),L=ilt([...E,...D]);i(L),g(!0)},[g]);return T.useEffect(()=>()=>v(),[v]),T.useEffect(()=>{if(d&&f){const j=k=>_(k,f),w=k=>_(k,d);return d.addEventListener("pointerleave",j),f.addEventListener("pointerleave",w),()=>{d.removeEventListener("pointerleave",j),f.removeEventListener("pointerleave",w)}}},[d,f,_,v]),T.useEffect(()=>{if(l){const j=w=>{const k=w.target,M={x:w.clientX,y:w.clientY},S=(d==null?void 0:d.contains(k))||(f==null?void 0:f.contains(k)),E=!alt(M,l);S?v():E&&(v(),h())};return document.addEventListener("pointermove",j),()=>document.removeEventListener("pointermove",j)}},[d,f,l,h,v]),e.jsx(h8e,{...t,ref:o})}),[Qot,Jot]=yie(YI,{isInside:!1}),elt=sOe("TooltipContent"),h8e=T.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=_ie(P5,r),h=vie(r),{onClose:f}=d;return T.useEffect(()=>(document.addEventListener(Vpe,f),()=>document.removeEventListener(Vpe,f)),[f]),T.useEffect(()=>{if(d.trigger){const g=v=>{const _=v.target;_!=null&&_.contains(d.trigger)&&f()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,f]),e.jsx(n_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:e.jsxs(S6,{"data-state":d.stateAttribute,...h,...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(elt,{children:n}),e.jsx(Qot,{scope:r,isInside:!0,children:e.jsx(Vnt,{id:d.contentId,role:"tooltip",children:a||n})})]})})});u8e.displayName=P5;var m8e="TooltipArrow",tlt=T.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=vie(r);return Jot(m8e,r).isInside?null:e.jsx(C6,{...a,...n,ref:s})});tlt.displayName=m8e;function slt(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 rlt(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 nlt(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 alt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=v>n&&r<(g-h)*(n-f)/(v-f)+h&&(a=!a)}return a}function ilt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),olt(s)}function olt(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 llt=l8e,clt=c8e,dlt=d8e,p8e=u8e;const bN=llt,em=clt,tm=dlt,fh=T.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(p8e,{ref:n,sideOffset:s,className:$t("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}));fh.displayName=p8e.displayName;var P3=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(){}},Qk=typeof window>"u"||"Deno"in globalThis;function hh(){}function ult(t,s){return typeof t=="function"?t(s):t}function Wpe(t){return typeof t=="number"&&t>=0&&t!==1/0}function f8e(t,s){return Math.max(t+(s||0)-Date.now(),0)}function L1(t,s){return typeof t=="function"?t(s):t}function Ip(t,s){return typeof t=="function"?t(s):t}function uCe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==dve(l,s.options))return!1}else if(!XI(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 hCe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(Jk(s.options.mutationKey)!==Jk(o))return!1}else if(!XI(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function dve(t,s){return((s==null?void 0:s.queryKeyHashFn)||Jk)(t)}function Jk(t){return JSON.stringify(t,(s,r)=>Gpe(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function XI(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>XI(t[r],s[r])):!1}function g8e(t,s){if(t===s)return t;const r=mCe(t)&&mCe(s);if(r||Gpe(t)&&Gpe(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 h=0;for(let f=0;f{setTimeout(s,t)})}function Kpe(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?g8e(t,s):s}function mlt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function plt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var uve=Symbol();function x8e(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===uve?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function y8e(t,s){return typeof t=="function"?t(...s):!!t}var ak,Zv,m5,E6e,flt=(E6e=class extends P3{constructor(){super();Aa(this,ak);Aa(this,Zv);Aa(this,m5);In(this,m5,s=>{if(!Qk&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){ls(this,Zv)||this.setEventListener(ls(this,m5))}onUnsubscribe(){var s;this.hasListeners()||((s=ls(this,Zv))==null||s.call(this),In(this,Zv,void 0))}setEventListener(s){var r;In(this,m5,s),(r=ls(this,Zv))==null||r.call(this),In(this,Zv,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){ls(this,ak)!==s&&(In(this,ak,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof ls(this,ak)=="boolean"?ls(this,ak):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},ak=new WeakMap,Zv=new WeakMap,m5=new WeakMap,E6e),hve=new flt,p5,Yv,f5,I6e,glt=(I6e=class extends P3{constructor(){super();Aa(this,p5,!0);Aa(this,Yv);Aa(this,f5);In(this,f5,s=>{if(!Qk&&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(){ls(this,Yv)||this.setEventListener(ls(this,f5))}onUnsubscribe(){var s;this.hasListeners()||((s=ls(this,Yv))==null||s.call(this),In(this,Yv,void 0))}setEventListener(s){var r;In(this,f5,s),(r=ls(this,Yv))==null||r.call(this),In(this,Yv,s(this.setOnline.bind(this)))}setOnline(s){ls(this,p5)!==s&&(In(this,p5,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return ls(this,p5)}},p5=new WeakMap,Yv=new WeakMap,f5=new WeakMap,I6e),yre=new glt;function Zpe(){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 xlt(t){return Math.min(1e3*2**t,3e4)}function v8e(t){return(t??"online")==="online"?yre.isOnline():!0}var _8e=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function jue(t){return t instanceof _8e}function b8e(t){let s=!1,r=0,n=!1,a;const o=Zpe(),l=w=>{var k;n||(v(new _8e(w)),(k=t.abort)==null||k.call(t))},i=()=>{s=!0},d=()=>{s=!1},h=()=>hve.isFocused()&&(t.networkMode==="always"||yre.isOnline())&&t.canRun(),f=()=>v8e(t.networkMode)&&t.canRun(),g=w=>{var k;n||(n=!0,(k=t.onSuccess)==null||k.call(t,w),a==null||a(),o.resolve(w))},v=w=>{var k;n||(n=!0,(k=t.onError)==null||k.call(t,w),a==null||a(),o.reject(w))},_=()=>new Promise(w=>{var k;a=M=>{(n||h())&&w(M)},(k=t.onPause)==null||k.call(t)}).then(()=>{var w;a=void 0,n||(w=t.onContinue)==null||w.call(t)}),j=()=>{if(n)return;let w;const k=r===0?t.initialPromise:void 0;try{w=k??t.fn()}catch(M){w=Promise.reject(M)}Promise.resolve(w).then(g).catch(M=>{var B;if(n)return;const S=t.retry??(Qk?0:3),E=t.retryDelay??xlt,D=typeof E=="function"?E(r,M):E,L=S===!0||typeof S=="number"&&rh()?void 0:_()).then(()=>{s?v(M):j()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:f,start:()=>(f()?j():_().then(j),o)}}var ylt=t=>setTimeout(t,0);function vlt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=ylt;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 Nd=vlt(),ik,P6e,w8e=(P6e=class{constructor(){Aa(this,ik)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Wpe(this.gcTime)&&In(this,ik,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Qk?1/0:5*60*1e3))}clearGcTimeout(){ls(this,ik)&&(clearTimeout(ls(this,ik)),In(this,ik,void 0))}},ik=new WeakMap,P6e),g5,ok,Ep,lk,Au,h6,ck,Gf,Cy,L6e,_lt=(L6e=class extends w8e{constructor(s){super();Aa(this,Gf);Aa(this,g5);Aa(this,ok);Aa(this,Ep);Aa(this,lk);Aa(this,Au);Aa(this,h6);Aa(this,ck);In(this,ck,!1),In(this,h6,s.defaultOptions),this.setOptions(s.options),this.observers=[],In(this,lk,s.client),In(this,Ep,ls(this,lk).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,In(this,g5,blt(this.options)),this.state=s.state??ls(this,g5),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=ls(this,Au))==null?void 0:s.promise}setOptions(s){this.options={...ls(this,h6),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ls(this,Ep).remove(this)}setData(s,r){const n=Kpe(this.state.data,s,this.options);return Ii(this,Gf,Cy).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Ii(this,Gf,Cy).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=ls(this,Au))==null?void 0:n.promise;return(a=ls(this,Au))==null||a.cancel(s),r?r.then(hh).catch(hh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ls(this,g5))}isActive(){return this.observers.some(s=>Ip(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===uve||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>L1(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:!f8e(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=ls(this,Au))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=ls(this,Au))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),ls(this,Ep).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(ls(this,Au)&&(ls(this,ck)?ls(this,Au).cancel({revert:!0}):ls(this,Au).cancelRetry()),this.scheduleGc()),ls(this,Ep).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ii(this,Gf,Cy).call(this,{type:"invalidate"})}fetch(s,r){var h,f,g;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(ls(this,Au))return ls(this,Au).continueRetry(),ls(this,Au).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:()=>(In(this,ck,!0),n.signal)})},o=()=>{const v=x8e(this.options,r),j=(()=>{const w={client:ls(this,lk),queryKey:this.queryKey,meta:this.meta};return a(w),w})();return In(this,ck,!1),this.options.persister?this.options.persister(v,j,this):v(j)},i=(()=>{const v={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:ls(this,lk),state:this.state,fetchFn:o};return a(v),v})();(h=this.options.behavior)==null||h.onFetch(i,this),In(this,ok,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=i.fetchOptions)==null?void 0:f.meta))&&Ii(this,Gf,Cy).call(this,{type:"fetch",meta:(g=i.fetchOptions)==null?void 0:g.meta});const d=v=>{var _,j,w,k;jue(v)&&v.silent||Ii(this,Gf,Cy).call(this,{type:"error",error:v}),jue(v)||((j=(_=ls(this,Ep).config).onError)==null||j.call(_,v,this),(k=(w=ls(this,Ep).config).onSettled)==null||k.call(w,this.state.data,v,this)),this.scheduleGc()};return In(this,Au,b8e({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var _,j,w,k;if(v===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(v)}catch(M){d(M);return}(j=(_=ls(this,Ep).config).onSuccess)==null||j.call(_,v,this),(k=(w=ls(this,Ep).config).onSettled)==null||k.call(w,v,this.state.error,this),this.scheduleGc()},onError:d,onFail:(v,_)=>{Ii(this,Gf,Cy).call(this,{type:"failed",failureCount:v,error:_})},onPause:()=>{Ii(this,Gf,Cy).call(this,{type:"pause"})},onContinue:()=>{Ii(this,Gf,Cy).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),ls(this,Au).start()}},g5=new WeakMap,ok=new WeakMap,Ep=new WeakMap,lk=new WeakMap,Au=new WeakMap,h6=new WeakMap,ck=new WeakMap,Gf=new WeakSet,Cy=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,...j8e(n.data,this.options),fetchMeta:s.meta??null};case"success":return In(this,ok,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 jue(a)&&a.revert&&ls(this,ok)?{...ls(this,ok),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),Nd.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),ls(this,Ep).notify({query:this,type:"updated",action:s})})},L6e);function j8e(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:v8e(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function blt(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,D6e,wlt=(D6e=class extends P3{constructor(s={}){super();Aa(this,cx);this.config=s,In(this,cx,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??dve(a,r);let l=this.get(o);return l||(l=new _lt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){ls(this,cx).has(s.queryHash)||(ls(this,cx).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=ls(this,cx).get(s.queryHash);r&&(s.destroy(),r===s&&ls(this,cx).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){Nd.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return ls(this,cx).get(s)}getAll(){return[...ls(this,cx).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>uCe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>uCe(s,n)):r}notify(s){Nd.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){Nd.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){Nd.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},cx=new WeakMap,D6e),dx,ch,dk,ux,wv,O6e,jlt=(O6e=class extends w8e{constructor(s){super();Aa(this,ux);Aa(this,dx);Aa(this,ch);Aa(this,dk);this.mutationId=s.mutationId,In(this,ch,s.mutationCache),In(this,dx,[]),this.state=s.state||k8e(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){ls(this,dx).includes(s)||(ls(this,dx).push(s),this.clearGcTimeout(),ls(this,ch).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){In(this,dx,ls(this,dx).filter(r=>r!==s)),this.scheduleGc(),ls(this,ch).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){ls(this,dx).length||(this.state.status==="pending"?this.scheduleGc():ls(this,ch).remove(this))}continue(){var s;return((s=ls(this,dk))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,d,h,f,g,v,_,j,w,k,M,S,E,D,L,B,$,V;const r=()=>{Ii(this,ux,wv).call(this,{type:"continue"})};In(this,dk,b8e({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(W,G)=>{Ii(this,ux,wv).call(this,{type:"failed",failureCount:W,error:G})},onPause:()=>{Ii(this,ux,wv).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ls(this,ch).canRun(this)}));const n=this.state.status==="pending",a=!ls(this,dk).canStart();try{if(n)r();else{Ii(this,ux,wv).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=ls(this,ch).config).onMutate)==null?void 0:l.call(o,s,this));const G=await((d=(i=this.options).onMutate)==null?void 0:d.call(i,s));G!==this.state.context&&Ii(this,ux,wv).call(this,{type:"pending",context:G,variables:s,isPaused:a})}const W=await ls(this,dk).start();return await((f=(h=ls(this,ch).config).onSuccess)==null?void 0:f.call(h,W,s,this.state.context,this)),await((v=(g=this.options).onSuccess)==null?void 0:v.call(g,W,s,this.state.context)),await((j=(_=ls(this,ch).config).onSettled)==null?void 0:j.call(_,W,null,this.state.variables,this.state.context,this)),await((k=(w=this.options).onSettled)==null?void 0:k.call(w,W,null,s,this.state.context)),Ii(this,ux,wv).call(this,{type:"success",data:W}),W}catch(W){try{throw await((S=(M=ls(this,ch).config).onError)==null?void 0:S.call(M,W,s,this.state.context,this)),await((D=(E=this.options).onError)==null?void 0:D.call(E,W,s,this.state.context)),await((B=(L=ls(this,ch).config).onSettled)==null?void 0:B.call(L,void 0,W,this.state.variables,this.state.context,this)),await((V=($=this.options).onSettled)==null?void 0:V.call($,void 0,W,s,this.state.context)),W}finally{Ii(this,ux,wv).call(this,{type:"error",error:W})}}finally{ls(this,ch).runNext(this)}}},dx=new WeakMap,ch=new WeakMap,dk=new WeakMap,ux=new WeakSet,wv=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),Nd.batch(()=>{ls(this,dx).forEach(n=>{n.onMutationUpdate(s)}),ls(this,ch).notify({mutation:this,type:"updated",action:s})})},O6e);function k8e(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ry,Kf,m6,R6e,klt=(R6e=class extends P3{constructor(s={}){super();Aa(this,Ry);Aa(this,Kf);Aa(this,m6);this.config=s,In(this,Ry,new Set),In(this,Kf,new Map),In(this,m6,0)}build(s,r,n){const a=new jlt({mutationCache:this,mutationId:++lO(this,m6)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){ls(this,Ry).add(s);const r=AO(s);if(typeof r=="string"){const n=ls(this,Kf).get(r);n?n.push(s):ls(this,Kf).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(ls(this,Ry).delete(s)){const r=AO(s);if(typeof r=="string"){const n=ls(this,Kf).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&ls(this,Kf).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=AO(s);if(typeof r=="string"){const n=ls(this,Kf).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=AO(s);if(typeof r=="string"){const a=(n=ls(this,Kf).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(){Nd.batch(()=>{ls(this,Ry).forEach(s=>{this.notify({type:"removed",mutation:s})}),ls(this,Ry).clear(),ls(this,Kf).clear()})}getAll(){return Array.from(ls(this,Ry))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>hCe(r,n))}findAll(s={}){return this.getAll().filter(r=>hCe(s,r))}notify(s){Nd.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return Nd.batch(()=>Promise.all(s.map(r=>r.continue().catch(hh))))}},Ry=new WeakMap,Kf=new WeakMap,m6=new WeakMap,R6e);function AO(t){var s;return(s=t.options.scope)==null?void 0:s.id}function vre(t){return{onFetch:(s,r)=>{var f,g,v,_,j;const n=s.options,a=(v=(g=(f=s.fetchOptions)==null?void 0:f.meta)==null?void 0:g.fetchMore)==null?void 0:v.direction,o=((_=s.state.data)==null?void 0:_.pages)||[],l=((j=s.state.data)==null?void 0:j.pageParams)||[];let i={pages:[],pageParams:[]},d=0;const h=async()=>{let w=!1;const k=E=>{Object.defineProperty(E,"signal",{enumerable:!0,get:()=>(s.signal.aborted?w=!0:s.signal.addEventListener("abort",()=>{w=!0}),s.signal)})},M=x8e(s.options,s.fetchOptions),S=async(E,D,L)=>{if(w)return Promise.reject();if(D==null&&E.pages.length)return Promise.resolve(E);const $=(()=>{const J={client:s.client,queryKey:s.queryKey,pageParam:D,direction:L?"backward":"forward",meta:s.options.meta};return k(J),J})(),V=await M($),{maxPages:W}=s.options,G=L?plt:mlt;return{pages:G(E.pages,V,W),pageParams:G(E.pageParams,D,W)}};if(a&&o.length){const E=a==="backward",D=E?N8e:Ype,L={pages:o,pageParams:l},B=D(n,L);i=await S(L,B,E)}else{const E=t??o.length;do{const D=d===0?l[0]??n.initialPageParam:Ype(n,i);if(d>0&&D==null)break;i=await S(i,D),d++}while(d{var w,k;return(k=(w=s.options).persister)==null?void 0:k.call(w,h,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=h}}}function Ype(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 N8e(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 Nlt(t,s){return s?Ype(t,s)!=null:!1}function Slt(t,s){return!s||!t.getPreviousPageParam?!1:N8e(t,s)!=null}var vc,Xv,Qv,x5,y5,Jv,v5,_5,F6e,Clt=(F6e=class{constructor(t={}){Aa(this,vc);Aa(this,Xv);Aa(this,Qv);Aa(this,x5);Aa(this,y5);Aa(this,Jv);Aa(this,v5);Aa(this,_5);In(this,vc,t.queryCache||new wlt),In(this,Xv,t.mutationCache||new klt),In(this,Qv,t.defaultOptions||{}),In(this,x5,new Map),In(this,y5,new Map),In(this,Jv,0)}mount(){lO(this,Jv)._++,ls(this,Jv)===1&&(In(this,v5,hve.subscribe(async t=>{t&&(await this.resumePausedMutations(),ls(this,vc).onFocus())})),In(this,_5,yre.subscribe(async t=>{t&&(await this.resumePausedMutations(),ls(this,vc).onOnline())})))}unmount(){var t,s;lO(this,Jv)._--,ls(this,Jv)===0&&((t=ls(this,v5))==null||t.call(this),In(this,v5,void 0),(s=ls(this,_5))==null||s.call(this),In(this,_5,void 0))}isFetching(t){return ls(this,vc).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return ls(this,Xv).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ls(this,vc).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=ls(this,vc).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(L1(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return ls(this,vc).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=ls(this,vc).get(n.queryHash),o=a==null?void 0:a.state.data,l=ult(s,o);if(l!==void 0)return ls(this,vc).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return Nd.batch(()=>ls(this,vc).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ls(this,vc).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=ls(this,vc);Nd.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=ls(this,vc);return Nd.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=Nd.batch(()=>ls(this,vc).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(hh).catch(hh)}invalidateQueries(t,s={}){return Nd.batch(()=>(ls(this,vc).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=Nd.batch(()=>ls(this,vc).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(hh)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(hh)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=ls(this,vc).build(this,s);return r.isStaleByTime(L1(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(hh).catch(hh)}fetchInfiniteQuery(t){return t.behavior=vre(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(hh).catch(hh)}ensureInfiniteQueryData(t){return t.behavior=vre(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return yre.isOnline()?ls(this,Xv).resumePausedMutations():Promise.resolve()}getQueryCache(){return ls(this,vc)}getMutationCache(){return ls(this,Xv)}getDefaultOptions(){return ls(this,Qv)}setDefaultOptions(t){In(this,Qv,t)}setQueryDefaults(t,s){ls(this,x5).set(Jk(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...ls(this,x5).values()],r={};return s.forEach(n=>{XI(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){ls(this,y5).set(Jk(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...ls(this,y5).values()],r={};return s.forEach(n=>{XI(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...ls(this,Qv).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=dve(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===uve&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...ls(this,Qv).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){ls(this,vc).clear(),ls(this,Xv).clear()}},vc=new WeakMap,Xv=new WeakMap,Qv=new WeakMap,x5=new WeakMap,y5=new WeakMap,Jv=new WeakMap,v5=new WeakMap,_5=new WeakMap,F6e),Vh,ho,p6,dh,uk,b5,e1,t1,f6,w5,j5,hk,mk,s1,k5,Oo,YA,Xpe,Qpe,Jpe,efe,tfe,sfe,rfe,C8e,z6e,S8e=(z6e=class extends P3{constructor(s,r){super();Aa(this,Oo);Aa(this,Vh);Aa(this,ho);Aa(this,p6);Aa(this,dh);Aa(this,uk);Aa(this,b5);Aa(this,e1);Aa(this,t1);Aa(this,f6);Aa(this,w5);Aa(this,j5);Aa(this,hk);Aa(this,mk);Aa(this,s1);Aa(this,k5,new Set);this.options=r,In(this,Vh,s),In(this,t1,null),In(this,e1,Zpe()),this.options.experimental_prefetchInRender||ls(this,e1).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&&(ls(this,ho).addObserver(this),fCe(ls(this,ho),this.options)?Ii(this,Oo,YA).call(this):this.updateResult(),Ii(this,Oo,efe).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return nfe(ls(this,ho),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return nfe(ls(this,ho),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ii(this,Oo,tfe).call(this),Ii(this,Oo,sfe).call(this),ls(this,ho).removeObserver(this)}setOptions(s){const r=this.options,n=ls(this,ho);if(this.options=ls(this,Vh).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ip(this.options.enabled,ls(this,ho))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ii(this,Oo,rfe).call(this),ls(this,ho).setOptions(this.options),r._defaulted&&!xre(this.options,r)&&ls(this,Vh).getQueryCache().notify({type:"observerOptionsUpdated",query:ls(this,ho),observer:this});const a=this.hasListeners();a&&gCe(ls(this,ho),n,this.options,r)&&Ii(this,Oo,YA).call(this),this.updateResult(),a&&(ls(this,ho)!==n||Ip(this.options.enabled,ls(this,ho))!==Ip(r.enabled,ls(this,ho))||L1(this.options.staleTime,ls(this,ho))!==L1(r.staleTime,ls(this,ho)))&&Ii(this,Oo,Xpe).call(this);const o=Ii(this,Oo,Qpe).call(this);a&&(ls(this,ho)!==n||Ip(this.options.enabled,ls(this,ho))!==Ip(r.enabled,ls(this,ho))||o!==ls(this,s1))&&Ii(this,Oo,Jpe).call(this,o)}getOptimisticResult(s){const r=ls(this,Vh).getQueryCache().build(ls(this,Vh),s),n=this.createResult(r,s);return Tlt(this,n)&&(In(this,dh,n),In(this,b5,this.options),In(this,uk,ls(this,ho).state)),n}getCurrentResult(){return ls(this,dh)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){ls(this,k5).add(s)}getCurrentQuery(){return ls(this,ho)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=ls(this,Vh).defaultQueryOptions(s),n=ls(this,Vh).getQueryCache().build(ls(this,Vh),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Ii(this,Oo,YA).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),ls(this,dh)))}createResult(s,r){var W;const n=ls(this,ho),a=this.options,o=ls(this,dh),l=ls(this,uk),i=ls(this,b5),h=s!==n?s.state:ls(this,p6),{state:f}=s;let g={...f},v=!1,_;if(r._optimisticResults){const G=this.hasListeners(),J=!G&&fCe(s,r),ne=G&&gCe(s,n,r,a);(J||ne)&&(g={...g,...j8e(f.data,s.options)}),r._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:j,errorUpdatedAt:w,status:k}=g;_=g.data;let M=!1;if(r.placeholderData!==void 0&&_===void 0&&k==="pending"){let G;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(G=o.data,M=!0):G=typeof r.placeholderData=="function"?r.placeholderData((W=ls(this,j5))==null?void 0:W.state.data,ls(this,j5)):r.placeholderData,G!==void 0&&(k="success",_=Kpe(o==null?void 0:o.data,G,r),v=!0)}if(r.select&&_!==void 0&&!M)if(o&&_===(l==null?void 0:l.data)&&r.select===ls(this,f6))_=ls(this,w5);else try{In(this,f6,r.select),_=r.select(_),_=Kpe(o==null?void 0:o.data,_,r),In(this,w5,_),In(this,t1,null)}catch(G){In(this,t1,G)}ls(this,t1)&&(j=ls(this,t1),_=ls(this,w5),w=Date.now(),k="error");const S=g.fetchStatus==="fetching",E=k==="pending",D=k==="error",L=E&&S,B=_!==void 0,V={status:k,fetchStatus:g.fetchStatus,isPending:E,isSuccess:k==="success",isError:D,isInitialLoading:L,isLoading:L,data:_,dataUpdatedAt:g.dataUpdatedAt,error:j,errorUpdatedAt:w,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>h.dataUpdateCount||g.errorUpdateCount>h.errorUpdateCount,isFetching:S,isRefetching:S&&!E,isLoadingError:D&&!B,isPaused:g.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:D&&B,isStale:mve(s,r),refetch:this.refetch,promise:ls(this,e1),isEnabled:Ip(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const G=ie=>{V.status==="error"?ie.reject(V.error):V.data!==void 0&&ie.resolve(V.data)},J=()=>{const ie=In(this,e1,V.promise=Zpe());G(ie)},ne=ls(this,e1);switch(ne.status){case"pending":s.queryHash===n.queryHash&&G(ne);break;case"fulfilled":(V.status==="error"||V.data!==ne.value)&&J();break;case"rejected":(V.status!=="error"||V.error!==ne.reason)&&J();break}}return V}updateResult(){const s=ls(this,dh),r=this.createResult(ls(this,ho),this.options);if(In(this,uk,ls(this,ho).state),In(this,b5,this.options),ls(this,uk).data!==void 0&&In(this,j5,ls(this,ho)),xre(r,s))return;In(this,dh,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!ls(this,k5).size)return!0;const l=new Set(o??ls(this,k5));return this.options.throwOnError&&l.add("error"),Object.keys(ls(this,dh)).some(i=>{const d=i;return ls(this,dh)[d]!==s[d]&&l.has(d)})};Ii(this,Oo,C8e).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ii(this,Oo,efe).call(this)}},Vh=new WeakMap,ho=new WeakMap,p6=new WeakMap,dh=new WeakMap,uk=new WeakMap,b5=new WeakMap,e1=new WeakMap,t1=new WeakMap,f6=new WeakMap,w5=new WeakMap,j5=new WeakMap,hk=new WeakMap,mk=new WeakMap,s1=new WeakMap,k5=new WeakMap,Oo=new WeakSet,YA=function(s){Ii(this,Oo,rfe).call(this);let r=ls(this,ho).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(hh)),r},Xpe=function(){Ii(this,Oo,tfe).call(this);const s=L1(this.options.staleTime,ls(this,ho));if(Qk||ls(this,dh).isStale||!Wpe(s))return;const n=f8e(ls(this,dh).dataUpdatedAt,s)+1;In(this,hk,setTimeout(()=>{ls(this,dh).isStale||this.updateResult()},n))},Qpe=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ls(this,ho)):this.options.refetchInterval)??!1},Jpe=function(s){Ii(this,Oo,sfe).call(this),In(this,s1,s),!(Qk||Ip(this.options.enabled,ls(this,ho))===!1||!Wpe(ls(this,s1))||ls(this,s1)===0)&&In(this,mk,setInterval(()=>{(this.options.refetchIntervalInBackground||hve.isFocused())&&Ii(this,Oo,YA).call(this)},ls(this,s1)))},efe=function(){Ii(this,Oo,Xpe).call(this),Ii(this,Oo,Jpe).call(this,Ii(this,Oo,Qpe).call(this))},tfe=function(){ls(this,hk)&&(clearTimeout(ls(this,hk)),In(this,hk,void 0))},sfe=function(){ls(this,mk)&&(clearInterval(ls(this,mk)),In(this,mk,void 0))},rfe=function(){const s=ls(this,Vh).getQueryCache().build(ls(this,Vh),this.options);if(s===ls(this,ho))return;const r=ls(this,ho);In(this,ho,s),In(this,p6,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},C8e=function(s){Nd.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(ls(this,dh))}),ls(this,Vh).getQueryCache().notify({query:ls(this,ho),type:"observerResultsUpdated"})})},z6e);function Mlt(t,s){return Ip(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function fCe(t,s){return Mlt(t,s)||t.state.data!==void 0&&nfe(t,s,s.refetchOnMount)}function nfe(t,s,r){if(Ip(s.enabled,t)!==!1&&L1(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&mve(t,s)}return!1}function gCe(t,s,r,n){return(t!==s||Ip(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&mve(t,r)}function mve(t,s){return Ip(s.enabled,t)!==!1&&t.isStaleByTime(L1(s.staleTime,t))}function Tlt(t,s){return!xre(t.getCurrentResult(),s)}var Alt=class extends S8e{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:vre()})}getOptimisticResult(t){return t.behavior=vre(),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 j,w;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,d=(w=(j=r.fetchMeta)==null?void 0:j.fetchMore)==null?void 0:w.direction,h=l&&d==="forward",f=a&&d==="forward",g=l&&d==="backward",v=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Nlt(s,r.data),hasPreviousPage:Slt(s,r.data),isFetchNextPageError:h,isFetchingNextPage:f,isFetchPreviousPageError:g,isFetchingPreviousPage:v,isRefetchError:i&&!h&&!g,isRefetching:o&&!f&&!v}}},r1,n1,Hh,Fy,d0,xse,afe,B6e,Elt=(B6e=class extends P3{constructor(r,n){super();Aa(this,d0);Aa(this,r1);Aa(this,n1);Aa(this,Hh);Aa(this,Fy);In(this,r1,r),this.setOptions(n),this.bindMethods(),Ii(this,d0,xse).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=ls(this,r1).defaultMutationOptions(r),xre(this.options,n)||ls(this,r1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ls(this,Hh),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Jk(n.mutationKey)!==Jk(this.options.mutationKey)?this.reset():((a=ls(this,Hh))==null?void 0:a.state.status)==="pending"&&ls(this,Hh).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ls(this,Hh))==null||r.removeObserver(this)}onMutationUpdate(r){Ii(this,d0,xse).call(this),Ii(this,d0,afe).call(this,r)}getCurrentResult(){return ls(this,n1)}reset(){var r;(r=ls(this,Hh))==null||r.removeObserver(this),In(this,Hh,void 0),Ii(this,d0,xse).call(this),Ii(this,d0,afe).call(this)}mutate(r,n){var a;return In(this,Fy,n),(a=ls(this,Hh))==null||a.removeObserver(this),In(this,Hh,ls(this,r1).getMutationCache().build(ls(this,r1),this.options)),ls(this,Hh).addObserver(this),ls(this,Hh).execute(r)}},r1=new WeakMap,n1=new WeakMap,Hh=new WeakMap,Fy=new WeakMap,d0=new WeakSet,xse=function(){var n;const r=((n=ls(this,Hh))==null?void 0:n.state)??k8e();In(this,n1,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},afe=function(r){Nd.batch(()=>{var n,a,o,l,i,d,h,f;if(ls(this,Fy)&&this.hasListeners()){const g=ls(this,n1).variables,v=ls(this,n1).context;(r==null?void 0:r.type)==="success"?((a=(n=ls(this,Fy)).onSuccess)==null||a.call(n,r.data,g,v),(l=(o=ls(this,Fy)).onSettled)==null||l.call(o,r.data,null,g,v)):(r==null?void 0:r.type)==="error"&&((d=(i=ls(this,Fy)).onError)==null||d.call(i,r.error,g,v),(f=(h=ls(this,Fy)).onSettled)==null||f.call(h,void 0,r.error,g,v))}this.listeners.forEach(g=>{g(ls(this,n1))})})},B6e),M8e=T.createContext(void 0),vs=t=>{const s=T.useContext(M8e);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Ilt=({client:t,children:s})=>(T.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(M8e.Provider,{value:t,children:s})),T8e=T.createContext(!1),Plt=()=>T.useContext(T8e);T8e.Provider;function Llt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Dlt=T.createContext(Llt()),Olt=()=>T.useContext(Dlt),Rlt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},Flt=t=>{T.useEffect(()=>{t.clearReset()},[t])},zlt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||y8e(r,[t.error,n])),Blt=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))}},$lt=(t,s)=>t.isLoading&&t.isFetching&&!s,Ult=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,xCe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function A8e(t,s,r){var g,v,_,j,w;const n=Plt(),a=Olt(),o=vs(),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",Blt(l),Rlt(l,a),Flt(a);const i=!o.getQueryCache().get(l.queryHash),[d]=T.useState(()=>new s(o,l)),h=d.getOptimisticResult(l),f=!n&&t.subscribed!==!1;if(T.useSyncExternalStore(T.useCallback(k=>{const M=f?d.subscribe(Nd.batchCalls(k)):hh;return d.updateResult(),M},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),T.useEffect(()=>{d.setOptions(l)},[l,d]),Ult(l,h))throw xCe(l,d,a);if(zlt({result:h,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw h.error;if((j=(_=o.getDefaultOptions().queries)==null?void 0:_._experimental_afterQuery)==null||j.call(_,l,h),l.experimental_prefetchInRender&&!Qk&&$lt(h,n)){const k=i?xCe(l,d,a):(w=o.getQueryCache().get(l.queryHash))==null?void 0:w.promise;k==null||k.catch(hh).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?h:d.trackResult(h)}function zt(t,s){return A8e(t,S8e)}function Wt(t,s){const r=vs(),[n]=T.useState(()=>new Elt(r,t));T.useEffect(()=>{n.setOptions(t)},[n,t]);const a=T.useSyncExternalStore(T.useCallback(l=>n.subscribe(Nd.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=T.useCallback((l,i)=>{n.mutate(l,i).catch(hh)},[n]);if(a.error&&y8e(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function qlt(t,s){return A8e(t,Alt)}/** * @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 QI(){return QI=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function E8e(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Hlt(){return Math.random().toString(36).substr(2,8)}function vCe(t,s){return{usr:t.state,key:t.key,idx:s}}function ife(t,s,r,n){return r===void 0&&(r=null),QI({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?L3(s):s,{state:r,key:s&&s.key||n||Hlt()})}function _re(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 L3(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 Wlt(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,h=f();h==null&&(h=0,l.replaceState(QI({},l.state,{idx:h}),""));function f(){return(l.state||{idx:null}).idx}function g(){i=l1.Pop;let k=f(),M=k==null?null:k-h;h=k,d&&d({action:i,location:w.location,delta:M})}function v(k,M){i=l1.Push;let S=ife(w.location,k,M);h=f()+1;let E=vCe(S,h),D=w.createHref(S);try{l.pushState(E,"",D)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(D)}o&&d&&d({action:i,location:w.location,delta:1})}function _(k,M){i=l1.Replace;let S=ife(w.location,k,M);h=f();let E=vCe(S,h),D=w.createHref(S);l.replaceState(E,"",D),o&&d&&d({action:i,location:w.location,delta:0})}function j(k){let M=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof k=="string"?k:_re(k);return S=S.replace(/ $/,"%20"),Yc(M,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,M)}let w={get action(){return i},get location(){return t(a,l)},listen(k){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(yCe,g),d=k,()=>{a.removeEventListener(yCe,g),d=null}},createHref(k){return s(a,k)},createURL:j,encodeLocation(k){let M=j(k);return{pathname:M.pathname,search:M.search,hash:M.hash}},push:v,replace:_,go(k){return l.go(k)}};return w}var _Ce;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(_Ce||(_Ce={}));function Glt(t,s,r){return r===void 0&&(r="/"),Klt(t,s,r)}function Klt(t,s,r,n){let a=typeof s=="string"?L3(s):s,o=pve(a.pathname||"/",r);if(o==null)return null;let l=I8e(t);Zlt(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("/")&&(Yc(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 h=D1([n,d.relativePath]),f=r.concat(d);o.children&&o.children.length>0&&(Yc(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),I8e(o.children,s,f,h)),!(o.path==null&&!o.index)&&s.push({path:h,score:sct(h,o.index),routesMeta:f})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let d of P8e(o.path))a(o,l,d)}),s}function P8e(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=P8e(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 Zlt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:rct(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Ylt=/^:[\w-]+$/,Xlt=3,Qlt=2,Jlt=1,ect=10,tct=-2,bCe=t=>t==="*";function sct(t,s){let r=t.split("/"),n=r.length;return r.some(bCe)&&(n+=tct),s&&(n+=Qlt),r.filter(a=>!bCe(a)).reduce((a,o)=>a+(Ylt.test(o)?Xlt:o===""?Jlt:ect),n)}function rct(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 nct(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:v,isOptional:_}=f;if(v==="*"){let w=i[g]||"";l=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const j=i[g];return _&&!j?h[v]=void 0:h[v]=(j||"").replace(/%2F/g,"/"),h},{}),pathname:o,pathnameBase:l,pattern:t}}function ict(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),E8e(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 oct(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return E8e(!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 pve(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 lct(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?L3(t):t;return{pathname:r?r.startsWith("/")?r:cct(r,s):s,search:hct(n),hash:mct(a)}}function cct(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 kue(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 dct(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function fve(t,s){let r=dct(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function gve(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=L3(t):(a=QI({},t),Yc(!a.pathname||!a.pathname.includes("?"),kue("?","pathname","search",a)),Yc(!a.pathname||!a.pathname.includes("#"),kue("#","pathname","hash",a)),Yc(!a.search||!a.search.includes("#"),kue("#","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=lct(a,i),h=l&&l!=="/"&&l.endsWith("/"),f=(o||l===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(h||f)&&(d.pathname+="/"),d}const D1=t=>t.join("/").replace(/\/\/+/g,"/"),uct=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),hct=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,mct=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function pct(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const L8e=["post","put","patch","delete"];new Set(L8e);const fct=["get",...L8e];new Set(fct);/** * 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 JI(){return JI=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),T.useCallback(function(h,f){if(f===void 0&&(f={}),!i.current)return;if(typeof h=="number"){n.go(h);return}let g=gve(h,JSON.parse(l),o,f.relative==="path");t==null&&s!=="/"&&(g.pathname=g.pathname==="/"?s:D1([s,g.pathname])),(f.replace?n.replace:n.push)(g,f.state,f)},[s,n,l,o,t])}const vct=T.createContext(null);function _ct(t){let s=T.useContext(Gx).outlet;return s&&T.createElement(vct.Provider,{value:t},s)}function wl(){let{matches:t}=T.useContext(Gx),s=t[t.length-1];return s?s.params:{}}function R8e(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=T.useContext(a_),{matches:a}=T.useContext(Gx),{pathname:o}=pm(),l=JSON.stringify(fve(a,n.v7_relativeSplatPath));return T.useMemo(()=>gve(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function bct(t,s){return wct(t,s)}function wct(t,s,r,n){D3()||Yc(!1);let{navigator:a}=T.useContext(a_),{matches:o}=T.useContext(Gx),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let h=pm(),f;if(s){var g;let k=typeof s=="string"?L3(s):s;d==="/"||(g=k.pathname)!=null&&g.startsWith(d)||Yc(!1),f=k}else f=h;let v=f.pathname||"/",_=v;if(d!=="/"){let k=d.replace(/^\//,"").split("/");_="/"+v.replace(/^\//,"").split("/").slice(k.length).join("/")}let j=Glt(t,{pathname:_}),w=Cct(j&&j.map(k=>Object.assign({},k,{params:Object.assign({},i,k.params),pathname:D1([d,a.encodeLocation?a.encodeLocation(k.pathname).pathname:k.pathname]),pathnameBase:k.pathnameBase==="/"?d:D1([d,a.encodeLocation?a.encodeLocation(k.pathnameBase).pathname:k.pathnameBase])})),o,r,n);return s&&w?T.createElement(bie.Provider,{value:{location:JI({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:l1.Pop}},w):w}function jct(){let t=Ect(),s=pct(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 T.createElement(T.Fragment,null,T.createElement("h2",null,"Unexpected Application Error!"),T.createElement("h3",{style:{fontStyle:"italic"}},s),r?T.createElement("pre",{style:a},r):null,null)}const kct=T.createElement(jct,null);class Nct extends T.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?T.createElement(Gx.Provider,{value:this.props.routeContext},T.createElement(D8e.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Sct(t){let{routeContext:s,match:r,children:n}=t,a=T.useContext(xve);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),T.createElement(Gx.Provider,{value:s},n)}function Cct(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 f=l.findIndex(g=>g.route.id&&(i==null?void 0:i[g.route.id])!==void 0);f>=0||Yc(!1),l=l.slice(0,Math.min(l.length,f+1))}let d=!1,h=-1;if(r&&n&&n.v7_partialHydration)for(let f=0;f=0?l=l.slice(0,h+1):l=[l[0]];break}}}return l.reduceRight((f,g,v)=>{let _,j=!1,w=null,k=null;r&&(_=i&&g.route.id?i[g.route.id]:void 0,w=g.route.errorElement||kct,d&&(h<0&&v===0?(Pct("route-fallback"),j=!0,k=null):h===v&&(j=!0,k=g.route.hydrateFallbackElement||null)));let M=s.concat(l.slice(0,v+1)),S=()=>{let E;return _?E=w:j?E=k:g.route.Component?E=T.createElement(g.route.Component,null):g.route.element?E=g.route.element:E=f,T.createElement(Sct,{match:g,routeContext:{outlet:f,matches:M,isDataRoute:r!=null},children:E})};return r&&(g.route.ErrorBoundary||g.route.errorElement||v===0)?T.createElement(Nct,{location:r.location,revalidation:r.revalidation,component:w,error:_,children:S(),routeContext:{outlet:null,matches:M,isDataRoute:!0}}):S()},null)}var F8e=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(F8e||{}),z8e=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}(z8e||{});function Mct(t){let s=T.useContext(xve);return s||Yc(!1),s}function Tct(t){let s=T.useContext(gct);return s||Yc(!1),s}function Act(t){let s=T.useContext(Gx);return s||Yc(!1),s}function B8e(t){let s=Act(),r=s.matches[s.matches.length-1];return r.route.id||Yc(!1),r.route.id}function Ect(){var t;let s=T.useContext(D8e),r=Tct(),n=B8e();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function Ict(){let{router:t}=Mct(F8e.UseNavigateStable),s=B8e(z8e.UseNavigateStable),r=T.useRef(!1);return O8e(()=>{r.current=!0}),T.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,JI({fromRouteId:s},o)))},[t,s])}const wCe={};function Pct(t,s,r){wCe[t]||(wCe[t]=!0)}function Lct(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Nue(t){let{to:s,replace:r,state:n,relative:a}=t;D3()||Yc(!1);let{future:o,static:l}=T.useContext(a_),{matches:i}=T.useContext(Gx),{pathname:d}=pm(),h=Yr(),f=gve(s,fve(i,o.v7_relativeSplatPath),d,a==="path"),g=JSON.stringify(f);return T.useEffect(()=>h(JSON.parse(g),{replace:r,state:n,relative:a}),[h,g,a,r,n]),null}function Dct(t){return _ct(t.context)}function nr(t){Yc(!1)}function Oct(t){let{basename:s="/",children:r=null,location:n,navigationType:a=l1.Pop,navigator:o,static:l=!1,future:i}=t;D3()&&Yc(!1);let d=s.replace(/^\/*/,"/"),h=T.useMemo(()=>({basename:d,navigator:o,static:l,future:JI({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=L3(n));let{pathname:f="/",search:g="",hash:v="",state:_=null,key:j="default"}=n,w=T.useMemo(()=>{let k=pve(f,d);return k==null?null:{location:{pathname:k,search:g,hash:v,state:_,key:j},navigationType:a}},[d,f,g,v,_,j,a]);return w==null?null:T.createElement(a_.Provider,{value:h},T.createElement(bie.Provider,{children:r,value:w}))}function $8e(t){let{children:s,location:r}=t;return bct(ofe(s),r)}new Promise(()=>{});function ofe(t,s){s===void 0&&(s=[]);let r=[];return T.Children.forEach(t,(n,a)=>{if(!T.isValidElement(n))return;let o=[...s,a];if(n.type===T.Fragment){r.push.apply(r,ofe(n.props.children,o));return}n.type!==nr&&Yc(!1),!n.props.index||!n.props.children||Yc(!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=ofe(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 lfe(){return lfe=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function Fct(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function zct(t,s){return t.button===0&&(!s||s==="_self")&&!Fct(t)}function cfe(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 Bct(t,s){let r=cfe(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const $ct=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Uct="6";try{window.__reactRouterVersion=Uct}catch{}const qct="startTransition",jCe=s0e[qct];function Vct(t){let{basename:s,children:r,future:n,window:a}=t,o=T.useRef();o.current==null&&(o.current=Vlt({window:a,v5Compat:!0}));let l=o.current,[i,d]=T.useState({action:l.action,location:l.location}),{v7_startTransition:h}=n||{},f=T.useCallback(g=>{h&&jCe?jCe(()=>d(g)):d(g)},[d,h]);return T.useLayoutEffect(()=>l.listen(f),[l,f]),T.useEffect(()=>Lct(n),[n]),T.createElement(Oct,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const Hct=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Wct=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bo=T.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:h,preventScrollReset:f,viewTransition:g}=s,v=Rct(s,$ct),{basename:_}=T.useContext(a_),j,w=!1;if(typeof h=="string"&&Wct.test(h)&&(j=h,Hct))try{let E=new URL(window.location.href),D=h.startsWith("//")?new URL(E.protocol+h):new URL(h),L=pve(D.pathname,_);D.origin===E.origin&&L!=null?h=L+D.search+D.hash:w=!0}catch{}let k=xct(h,{relative:a}),M=Gct(h,{replace:l,state:i,target:d,preventScrollReset:f,relative:a,viewTransition:g});function S(E){n&&n(E),E.defaultPrevented||M(E)}return T.createElement("a",lfe({},v,{href:j||k,onClick:w||o?n:S,ref:r,target:d}))});var kCe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(kCe||(kCe={}));var NCe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(NCe||(NCe={}));function Gct(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=Yr(),h=pm(),f=R8e(t,{relative:l});return T.useCallback(g=>{if(zct(g,r)){g.preventDefault();let v=n!==void 0?n:_re(h)===_re(f);d(t,{replace:v,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[h,d,f,n,a,r,t,o,l,i])}function Oc(t){let s=T.useRef(cfe(t)),r=T.useRef(!1),n=pm(),a=T.useMemo(()=>Bct(n.search,r.current?null:s.current),[n.search]),o=Yr(),l=T.useCallback((i,d)=>{const h=cfe(typeof i=="function"?i(a):i);r.current=!0,o("?"+h,d)},[o,a]);return[a,l]}var Kct=typeof Element<"u",Zct=typeof Map=="function",Yct=typeof Set=="function",Xct=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(Zct&&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(Yct&&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(Xct&&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(Kct&&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 Qct=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 Jct=fo(Qct);var edt=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 h=[r,n,a,o,l,i],f=0;d=new Error(s.replace(/%s/g,function(){return h[f++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}},tdt=edt;const SCe=fo(tdt);var sdt=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),h=0;h(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))(U8e||{}),Sue={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"]}},CCe=Object.values(U8e),yve={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},ndt=Object.entries(yve).reduce((t,[s,r])=>(t[r]=s,t),{}),ag="data-rh",Y4={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},X4=(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},adt=t=>{let s=X4(t,"title");const r=X4(t,Y4.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=X4(t,Y4.DEFAULT_TITLE);return s||n||void 0},idt=t=>X4(t,Y4.ON_CHANGE_CLIENT_STATE)||(()=>{}),Cue=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),odt=(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),xA=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&ldt(`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 h;const f=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:odt(["href"],t),bodyAttributes:Cue("bodyAttributes",t),defer:X4(t,Y4.DEFER),encode:X4(t,Y4.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:Cue("htmlAttributes",t),linkTags:xA("link",["rel","href"],t),metaTags:xA("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:xA("noscript",["innerHTML"],t),onChangeClientState:idt(t),scriptTags:xA("script",["src","innerHTML"],t),styleTags:xA("style",["cssText"],t),title:adt(t),titleAttributes:Cue("titleAttributes",t),prioritizeSeoTags:cdt(t,Y4.PRIORITIZE_SEO_TAGS)}),q8e=t=>Array.isArray(t)?t.join(""):t,udt=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(udt(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},MCe=(t,s)=>({...t,[s]:void 0}),hdt=["noscript","script","style"],dfe=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),V8e=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),mdt=(t,s,r,n)=>{const a=V8e(r),o=q8e(s);return a?`<${t} ${ag}="true" ${a}>${dfe(o,n)}`:`<${t} ${ag}="true">${dfe(o,n)}`},pdt=(t,s,r=!0)=>s.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(h=>!(h==="innerHTML"||h==="cssText")).reduce((h,f)=>{const g=typeof o[f]>"u"?f:`${f}="${dfe(o[f],r)}"`;return h?`${h} ${g}`:g},""),i=o.innerHTML||o.cssText||"",d=hdt.indexOf(t)===-1;return`${n}<${t} ${ag}="true" ${l}${d?"/>":`>${i}`}`},""),H8e=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=yve[n];return r[a||n]=t[n],r},s),fdt=(t,s,r)=>{const n={key:s,[ag]:!0},a=H8e(r,n);return[lt.createElement("title",a,s)]},vse=(t,s)=>s.map((r,n)=>{const a={key:n,[ag]:!0};return Object.keys(r).forEach(o=>{const i=yve[o]||o;if(i==="innerHTML"||i==="cssText"){const d=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:d}}else a[i]=r[o]}),lt.createElement(t,a)}),Ap=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>fdt(t,s.title,s.titleAttributes),toString:()=>mdt(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>H8e(s),toString:()=>V8e(s)};default:return{toComponent:()=>vse(t,s),toString:()=>pdt(t,s,r)}}},gdt=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=Mue(t,Sue.meta),o=Mue(s,Sue.link),l=Mue(r,Sue.script);return{priorityMethods:{toComponent:()=>[...vse("meta",a.priority),...vse("link",o.priority),...vse("script",l.priority)],toString:()=>`${Ap("meta",a.priority,n)} ${Ap("link",o.priority,n)} ${Ap("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},xdt=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:d,prioritizeSeoTags:h}=t;let{linkTags:f,metaTags:g,scriptTags:v}=t,_={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:_,linkTags:f,metaTags:g,scriptTags:v}=gdt(t)),{priority:_,base:Ap("base",s,n),bodyAttributes:Ap("bodyAttributes",r,n),htmlAttributes:Ap("htmlAttributes",a,n),link:Ap("link",f,n),meta:Ap("meta",g,n),noscript:Ap("noscript",o,n),script:Ap("script",v,n),style:Ap("style",l,n),title:Ap("title",{title:i,titleAttributes:d},n)}},ufe=xdt,EO=[],W8e=!!(typeof window<"u"&&window.document&&window.document.createElement),hfe=class{constructor(t,s){hn(this,"instances",[]);hn(this,"canUseDOM",W8e);hn(this,"context");hn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?EO:this.instances,add:t=>{(this.canUseDOM?EO:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?EO:this.instances).indexOf(t);(this.canUseDOM?EO:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=ufe({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ydt={},G8e=lt.createContext(ydt),pk,K8e=(pk=class extends T.Component{constructor(r){super(r);hn(this,"helmetData");this.helmetData=new hfe(this.props.context||{},pk.canUseDOM)}render(){return lt.createElement(G8e.Provider,{value:this.helmetData.value},this.props.children)}},hn(pk,"canUseDOM",W8e),pk),gC=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${ag}]`),a=[].slice.call(n),o=[];let l;return s&&s.length&&s.forEach(i=>{const d=document.createElement(t);for(const h in i)if(Object.prototype.hasOwnProperty.call(i,h))if(h==="innerHTML")d.innerHTML=i.innerHTML;else if(h==="cssText")d.styleSheet?d.styleSheet.cssText=i.cssText:d.appendChild(document.createTextNode(i.cssText));else{const f=h,g=typeof i[f]>"u"?"":i[f];d.setAttribute(h,g)}d.setAttribute(ag,"true"),a.some((h,f)=>(l=f,d.isEqualNode(h)))?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}},mfe=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(ag),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 h=o.indexOf(i);h!==-1&&o.splice(h,1)}for(let i=o.length-1;i>=0;i-=1)r.removeAttribute(o[i]);a.length===o.length?r.removeAttribute(ag):r.getAttribute(ag)!==l.join(",")&&r.setAttribute(ag,l.join(","))},vdt=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=q8e(t)),mfe("title",s)},TCe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:h,styleTags:f,title:g,titleAttributes:v}=t;mfe("body",n),mfe("html",a),vdt(g,v);const _={baseTag:gC("base",r),linkTags:gC("link",o),metaTags:gC("meta",l),noscriptTags:gC("noscript",i),scriptTags:gC("script",h),styleTags:gC("style",f)},j={},w={};Object.keys(_).forEach(k=>{const{newTags:M,oldTags:S}=_[k];M.length&&(j[k]=M),S.length&&(w[k]=_[k].oldTags)}),s&&s(),d(t,j,w)},yA=null,_dt=t=>{yA&&cancelAnimationFrame(yA),t.defer?yA=requestAnimationFrame(()=>{TCe(t,()=>{yA=null})}):(TCe(t),yA=null)},bdt=_dt,ACe=class extends T.Component{constructor(){super(...arguments);hn(this,"rendered",!1)}shouldComponentUpdate(s){return!rdt(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=ddt(s.get().map(o=>{const l={...o.props};return delete l.context,l}));K8e.canUseDOM?bdt(a):ufe&&(n=ufe(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}},Ume,Ih=(Ume=class extends T.Component{shouldComponentUpdate(t){return!Jct(MCe(this.props,"helmetData"),MCe(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 SCe(CCe.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 ${CCe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),SCe(!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 lt.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((d,h)=>(d[ndt[h]||h]=o[h],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 hfe)){const a=n;n=new hfe(a.context,!0),delete r.helmetData}return n?lt.createElement(ACe,{...r,context:n.value}):lt.createElement(G8e.Consumer,null,a=>lt.createElement(ACe,{...r,context:a}))}},hn(Ume,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Ume),pfe=function(t,s){return pfe=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])},pfe(t,s)};function Z8e(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");pfe(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var Fp=function(){return Fp=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 X8e(t,s){return function(r,n){s(r,n,t)}}function Q8e(t,s,r,n,a,o){function l(M){if(M!==void 0&&typeof M!="function")throw new TypeError("Function expected");return M}for(var i=n.kind,d=i==="getter"?"get":i==="setter"?"set":"value",h=!s&&t?n.static?t:t.prototype:null,f=s||(h?Object.getOwnPropertyDescriptor(h,n.name):{}),g,v=!1,_=r.length-1;_>=0;_--){var j={};for(var w in n)j[w]=w==="access"?{}:n[w];for(var w in n.access)j.access[w]=n.access[w];j.addInitializer=function(M){if(v)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(M||null))};var k=(0,r[_])(i==="accessor"?{get:f.get,set:f.set}:f[d],j);if(i==="accessor"){if(k===void 0)continue;if(k===null||typeof k!="object")throw new TypeError("Object expected");(g=l(k.get))&&(f.get=g),(g=l(k.set))&&(f.set=g),(g=l(k.init))&&a.unshift(g)}else(g=l(k))&&(i==="field"?a.unshift(g):f[d]=g)}h&&Object.defineProperty(h,n.name,f),v=!0}function J8e(t,s,r){for(var n=arguments.length>2,a=0;a0&&o[o.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!o||h[1]>o[0]&&h[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 vve(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 aRe(){for(var t=[],s=0;s1||d(_,w)})},j&&(a[_]=j(a[_])))}function d(_,j){try{h(n[_](j))}catch(w){v(o[0][3],w)}}function h(_){_.value instanceof L5?Promise.resolve(_.value.v).then(f,g):v(o[0][2],_)}function f(_){d("next",_)}function g(_){d("throw",_)}function v(_,j){_(j),o.shift(),o.length&&d(o[0][0],o[0][1])}}function lRe(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:L5(t[a](l)),done:!1}:o?o(l):l}:o}}function cRe(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 bre=="function"?bre(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(h){o({value:h,done:i})},l)}}function dRe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var wdt=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},ffe=function(t){return ffe=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},ffe(t)};function uRe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=ffe(t),n=0;n0){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=Cdt(d),d in ECe)return;ECe[d]=!0;const h=d.endsWith(".css"),f=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${f}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":Sdt,h||(g.as="script"),g.crossOrigin="",g.href=d,i&&g.setAttribute("nonce",i),document.head.appendChild(g),h)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)})},Mdt=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>O3(async()=>{const{default:n}=await Promise.resolve().then(()=>wN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class bve extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class ICe extends bve{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class PCe extends bve{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class LCe extends bve{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var gfe;(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"})(gfe||(gfe={}));class Tdt{constructor(s,{headers:r={},customFetch:n,region:a=gfe.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=Mdt(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return ra(this,arguments,void 0,function*(r,n={}){var a;try{const{headers:o,method:l,body:i,signal:d}=n;let h={},{region:f}=n;f||(f=this.region);const g=new URL(`${this.url}/${r}`);f&&f!=="any"&&(h["x-region"]=f,g.searchParams.set("forceFunctionRegion",f));let v;i&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?typeof Blob<"u"&&i instanceof Blob||i instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",v=i):typeof i=="string"?(h["Content-Type"]="text/plain",v=i):typeof FormData<"u"&&i instanceof FormData?v=i:(h["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({},h),this.headers),o),body:v,signal:d}).catch(M=>{throw M.name==="AbortError"?M:new ICe(M)}),j=_.headers.get("x-relay-error");if(j&&j==="true")throw new PCe(_);if(!_.ok)throw new LCe(_);let w=((a=_.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),k;return w==="application/json"?k=yield _.json():w==="application/octet-stream"||w==="application/pdf"?k=yield _.blob():w==="text/event-stream"?k=_:w==="multipart/form-data"?k=yield _.formData():k=yield _.text(),{data:k,error:null,response:_}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new ICe(o)}:{data:null,error:o,response:o instanceof LCe||o instanceof PCe?o.context:void 0}}})}}var Zh={};const R3=$6e(Ndt);var IO={},PO={},LO={},DO={},OO={},Adt=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")},D5=Adt();const Edt=D5.fetch,vRe=D5.fetch.bind(D5),_Re=D5.Headers,Idt=D5.Request,Pdt=D5.Response,wN=Object.freeze(Object.defineProperty({__proto__:null,Headers:_Re,Request:Idt,Response:Pdt,default:vRe,fetch:Edt},Symbol.toStringTag,{value:"Module"})),Ldt=$6e(wN);var RO={},DCe;function bRe(){if(DCe)return RO;DCe=1,Object.defineProperty(RO,"__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 RO.default=t,RO}var OCe;function wRe(){if(OCe)return OO;OCe=1,Object.defineProperty(OO,"__esModule",{value:!0});const t=R3,s=t.__importDefault(Ldt),r=t.__importDefault(bRe());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 h=>{var f,g,v,_;let j=null,w=null,k=null,M=h.status,S=h.statusText;if(h.ok){if(this.method!=="HEAD"){const B=await h.text();B===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((f=this.headers.get("Accept"))===null||f===void 0)&&f.includes("application/vnd.pgrst.plan+text"))?w=B:w=JSON.parse(B))}const D=(g=this.headers.get("Prefer"))===null||g===void 0?void 0:g.match(/count=(exact|planned|estimated)/),L=(v=h.headers.get("content-range"))===null||v===void 0?void 0:v.split("/");D&&L&&L.length>1&&(k=parseInt(L[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(w)&&(w.length>1?(j={code:"PGRST116",details:`Results contain ${w.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},w=null,k=null,M=406,S="Not Acceptable"):w.length===1?w=w[0]:w=null)}else{const D=await h.text();try{j=JSON.parse(D),Array.isArray(j)&&h.status===404&&(w=[],j=null,M=200,S="OK")}catch{h.status===404&&D===""?(M=204,S="No Content"):j={message:D}}if(j&&this.isMaybeSingle&&(!((_=j==null?void 0:j.details)===null||_===void 0)&&_.includes("0 rows"))&&(j=null,M=200,S="OK"),j&&this.shouldThrowOnError)throw new r.default(j)}return{error:j,data:w,count:k,status:M,statusText:S}});return this.shouldThrowOnError||(d=d.catch(h=>{var f,g,v;return{error:{message:`${(f=h==null?void 0:h.name)!==null&&f!==void 0?f:"FetchError"}: ${h==null?void 0:h.message}`,details:`${(g=h==null?void 0:h.stack)!==null&&g!==void 0?g:""}`,hint:"",code:`${(v=h==null?void 0:h.code)!==null&&v!==void 0?v:""}`},data:null,count:null,status:0,statusText:""}})),d.then(o,l)}returns(){return this}overrideTypes(){return this}}return OO.default=n,OO}var RCe;function jRe(){if(RCe)return DO;RCe=1,Object.defineProperty(DO,"__esModule",{value:!0});const s=R3.__importDefault(wRe());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 h=d?`${d}.order`:"order",f=this.url.searchParams.get(h);return this.url.searchParams.set(h,`${f?`${f},`:""}${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`,h=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(d,`${a}`),this.url.searchParams.set(h,`${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:h="text"}={}){var f;const g=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,d?"wal":null].filter(Boolean).join("|"),v=(f=this.headers.get("Accept"))!==null&&f!==void 0?f:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${h}; for="${v}"; options=${g};`),h==="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 DO.default=r,DO}var FCe;function wve(){if(FCe)return LO;FCe=1,Object.defineProperty(LO,"__esModule",{value:!0});const s=R3.__importDefault(jRe()),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 h="";d==="plain"?h="pl":d==="phrase"?h="ph":d==="websearch"&&(h="w");const f=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${h}fts${f}.${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 LO.default=n,LO}var zCe;function kRe(){if(zCe)return PO;zCe=1,Object.defineProperty(PO,"__esModule",{value:!0});const s=R3.__importDefault(wve());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 h=!1;const f=(a??"*").split("").map(g=>/\s/.test(g)&&!h?"":(g==='"'&&(h=!h),g)).join("");return this.url.searchParams.set("select",f),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 h=a.reduce((f,g)=>f.concat(Object.keys(g)),[]);if(h.length>0){const f=[...new Set(h)].map(g=>`"${g}"`);this.url.searchParams.set("columns",f.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 h;const f="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:f,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(h=this.fetch)!==null&&h!==void 0?h: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 PO.default=r,PO}var BCe;function Ddt(){if(BCe)return IO;BCe=1,Object.defineProperty(IO,"__esModule",{value:!0});const t=R3,s=t.__importDefault(kRe()),r=t.__importDefault(wve());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:h}={}){var f;let g;const v=new URL(`${this.url}/rpc/${o}`);let _;i||d?(g=i?"HEAD":"GET",Object.entries(l).filter(([w,k])=>k!==void 0).map(([w,k])=>[w,Array.isArray(k)?`{${k.join(",")}}`:`${k}`]).forEach(([w,k])=>{v.searchParams.append(w,k)})):(g="POST",_=l);const j=new Headers(this.headers);return h&&j.set("Prefer",`count=${h}`),new r.default({method:g,url:v,headers:j,schema:this.schemaName,body:_,fetch:(f=this.fetch)!==null&&f!==void 0?f:fetch})}}return IO.default=n,IO}Object.defineProperty(Zh,"__esModule",{value:!0});var NRe=Zh.PostgrestError=DRe=Zh.PostgrestBuilder=PRe=Zh.PostgrestTransformBuilder=ERe=Zh.PostgrestFilterBuilder=TRe=Zh.PostgrestQueryBuilder=CRe=Zh.PostgrestClient=void 0;const F3=R3,SRe=F3.__importDefault(Ddt());var CRe=Zh.PostgrestClient=SRe.default;const MRe=F3.__importDefault(kRe());var TRe=Zh.PostgrestQueryBuilder=MRe.default;const ARe=F3.__importDefault(wve());var ERe=Zh.PostgrestFilterBuilder=ARe.default;const IRe=F3.__importDefault(jRe());var PRe=Zh.PostgrestTransformBuilder=IRe.default;const LRe=F3.__importDefault(wRe());var DRe=Zh.PostgrestBuilder=LRe.default;const ORe=F3.__importDefault(bRe());NRe=Zh.PostgrestError=ORe.default;var RRe=Zh.default={PostgrestClient:SRe.default,PostgrestQueryBuilder:MRe.default,PostgrestFilterBuilder:ARe.default,PostgrestTransformBuilder:IRe.default,PostgrestBuilder:LRe.default,PostgrestError:ORe.default};const Odt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return DRe},get PostgrestClient(){return CRe},get PostgrestError(){return NRe},get PostgrestFilterBuilder(){return ERe},get PostgrestQueryBuilder(){return TRe},get PostgrestTransformBuilder(){return PRe},default:RRe},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:Rdt,PostgrestQueryBuilder:Ufs,PostgrestFilterBuilder:qfs,PostgrestTransformBuilder:Vfs,PostgrestBuilder:Hfs,PostgrestError:Wfs}=RRe||Odt;class Fdt{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 zdt="2.78.0",Bdt=`realtime-js/${zdt}`,$dt="1.0.0",xfe=1e4,Udt=1e3,qdt=100;var eI;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(eI||(eI={}));var _d;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(_d||(_d={}));var Yf;(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"})(Yf||(Yf={}));var yfe;(function(t){t.websocket="websocket"})(yfe||(yfe={}));var Fj;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Fj||(Fj={}));class Vdt{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 h=JSON.parse(n.decode(s.slice(l,s.byteLength)));return{ref:null,topic:i,event:d,payload:h}}}class FRe{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 hl;(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"})(hl||(hl={}));const $Ce=(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]=Hdt(l,t,s,a),o),{}):{}},Hdt=(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)?zRe(o,l):vfe(l)},zRe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return Zdt(s,r)}switch(t){case hl.bool:return Wdt(s);case hl.float4:case hl.float8:case hl.int2:case hl.int4:case hl.int8:case hl.numeric:case hl.oid:return Gdt(s);case hl.json:case hl.jsonb:return Kdt(s);case hl.timestamp:return Ydt(s);case hl.abstime:case hl.date:case hl.daterange:case hl.int4range:case hl.int8range:case hl.money:case hl.reltime:case hl.text:case hl.time:case hl.timestamptz:case hl.timetz:case hl.tsrange:case hl.tstzrange:return vfe(s);default:return vfe(s)}},vfe=t=>t,Wdt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Gdt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},Kdt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},Zdt=(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=>zRe(s,i))}return t},Ydt=t=>typeof t=="string"?t.replace(" ","T"):t,BRe=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 Tue{constructor(s,r,n={},a=xfe){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 UCe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(UCe||(UCe={}));class tI{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=tI.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=tI.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=tI.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,(h,f)=>{l[h]||(d[h]=f)}),this.map(l,(h,f)=>{const g=o[h];if(g){const v=f.map(k=>k.presence_ref),_=g.map(k=>k.presence_ref),j=f.filter(k=>_.indexOf(k.presence_ref)<0),w=g.filter(k=>v.indexOf(k.presence_ref)<0);j.length>0&&(i[h]=j),w.length>0&&(d[h]=w)}else i[h]=f}),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 h;const f=(h=s[i])!==null&&h!==void 0?h:[];if(s[i]=this.cloneDeep(d),f.length>0){const g=s[i].map(_=>_.presence_ref),v=f.filter(_=>g.indexOf(_.presence_ref)<0);s[i].unshift(...v)}n(i,f,d)}),this.map(l,(i,d)=>{let h=s[i];if(!h)return;const f=d.map(g=>g.presence_ref);h=h.filter(g=>f.indexOf(g.presence_ref)<0),s[i]=h,a(i,h,d),h.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 qCe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(qCe||(qCe={}));var sI;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(sI||(sI={}));var Ey;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Ey||(Ey={}));class jve{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=_d.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 Tue(this,Yf.join,this.params,this.timeout),this.rejoinTimer=new FRe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=_d.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=_d.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=_d.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=_d.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=_d.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Yf.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new tI(this),this.broadcastEndpointURL=BRe(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==_d.closed){const{config:{broadcast:l,presence:i,private:d}}=this.params,h=(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(_=>_.filter))!==null&&a!==void 0?a:[],f=!!this.bindings[sI.PRESENCE]&&this.bindings[sI.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:f}),postgres_changes:h,private:d};this.socket.accessTokenValue&&(g.access_token=this.socket.accessTokenValue),this._onError(_=>s==null?void 0:s(Ey.CHANNEL_ERROR,_)),this._onClose(()=>s==null?void 0:s(Ey.CLOSED)),this.updateJoinPayload(Object.assign({config:v},g)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:_})=>{var j;if(this.socket.setAuth(),_===void 0){s==null||s(Ey.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,k=(j=w==null?void 0:w.length)!==null&&j!==void 0?j:0,M=[];for(let S=0;S{this.state=_d.errored,s==null||s(Ey.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(Ey.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===_d.joined&&s===sI.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 h=await i.json();d=h.error||h.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 h=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=h.body)===null||a===void 0?void 0:a.cancel()),h.ok?"ok":"error"}catch(h){return h.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var l,i,d;const h=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"),h.receive("ok",()=>o("ok")),h.receive("error",()=>o("error")),h.receive("timeout",()=>o("timed out"))})}updateJoinPayload(s){this.joinPush.updatePayload(s)}unsubscribe(s=this.timeout){this.state=_d.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Yf.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new Tue(this,Yf.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=_d.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 Tue(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>qdt){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:h,join:f}=Yf;if(n&&[i,d,h,f].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 j,w,k;return((j=_.filter)===null||j===void 0?void 0:j.event)==="*"||((k=(w=_.filter)===null||w===void 0?void 0:w.event)===null||k===void 0?void 0:k.toLocaleLowerCase())===l}).map(_=>_.callback(v,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var j,w,k,M,S,E;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in _){const D=_.id,L=(j=_.filter)===null||j===void 0?void 0:j.event;return D&&((w=r.ids)===null||w===void 0?void 0:w.includes(D))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((k=r.data)===null||k===void 0?void 0:k.type.toLocaleLowerCase()))}else{const D=(S=(M=_==null?void 0:_.filter)===null||M===void 0?void 0:M.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return D==="*"||D===((E=r==null?void 0:r.event)===null||E===void 0?void 0:E.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof v=="object"&&"ids"in v){const j=v.data,{schema:w,table:k,commit_timestamp:M,type:S,errors:E}=j;v=Object.assign(Object.assign({},{schema:w,table:k,commit_timestamp:M,eventType:S,new:{},old:{},errors:E}),this._getPayloadRecords(j))}_.callback(v,n)})}_isClosed(){return this.state===_d.closed}_isJoined(){return this.state===_d.joined}_isJoining(){return this.state===_d.joining}_isLeaving(){return this.state===_d.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&&jve.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(Yf.close,{},s)}_onError(s){this._on(Yf.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=_d.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=$Ce(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=$Ce(s.columns,s.old_record)),r}}const Aue=()=>{},FO={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},Xdt=[1e3,2e3,5e3,1e4],Qdt=1e4,Jdt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class eut{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=xfe,this.transport=null,this.heartbeatIntervalMs=FO.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Aue,this.ref=0,this.reconnectTimer=null,this.logger=Aue,this.conn=null,this.sendBuffer=[],this.serializer=new Vdt,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)=>O3(async()=>{const{default:i}=await Promise.resolve().then(()=>wN);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}/${yfe.websocket}`,this.httpEndpoint=BRe(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=Fdt.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:$dt}))}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 eI.connecting:return Fj.Connecting;case eI.open:return Fj.Open;case eI.closing:return Fj.Closing;default:return Fj.Closed}}isConnected(){return this.connectionState()===Fj.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 jve(`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(Udt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},FO.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(h){this.log("error","error in heartbeat callback",h)}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(h=>h._isMember(n)).forEach(h=>h._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(Yf.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([Jdt],{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:Bdt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(Yf.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 FRe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},FO.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(s){var r,n,a,o,l,i,d,h,f;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:xfe,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:FO.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:Aue,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=>Xdt[g-1]||Qdt,this.encode=(h=s==null?void 0:s.encode)!==null&&h!==void 0?h:(g,v)=>v(JSON.stringify(g)),this.decode=(f=s==null?void 0:s.decode)!==null&&f!==void 0?f: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 kve extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function ec(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class tut extends kve{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 _fe extends kve{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const Nve=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>O3(async()=>{const{default:n}=await Promise.resolve().then(()=>wN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},sut=()=>ra(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield O3(()=>Promise.resolve().then(()=>wN),void 0)).Response:Response}),bfe=t=>{if(Array.isArray(t))return t.map(r=>bfe(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]=bfe(n)}),s},rut=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)},Eue=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)},nut=(t,s,r)=>ra(void 0,void 0,void 0,function*(){const n=yield sut();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 tut(Eue(a),o,l))}).catch(a=>{s(new _fe(Eue(a),a))}):s(new _fe(Eue(t),t))}),aut=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(rut(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 M6(t,s,r,n,a,o){return ra(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,aut(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=>nut(d,i,n))})})}function eP(t,s,r,n){return ra(this,void 0,void 0,function*(){return M6(t,"GET",s,r,n)})}function Wf(t,s,r,n,a){return ra(this,void 0,void 0,function*(){return M6(t,"POST",s,n,a,r)})}function wfe(t,s,r,n,a){return ra(this,void 0,void 0,function*(){return M6(t,"PUT",s,n,a,r)})}function iut(t,s,r,n){return ra(this,void 0,void 0,function*(){return M6(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function Sve(t,s,r,n,a){return ra(this,void 0,void 0,function*(){return M6(t,"DELETE",s,n,a,r)})}class out{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return ra(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(ec(s))return{data:null,error:s};throw s}})}}var $Re;class lut{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[$Re]="BlobDownloadBuilder",this.promise=null}asStream(){return new out(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 ra(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(ec(s))return{data:null,error:s};throw s}})}}$Re=Symbol.toStringTag;const cut={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},VCe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class dut{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=Nve(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return ra(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},VCe),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 h=this._removeEmptyFolders(r),f=this._getFinalPath(h),g=yield(s=="PUT"?wfe:Wf)(this.fetch,`${this.url}/object/${f}`,o,Object.assign({headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{}));return{data:{path:h,id:g.Id,fullPath:g.Key},error:null}}catch(o){if(this.shouldThrowOnError)throw o;if(ec(o))return{data:null,error:o};throw o}})}upload(s,r,n){return ra(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return ra(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 h=Object.assign({upsert:VCe.upsert},a),f=Object.assign(Object.assign({},this.headers),{"x-upsert":String(h.upsert)});typeof Blob<"u"&&n instanceof Blob?(d=new FormData,d.append("cacheControl",h.cacheControl),d.append("",n)):typeof FormData<"u"&&n instanceof FormData?(d=n,d.append("cacheControl",h.cacheControl)):(d=n,f["cache-control"]=`max-age=${h.cacheControl}`,f["content-type"]=h.contentType);const g=yield wfe(this.fetch,i.toString(),d,{headers:f});return{data:{path:o,fullPath:g.Key},error:null}}catch(d){if(this.shouldThrowOnError)throw d;if(ec(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(s,r){return ra(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 Wf(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 kve("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ec(n))return{data:null,error:n};throw n}})}update(s,r,n){return ra(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return ra(this,void 0,void 0,function*(){try{return{data:yield Wf(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(ec(a))return{data:null,error:a};throw a}})}copy(s,r,n){return ra(this,void 0,void 0,function*(){try{return{data:{path:(yield Wf(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(ec(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return ra(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield Wf(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(ec(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return ra(this,void 0,void 0,function*(){try{const a=yield Wf(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(ec(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=()=>eP(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new lut(d,this.shouldThrowOnError)}info(s){return ra(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield eP(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:bfe(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ec(n))return{data:null,error:n};throw n}})}exists(s){return ra(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield iut(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ec(n)&&n instanceof _fe){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 h=a.join("&");return h!==""&&(h=`?${h}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${h}`)}}}remove(s){return ra(this,void 0,void 0,function*(){try{return{data:yield Sve(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ec(r))return{data:null,error:r};throw r}})}list(s,r,n){return ra(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},cut),r),{prefix:s||""});return{data:yield Wf(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(ec(a))return{data:null,error:a};throw a}})}listV2(s,r){return ra(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield Wf(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(ec(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 URe="2.78.0",qRe={"X-Client-Info":`storage-js/${URe}`};class uut{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({},qRe),r),this.fetch=Nve(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return ra(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield eP(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ec(r))return{data:null,error:r};throw r}})}getBucket(s){return ra(this,void 0,void 0,function*(){try{return{data:yield eP(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ec(r))return{data:null,error:r};throw r}})}createBucket(s){return ra(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield Wf(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(ec(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return ra(this,void 0,void 0,function*(){try{return{data:yield wfe(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(ec(n))return{data:null,error:n};throw n}})}emptyBucket(s){return ra(this,void 0,void 0,function*(){try{return{data:yield Wf(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ec(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ra(this,void 0,void 0,function*(){try{return{data:yield Sve(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ec(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 hut{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},qRe),r),this.fetch=Nve(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ra(this,void 0,void 0,function*(){try{return{data:yield Wf(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ec(r))return{data:null,error:r};throw r}})}listBuckets(s){return ra(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 eP(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ec(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ra(this,void 0,void 0,function*(){try{return{data:yield Sve(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(ec(r))return{data:null,error:r};throw r}})}}const Cve={"X-Client-Info":`storage-js/${URe}`,"Content-Type":"application/json"};class VRe extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function Fm(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class Iue extends VRe{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 mut extends VRe{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var HCe;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(HCe||(HCe={}));const Mve=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>O3(async()=>{const{default:n}=await Promise.resolve().then(()=>wN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},put=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)},WCe=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),fut=(t,s,r)=>ra(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 Iue(WCe(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new Iue(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new Iue(i,a,l))}}else s(new mut(WCe(t),t))}),gut=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(put(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 xut(t,s,r,n,a,o){return ra(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,gut(s,n,a,o)).then(d=>{if(!d.ok)throw d;if(n!=null&&n.noResolveJson)return d;const h=d.headers.get("content-type");return!h||!h.includes("application/json")?{}:d.json()}).then(d=>l(d)).catch(d=>fut(d,i,n))})})}function zm(t,s,r,n,a){return ra(this,void 0,void 0,function*(){return xut(t,"POST",s,n,a,r)})}class yut{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Cve),r),this.fetch=Mve(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return ra(this,void 0,void 0,function*(){try{return{data:(yield zm(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}getIndex(s,r){return ra(this,void 0,void 0,function*(){try{return{data:yield zm(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Fm(n))return{data:null,error:n};throw n}})}listIndexes(s){return ra(this,void 0,void 0,function*(){try{return{data:yield zm(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return ra(this,void 0,void 0,function*(){try{return{data:(yield zm(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Fm(n))return{data:null,error:n};throw n}})}}class vut{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Cve),r),this.fetch=Mve(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return ra(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 zm(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}getVectors(s){return ra(this,void 0,void 0,function*(){try{return{data:yield zm(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}listVectors(s){return ra(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 zm(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}queryVectors(s){return ra(this,void 0,void 0,function*(){try{return{data:yield zm(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}deleteVectors(s){return ra(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 zm(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}}class _ut{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Cve),r),this.fetch=Mve(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ra(this,void 0,void 0,function*(){try{return{data:(yield zm(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}getBucket(s){return ra(this,void 0,void 0,function*(){try{return{data:yield zm(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}listBuckets(){return ra(this,arguments,void 0,function*(s={}){try{return{data:yield zm(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ra(this,void 0,void 0,function*(){try{return{data:(yield zm(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fm(r))return{data:null,error:r};throw r}})}}class but extends _ut{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new wut(this.url,this.headers,s,this.fetch)}}class wut extends yut{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return ra(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 ra(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 ra(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 ra(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new jut(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class jut extends vut{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 ra(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 ra(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 ra(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 ra(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 ra(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class kut extends uut{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new dut(this.url,this.headers,s,this.fetch)}get vectors(){return new but(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new hut(this.url+"/iceberg",this.headers,this.fetch)}}const Nut="2.78.0";let XA="";typeof Deno<"u"?XA="deno":typeof document<"u"?XA="web":typeof navigator<"u"&&navigator.product==="ReactNative"?XA="react-native":XA="node";const Sut={"X-Client-Info":`supabase-js-${XA}/${Nut}`},Cut={headers:Sut},Mut={schema:"public"},Tut={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Aut={},Eut=t=>{let s;return t?s=t:typeof fetch>"u"?s=vRe:s=fetch,(...r)=>s(...r)},Iut=()=>typeof Headers>"u"?_Re:Headers,Put=(t,s,r)=>{const n=Eut(r),a=Iut();return async(o,l)=>{var i;const d=(i=await s())!==null&&i!==void 0?i:t;let h=new a(l==null?void 0:l.headers);return h.has("apikey")||h.set("apikey",t),h.has("Authorization")||h.set("Authorization",`Bearer ${d}`),n(o,Object.assign(Object.assign({},l),{headers:h}))}};function Lut(t){return t.endsWith("/")?t:t+"/"}function Dut(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:d,auth:h,realtime:f,global:g}=s,v={db:Object.assign(Object.assign({},d),a),auth:Object.assign(Object.assign({},h),o),realtime:Object.assign(Object.assign({},f),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 Out(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(Lut(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const HRe="2.78.0",OC=30*1e3,jfe=3,Pue=jfe*OC,Rut="http://localhost:9999",Fut="supabase.auth.token",zut={"X-Client-Info":`gotrue-js/${HRe}`},kfe="X-Supabase-Api-Version",WRe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},But=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,$ut=10*60*1e3;class tP extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function va(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Uut extends tP{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function qut(t){return va(t)&&t.name==="AuthApiError"}class zj extends tP{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class o_ extends tP{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class Bf extends o_{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Vut(t){return va(t)&&t.name==="AuthSessionMissingError"}class xC extends o_{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class zO extends o_{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class BO extends o_{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 Hut(t){return va(t)&&t.name==="AuthImplicitGrantRedirectError"}class GCe extends o_{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 Nfe extends o_{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function Lue(t){return va(t)&&t.name==="AuthRetryableFetchError"}class KCe extends o_{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class Sfe extends o_{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const wre="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ZCe=` \r=`.split(""),Wut=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(wre[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(wre[n]),s.queuedBits-=6}}function GRe(t,s,r){const n=Wut[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 XCe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{Zut(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 Kut(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}Gut(n,s)}}function Zut(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 Q4(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function Wj(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>YCe(a,r,n)),YCe(null,r,n),s.join("")}function Xut(t){return Math.round(Date.now()/1e3)+t}function Qut(){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 lh=()=>typeof window<"u"&&typeof document<"u",db={tested:!1,writable:!1},KRe=()=>{if(!lh())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(db.tested)return db.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),db.tested=!0,db.writable=!0}catch{db.tested=!0,db.writable=!1}return db.writable};function Jut(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 ZRe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>O3(async()=>{const{default:n}=await Promise.resolve().then(()=>wN);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},eht=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",RC=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},ub=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},yv=async(t,s)=>{await t.removeItem(s)};class jie{constructor(){this.promise=new jie.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}jie.promiseConstructor=Promise;function Due(t){const s=t.split(".");if(s.length!==3)throw new Sfe("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function sht(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 rht(t){return("0"+t.toString(16)).substr(-2)}function nht(){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,rht).join("")}async function aht(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 iht(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 aht(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function yC(t,s,r=!1){const n=nht();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await RC(t,`${s}-code-verifier`,a);const o=await iht(n);return[o,n===o?"plain":"s256"]}const oht=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function lht(t){const s=t.headers.get(kfe);if(!s||!s.match(oht))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function cht(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 dht(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 uht=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function vC(t){if(!uht.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Oue(){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 hht(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 QCe(t){return JSON.parse(JSON.stringify(t))}const Ij=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),mht=[502,503,504];async function JCe(t){var s;if(!eht(t))throw new Nfe(Ij(t),0);if(mht.includes(t.status))throw new Nfe(Ij(t),t.status);let r;try{r=await t.json()}catch(o){throw new zj(Ij(o),o)}let n;const a=lht(t);if(a&&a.getTime()>=WRe["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 KCe(Ij(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new Bf}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 KCe(Ij(r),t.status,r.weak_password.reasons);throw new Uut(Ij(r),t.status||500,n)}const pht=(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 si(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[kfe]||(o[kfe]=WRe["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 fht(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 fht(t,s,r,n,a,o){const l=pht(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(d){throw console.error(d),new Nfe(Ij(d),0)}if(i.ok||await JCe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await JCe(d)}}function $f(t){var s;let r=null;yht(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Xut(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function e4e(t){const s=$f(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 Vv(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function ght(t){return{data:t,error:null}}function xht(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=i_(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 t4e(t){return t}function yht(t){return t.access_token&&t.refresh_token&&t.expires_in}const Rue=["global","local","others"];class vht{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=ZRe(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=Rue[0]){if(Rue.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Rue.join(", ")}`);try{return await si(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(va(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await si(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:Vv})}catch(n){if(va(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=i_(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 si(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:xht,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(va(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await si(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:Vv})}catch(r){if(va(r))return{data:{user:null},error:r};throw r}}async listUsers(s){var r,n,a,o,l,i,d;try{const h={nextPage:null,lastPage:0,total:0},f=await si(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:t4e});if(f.error)throw f.error;const g=await f.json(),v=(l=f.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=f.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(j=>{const w=parseInt(j.split(";")[0].split("=")[1].substring(0,1)),k=JSON.parse(j.split(";")[1].split("=")[1]);h[`${k}Page`]=w}),h.total=parseInt(v)),{data:Object.assign(Object.assign({},g),h),error:null}}catch(h){if(va(h))return{data:{users:[]},error:h};throw h}}async getUserById(s){vC(s);try{return await si(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:Vv})}catch(r){if(va(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){vC(s);try{return await si(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:Vv})}catch(n){if(va(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){vC(s);try{return await si(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:Vv})}catch(n){if(va(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){vC(s.userId);try{const{data:r,error:n}=await si(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(va(r))return{data:null,error:r};throw r}}async _deleteFactor(s){vC(s.userId),vC(s.id);try{return{data:await si(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(va(r))return{data:null,error:r};throw r}}async _listOAuthClients(s){var r,n,a,o,l,i,d;try{const h={nextPage:null,lastPage:0,total:0},f=await si(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:t4e});if(f.error)throw f.error;const g=await f.json(),v=(l=f.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=f.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(j=>{const w=parseInt(j.split(";")[0].split("=")[1].substring(0,1)),k=JSON.parse(j.split(";")[1].split("=")[1]);h[`${k}Page`]=w}),h.total=parseInt(v)),{data:Object.assign(Object.assign({},g),h),error:null}}catch(h){if(va(h))return{data:{clients:[]},error:h};throw h}}async _createOAuthClient(s){try{return await si(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(va(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await si(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(va(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await si(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(va(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await si(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(va(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await si(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(va(r))return{data:null,error:r};throw r}}}function s4e(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const _C={debug:!!(globalThis&&KRe()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class YRe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class _ht extends YRe{}async function bht(t,s,r){_C.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),_C.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){_C.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{_C.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw _C.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new _ht(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(_C.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 wht(){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 XRe(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function jht(t){return parseInt(t,16)}function kht(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function Nht(t){var s;const{chainId:r,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:d,resources:h,scheme:f,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 _=XRe(t.address),j=f?`${f}://${n}`:n,w=t.statement?`${t.statement} `:"",k=`${j} wants you to sign in with your Ethereum account: ${_} ${w}`;let M=`URI: ${g} Version: ${v} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(M+=` Expiration Time: ${a.toISOString()}`),i&&(M+=` Not Before: ${i.toISOString()}`),d&&(M+=` Request ID: ${d}`),h){let S=` Resources:`;for(const E of h){if(!E||typeof E!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${E}`);S+=` - ${E}`}M+=S}return`${k} ${M}`}class id 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 jre extends id{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function Sht({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 id({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 id({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 id({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 id({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 id({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new id({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 id({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new id({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(QRe(l)){if(o.rp.id!==l)return new id({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new id({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 id({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 id({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 id({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Cht({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 id({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new id({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(QRe(n)){if(r.rpId!==n)return new id({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new id({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new id({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 id({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Mht{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 Tht=new Mht;function Aht(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=i_(t,["challenge","user","excludeCredentials"]),o=Q4(s).buffer,l=Object.assign(Object.assign({},r),{id:Q4(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]=kre(i,l):n[o]=kre(l)}else n[o]=l}return n}function Fht(t,s){return kre(Oht,t,s||{})}function zht(t,s){return kre(Rht,t,s||{})}class Bht{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??Tht.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:h}=l.webauthn.credential_options.publicKey;h.name||(h.name=`${h.id}:${n}`),h.displayName||(h.displayName=h.name)}switch(l.webauthn.type){case"create":{const h=Fht(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:f,error:g}=await Lht({publicKey:h,signal:d});return f?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:f}},error:null}:{data:null,error:g}}case"request":{const h=zht(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:f,error:g}=await Dht(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:h,signal:d}));return f?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:f}},error:null}:{data:null,error:g}}}}catch(l){return va(l)?{data:null,error:l}:{data:null,error:new zj("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 tP("rpId is required for WebAuthn authentication")};try{if(!r4e())return{data:null,error:new zj("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 va(l)?{data:null,error:l}:{data:null,error:new zj("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 tP("rpId is required for WebAuthn registration")};try{if(!r4e())return{data:null,error:new zj("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(f=>{var g;return(g=f.data)===null||g===void 0?void 0:g.all.find(v=>v.factor_type==="webauthn"&&v.friendly_name===s&&v.status!=="unverified")}).then(f=>f?this.client.mfa.unenroll({factorId:f==null?void 0:f.id}):void 0),{data:null,error:i};const{data:d,error:h}=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:h}}catch(l){return va(l)?{data:null,error:l}:{data:null,error:new zj("Unexpected error in register",l)}}}}wht();const $ht={url:Rut,storageKey:Fut,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:zut,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function n4e(t,s,r){return await r()}const bC={};class sP{get jwks(){var s,r;return(r=(s=bC[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){bC[this.storageKey]=Object.assign(Object.assign({},bC[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=bC[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){bC[this.storageKey]=Object.assign(Object.assign({},bC[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=sP.nextInstanceID,sP.nextInstanceID+=1,this.instanceID>0&&lh()&&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({},$ht),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 vht({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=ZRe(a.fetch),this.lock=a.lock||n4e,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:lh()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=bht:this.lock=n4e,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 Bht(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:KRe()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=s4e(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=s4e(this.memoryStorage)),lh()&&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} (${HRe}) ${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=Jut(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),lh()&&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),Hut(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 va(r)?{error:r}:{error:new zj("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await si(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:$f}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,h=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:h,session:d},error:null}}catch(o){if(va(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:f,password:g,options:v}=s;let _=null,j=null;this.flowType==="pkce"&&([_,j]=await yC(this.storage,this.storageKey)),o=await si(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:v==null?void 0:v.emailRedirectTo,body:{email:f,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:j},xform:$f})}else if("phone"in s){const{phone:f,password:g,options:v}=s;o=await si(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:f,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:$f})}else throw new zO("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,h=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:h,session:d},error:null}}catch(o){if(va(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 si(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:e4e})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await si(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:e4e})}else throw new zO("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 xC}:(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(va(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,h,f,g,v;let _,j;if("message"in s)_=s.message,j=s.signature;else{const{chain:w,wallet:k,statement:M,options:S}=s;let E;if(lh())if(typeof k=="object")E=k;else{const W=window;if("ethereum"in W&&typeof W.ethereum=="object"&&"request"in W.ethereum&&typeof W.ethereum.request=="function")E=W.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 k!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");E=k}const D=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),L=await E.request({method:"eth_requestAccounts"}).then(W=>W).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 B=XRe(L[0]);let $=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!$){const W=await E.request({method:"eth_chainId"});$=jht(W)}const V={domain:D.host,address:B,statement:M,uri:D.href,version:"1",chainId:$,nonce:(a=S==null?void 0:S.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=S==null?void 0:S.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=S==null?void 0:S.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(d=S==null?void 0:S.signInWithEthereum)===null||d===void 0?void 0:d.notBefore,requestId:(h=S==null?void 0:S.signInWithEthereum)===null||h===void 0?void 0:h.requestId,resources:(f=S==null?void 0:S.signInWithEthereum)===null||f===void 0?void 0:f.resources};_=Nht(V),j=await E.request({method:"personal_sign",params:[kht(_),B]})}try{const{data:w,error:k}=await si(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:_,signature:j},!((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:$f});if(k)throw k;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new xC}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:k})}catch(w){if(va(w))return{data:{user:null,session:null},error:w};throw w}}async signInWithSolana(s){var r,n,a,o,l,i,d,h,f,g,v,_;let j,w;if("message"in s)j=s.message,w=s.signature;else{const{chain:k,wallet:M,statement:S,options:E}=s;let D;if(lh())if(typeof M=="object")D=M;else{const B=window;if("solana"in B&&typeof B.solana=="object"&&("signIn"in B.solana&&typeof B.solana.signIn=="function"||"signMessage"in B.solana&&typeof B.solana.signMessage=="function"))D=B.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 M!="object"||!(E!=null&&E.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");D=M}const L=new URL((r=E==null?void 0:E.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in D&&D.signIn){const B=await D.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},E==null?void 0:E.signInWithSolana),{version:"1",domain:L.host,uri:L.href}),S?{statement:S}:null));let $;if(Array.isArray(B)&&B[0]&&typeof B[0]=="object")$=B[0];else if(B&&typeof B=="object"&&"signedMessage"in B&&"signature"in B)$=B;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)j=typeof $.signedMessage=="string"?$.signedMessage:new TextDecoder().decode($.signedMessage),w=$.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in D)||typeof D.signMessage!="function"||!("publicKey"in D)||typeof D!="object"||!D.publicKey||!("toBase58"in D.publicKey)||typeof D.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");j=[`${L.host} wants you to sign in with your Solana account:`,D.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${L.href}`,`Issued At: ${(a=(n=E==null?void 0:E.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=E==null?void 0:E.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${E.signInWithSolana.notBefore}`]:[],...!((l=E==null?void 0:E.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${E.signInWithSolana.expirationTime}`]:[],...!((i=E==null?void 0:E.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${E.signInWithSolana.chainId}`]:[],...!((d=E==null?void 0:E.signInWithSolana)===null||d===void 0)&&d.nonce?[`Nonce: ${E.signInWithSolana.nonce}`]:[],...!((h=E==null?void 0:E.signInWithSolana)===null||h===void 0)&&h.requestId?[`Request ID: ${E.signInWithSolana.requestId}`]:[],...!((g=(f=E==null?void 0:E.signInWithSolana)===null||f===void 0?void 0:f.resources)===null||g===void 0)&&g.length?["Resources",...E.signInWithSolana.resources.map($=>`- ${$}`)]:[]].join(` `);const B=await D.signMessage(new TextEncoder().encode(j),"utf8");if(!B||!(B instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=B}}try{const{data:k,error:M}=await si(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:j,signature:Wj(w)},!((v=s.options)===null||v===void 0)&&v.captchaToken?{gotrue_meta_security:{captcha_token:(_=s.options)===null||_===void 0?void 0:_.captchaToken}}:null),xform:$f});if(M)throw M;return!k||!k.session||!k.user?{data:{user:null,session:null},error:new xC}:(k.session&&(await this._saveSession(k.session),await this._notifyAllSubscribers("SIGNED_IN",k.session)),{data:Object.assign({},k),error:M})}catch(k){if(va(k))return{data:{user:null,session:null},error:k};throw k}}async _exchangeCodeForSession(s){const r=await ub(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await si(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:$f});if(await yv(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new xC}:(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(va(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 si(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:$f}),{data:d,error:h}=i;return h?{data:{user:null,session:null},error:h}:!d||!d.session||!d.user?{data:{user:null,session:null},error:new xC}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:h})}catch(r){if(va(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 h=null,f=null;this.flowType==="pkce"&&([h,f]=await yC(this.storage,this.storageKey));const{error:g}=await si(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:h,code_challenge_method:f},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:h,error:f}=await si(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:h==null?void 0:h.message_id},error:f}}throw new zO("You must provide either an email or phone number.")}catch(i){if(va(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 si(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:$f});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const d=l.session,h=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:h,session:d},error:null}}catch(a){if(va(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 yC(this.storage,this.storageKey)),await si(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:ght})}catch(o){if(va(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 Bf;const{error:a}=await si(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(va(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 si(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 si(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 zO("You must provide either an email or phone number and a type")}catch(r){if(va(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 ub(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 si(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:Vv}):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 Bf}:await si(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:Vv})})}catch(r){if(va(r))return Vut(r)&&(await this._removeSession(),await yv(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 Bf;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&s.email!=null&&([i,d]=await yC(this.storage,this.storageKey));const{data:h,error:f}=await si(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:Vv});if(f)throw f;return l.user=h.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(va(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 Bf;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=Due(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(va(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 Bf;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(va(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!lh())throw new BO("No browser detected.");if(s.error||s.error_description||s.error_code)throw new BO(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 GCe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new BO("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 GCe("No code detected.");const{data:S,error:E}=await this._exchangeCodeForSession(s.code);if(E)throw E;const D=new URL(window.location.href);return D.searchParams.delete("code"),window.history.replaceState(window.history.state,"",D.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:d,token_type:h}=s;if(!o||!i||!l||!h)throw new BO("No session defined in URL");const f=Math.round(Date.now()/1e3),g=parseInt(i);let v=f+g;d&&(v=parseInt(d));const _=v-f;_*1e3<=OC&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${g}s`);const j=v-g;f-j>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",j,v,f):f-j<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",j,v,f);const{data:w,error:k}=await this._getUser(o);if(k)throw k;const M={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:g,expires_at:v,refresh_token:l,token_type:h,user:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:M,redirectType:s.type},error:null}}catch(n){if(va(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 ub(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&&!(qut(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await yv(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=Qut(),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 yC(this.storage,this.storageKey,!0));try{return await si(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(va(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(va(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,h,f;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 si(this.fetch,"GET",_,{headers:this.headers,jwt:(f=(h=g.session)===null||h===void 0?void 0:h.access_token)!==null&&f!==void 0?f:void 0})});if(a)throw a;return lh()&&!(!((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(va(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:h,nonce:f}=s,g=await si(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:h,nonce:f,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:$f}),{data:v,error:_}=g;return _?{data:{user:null,session:null},error:_}:!v||!v.session||!v.user?{data:{user:null,session:null},error:new xC}:(v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("USER_UPDATED",v.session)),{data:v,error:_})}catch(a){if(va(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 si(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(va(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 sht(async a=>(a>0&&await tht(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await si(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:$f})),(a,o)=>{const l=200*Math.pow(2,a);return o&&Lue(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(),OC);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)/OC);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${OC}ms, refresh threshold is ${jfe} ticks`),a<=jfe&&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 YRe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!lh()||!(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 yC(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 si(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(va(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:h}=await si(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 h?{data:null,error:h}:(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(va(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"?Iht(s.webauthn.credential_response):Pht(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:d}=await si(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(va(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 si(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:Aht(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:Eht(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(va(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}=Due(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(f=>f.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(i="aal2");const h=o.amr||[];return{data:{currentLevel:l,nextLevel:i,currentAuthenticationMethods:h},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 si(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 Bf}})}catch(r){if(va(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 Bf};const l=await si(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&&lh()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(va(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 Bf};const l=await si(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&&lh()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(va(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+$ut>a)return n;const{data:o,error:l}=await si(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:j}=await this.getSession();if(j||!_.session)return{data:null,error:j};n=_.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:d}}=Due(n);r!=null&&r.allowExpired||cht(o.exp);const h=!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(!h){const{error:_}=await this.getUser(n);if(_)throw _;return{data:{claims:o,header:a,signature:l},error:null}}const f=dht(a.alg),g=await crypto.subtle.importKey("jwk",h,f,!0,["verify"]);if(!await crypto.subtle.verify(f,g,l,Yut(`${i}.${d}`)))throw new Sfe("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(va(n))return{data:null,error:n};throw n}}}sP.nextInstanceID=0;const Uht=sP;class qht extends Uht{constructor(s){super(s)}}class Vht{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=Out(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`,h={db:Mut,realtime:Aut,auth:Object.assign(Object.assign({},Tut),{storageKey:d}),global:Cut},f=Dut(n??{},h);this.storageKey=(a=f.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=f.global.headers)!==null&&o!==void 0?o:{},f.accessToken?(this.accessToken=f.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=f.auth)!==null&&l!==void 0?l:{},this.headers,f.global.fetch),this.fetch=Put(r,this._getAccessToken.bind(this),f.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},f.realtime)),this.rest=new Rdt(new URL("rest/v1",i).href,{headers:this.headers,schema:f.db.schema,fetch:this.fetch}),this.storage=new kut(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),f.accessToken||this._listenForAuthEvents()}get functions(){return new Tdt(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:h},f,g){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new qht({url:this.authUrl.href,headers:Object.assign(Object.assign({},v),f),storageKey:l,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:d,debug:h,fetch:g,hasCustomAuthorizationHeader:Object.keys(this.headers).some(_=>_.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new eut(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 Hht=(t,s,r)=>new Vht(t,s,r);function Wht(){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}Wht()&&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 Ght="https://relzejiswnotikjgvjhz.supabase.co",Kht="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",Z=Hht(Ght,Kht,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),JRe=T.createContext(void 0),Zht=({children:t})=>{const[s,r]=T.useState(null),[n,a]=T.useState(null),[o,l]=T.useState(!0),[i,d]=T.useState(!1),[h,f]=T.useState(!1),[g,v]=T.useState(null),[_,j]=T.useState([]),[w,k]=T.useState(null),M=Yr(),S=async B=>{try{console.log("Checking roles via RPC for user:",B);const[{data:$,error:V},{data:W,error:G}]=await Promise.all([Z.rpc("has_role",{_user_id:B,_role:"admin"}),Z.rpc("has_role",{_user_id:B,_role:"brokerage_manager"})]);if(V||G)console.error("Role RPC errors:",{isAdminError:V,isBrokerError:G}),d(!1),f(!1);else{const ie=!!$,ee=!!W;console.log("RPC roles result:",{adminValue:ie,brokerValue:ee}),d(ie),f(ee)}const{data:J,error:ne}=await Z.from("profiles").select("brokerage_id").eq("id",B).single();if(v(!ne&&J?J.brokerage_id:null),W){console.log("Fetching managed brokerages for user:",B);const{data:ie,error:ee}=await Z.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",B);if(console.log("Managed brokerage assignments result:",{assignments:ie,assignmentsError:ee}),ee||!ie){console.error("Error fetching managed brokerage assignments:",ee),j([]);return}const de=Array.from(new Set(ie.map(ge=>ge.brokerage_id).filter(Boolean)));if(de.length===0){j([]);return}const{data:oe,error:ue}=await Z.from("brokerages").select("id, name").in("id",de);if(console.log("Managed brokerages details result:",{brokeragesData:oe,brokeragesError:ue}),ue||!oe){console.error("Error fetching managed brokerages details:",ue),j([]);return}const ce=oe.map(ge=>({id:ge.id,name:ge.name})).sort((ge,Te)=>de.indexOf(ge.id)-de.indexOf(Te.id));console.log("Parsed managed brokerages:",ce),j(ce),ce.length>0&&!w&&k(ce[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),j([])}catch($){console.error("Unexpected error in checkRoles:",$),d(!1),f(!1),v(null),j([])}};T.useEffect(()=>{const{data:{subscription:B}}=Z.auth.onAuthStateChange(($,V)=>{console.log("Auth event:",$),a(V),r((V==null?void 0:V.user)??null),$==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{M("/profile?reset=true")},100)),V!=null&&V.user?setTimeout(()=>{S(V.user.id)},0):(d(!1),f(!1),v(null),j([]),k(null))});return Z.auth.getSession().then(({data:{session:$}})=>{a($),r(($==null?void 0:$.user)??null),$!=null&&$.user?S($.user.id).finally(()=>{l(!1)}):l(!1)}),()=>B.unsubscribe()},[]);const E=async(B,$)=>{const{error:V}=await Z.auth.signInWithPassword({email:B,password:$});if(V)throw be.error(V.message),V;be.success("Welcome back!"),M("/dashboard")},D=async(B,$,V)=>{const W=`${window.location.origin}/dashboard`,{error:G}=await Z.auth.signUp({email:B,password:$,options:{emailRedirectTo:W,data:{name:V}}});if(G)throw be.error(G.message),G;be.success("Account created! Welcome to LevelUp."),M("/dashboard")},L=async()=>{try{const{data:{session:B}}=await Z.auth.getSession();if(B){const{error:$}=await Z.auth.signOut();$?$.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",$.message):(console.error("Sign out error:",$),be.error($.message)):be.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),d(!1),f(!1),v(null),j([]),k(null),M("/auth")}catch(B){console.error("Unexpected sign out error:",B),M("/auth")}};return e.jsx(JRe.Provider,{value:{user:s,session:n,loading:o,signIn:E,signUp:D,signOut:L,isAdmin:i,isBrokerageManager:h,brokerageId:g,managedBrokerages:_,selectedBrokerageId:w,setSelectedBrokerageId:k},children:t})},Ys=()=>{const t=T.useContext(JRe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},eFe=T.createContext(void 0),hb="levelup_admin_session",vv="levelup_impersonation",Yht=({children:t})=>{const[s,r]=T.useState(!1),[n,a]=T.useState(null),[o,l]=T.useState(!1);T.useEffect(()=>{const h=sessionStorage.getItem(vv);if(h)try{const f=JSON.parse(h);r(!0),a(f)}catch{sessionStorage.removeItem(vv)}},[]);const i=async h=>{l(!0);try{const{data:{session:f}}=await Z.auth.getSession();if(!f)return be.error("No active session found"),!1;const g={access_token:f.access_token,refresh_token:f.refresh_token};sessionStorage.setItem(hb,JSON.stringify(g));const v=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.access_token}`},body:JSON.stringify({targetUserId:h})}),_=await v.json();if(!v.ok)throw new Error(_.error||"Failed to impersonate user");const j={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(vv,JSON.stringify(j)),_.method==="session"){const{error:w}=await Z.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(hb),sessionStorage.removeItem(vv),new Error("Failed to establish impersonation session")}else{const w=_.type||"recovery",{error:k}=await Z.auth.verifyOtp({token_hash:_.token_hash,type:w});if(k)throw console.error("Verify OTP error:",k),sessionStorage.removeItem(hb),sessionStorage.removeItem(vv),new Error("Failed to establish impersonation session")}return r(!0),a(j),be.success(`Now viewing as ${j.name}`),window.location.href="/dashboard",!0}catch(f){return console.error("Impersonation error:",f),be.error(f.message||"Failed to impersonate user"),sessionStorage.removeItem(hb),sessionStorage.removeItem(vv),!1}finally{l(!1)}},d=async()=>{l(!0);try{const h=sessionStorage.getItem(hb);if(!h){await Z.auth.signOut(),window.location.href="/auth";return}const f=JSON.parse(h);await Z.auth.signOut();const{error:g}=await Z.auth.setSession({access_token:f.access_token,refresh_token:f.refresh_token});if(sessionStorage.removeItem(hb),sessionStorage.removeItem(vv),g){console.error("Failed to restore admin session:",g),be.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),be.success("Returned to admin account"),window.location.href="/admin/members"}catch(h){console.error("Stop impersonation error:",h),be.error("Failed to restore admin session"),sessionStorage.removeItem(hb),sessionStorage.removeItem(vv),window.location.href="/auth"}finally{l(!1)}};return e.jsx(eFe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:t})},Tve=()=>{const t=T.useContext(eFe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},rP=M3("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"}}),Y=T.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?K0e:"button";return e.jsx(l,{className:$t(rP({variant:s,size:r,className:t})),ref:o,...a})});Y.displayName="Button";const Xht=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=Tve();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(Lu,{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(Y,{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(Us,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Xr,{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"})]})})]})})},tFe=T.createContext(void 0),vA="levelup_acting_as",Qht=({children:t})=>{const{user:s}=Ys(),[r,n]=T.useState(!1),[a,o]=T.useState([]),[l,i]=T.useState(null),[d,h]=T.useState({}),[f,g]=T.useState(!0);T.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),h({}),g(!1);return}(async()=>{g(!0);try{const{data:k}=await Z.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!k){n(!1),o([]),i(null),h({}),g(!1);return}n(!0);const{data:M,error:S}=await Z.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(S||!M||M.length===0){o([]),g(!1);return}const E=M.map($=>$.agent_id),{data:D}=await Z.from("profiles").select("id, name, email, avatar_url").in("id",E),L=(D||[]).map($=>({id:$.id,name:$.name||$.email||"Unknown",email:$.email||"",avatar_url:$.avatar_url}));o(L);const B=sessionStorage.getItem(vA);if(B){const $=L.find(V=>V.id===B);if($){i($);const V=M.find(W=>W.agent_id===B);h((V==null?void 0:V.permissions)||{})}else if(L.length>0){i(L[0]);const V=M.find(W=>W.agent_id===L[0].id);h((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(vA,L[0].id)}}else if(L.length>0){i(L[0]);const $=M.find(V=>V.agent_id===L[0].id);h(($==null?void 0:$.permissions)||{}),sessionStorage.setItem(vA,L[0].id)}}catch(k){console.error("Error loading assistant data:",k)}finally{g(!1)}})()},[s==null?void 0:s.id]);const v=w=>{i(w),w?(sessionStorage.setItem(vA,w.id),Z.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",w.id).single().then(({data:k})=>{h((k==null?void 0:k.permissions)||{})})):(sessionStorage.removeItem(vA),h({}))},_=w=>r?d[w]===!0:!0,j=r&&l?l.id:(s==null?void 0:s.id)||null;return e.jsx(tFe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:v,effectiveUserId:j,permissions:d,hasPermission:_,isLoading:f},children:t})},Ave=()=>{const t=T.useContext(tFe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},lo=()=>{const{effectiveUserId:t}=Ave();return t};var sFe={exports:{}},rFe={};/** * @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 O5=T;function Jht(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var emt=typeof Object.is=="function"?Object.is:Jht,tmt=O5.useState,smt=O5.useEffect,rmt=O5.useLayoutEffect,nmt=O5.useDebugValue;function amt(t,s){var r=s(),n=tmt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return rmt(function(){a.value=r,a.getSnapshot=s,Fue(a)&&o({inst:a})},[t,r,s]),smt(function(){return Fue(a)&&o({inst:a}),t(function(){Fue(a)&&o({inst:a})})},[t]),nmt(r),r}function Fue(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!emt(t,r)}catch{return!0}}function imt(t,s){return s()}var omt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?imt:amt;rFe.useSyncExternalStore=O5.useSyncExternalStore!==void 0?O5.useSyncExternalStore:omt;sFe.exports=rFe;var lmt=sFe.exports;function cmt(){return lmt.useSyncExternalStore(dmt,()=>!0,()=>!1)}function dmt(){return()=>{}}var Eve="Avatar",[umt]=Dc(Eve),[hmt,nFe]=umt(Eve),aFe=T.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=T.useState("idle");return e.jsx(hmt,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Qr.span,{...n,ref:s})})});aFe.displayName=Eve;var iFe="AvatarImage",oFe=T.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=nFe(iFe,r),i=mmt(n,o),d=Ac(h=>{a(h),l.onImageLoadingStatusChange(h)});return Pc(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(Qr.img,{...o,ref:s,src:n}):null});oFe.displayName=iFe;var lFe="AvatarFallback",cFe=T.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=nFe(lFe,r),[l,i]=T.useState(n===void 0);return T.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});cFe.displayName=lFe;function a4e(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function mmt(t,{referrerPolicy:s,crossOrigin:r}){const n=cmt(),a=T.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=T.useState(()=>a4e(o,t));return Pc(()=>{i(a4e(o,t))},[o,t]),Pc(()=>{const d=g=>()=>{i(g)};if(!o)return;const h=d("loaded"),f=d("error");return o.addEventListener("load",h),o.addEventListener("error",f),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",h),o.removeEventListener("error",f)}},[o,r,s]),l}var dFe=aFe,uFe=oFe,hFe=cFe;const fn=T.forwardRef(({className:t,...s},r)=>e.jsx(dFe,{ref:r,className:$t("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));fn.displayName=dFe.displayName;const _a=T.forwardRef(({className:t,...s},r)=>e.jsx(uFe,{ref:r,className:$t("aspect-square h-full w-full",t),...s}));_a.displayName=uFe.displayName;const gn=T.forwardRef(({className:t,...s},r)=>e.jsx(hFe,{ref:r,className:$t("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));gn.displayName=hFe.displayName;const pmt=M3("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 ct({className:t,variant:s,...r}){return e.jsx("div",{className:$t(pmt({variant:s}),t),...r})}var fmt=T.createContext(void 0);function jN(t){const s=T.useContext(fmt);return t||s||"ltr"}var zue=0;function kie(){T.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??i4e()),document.body.insertAdjacentElement("beforeend",t[1]??i4e()),zue++,()=>{zue===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),zue--}},[])}function i4e(){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 Bue="focusScope.autoFocusOnMount",$ue="focusScope.autoFocusOnUnmount",o4e={bubbles:!1,cancelable:!0},gmt="FocusScope",T6=T.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=T.useState(null),h=Ac(a),f=Ac(o),g=T.useRef(null),v=ba(s,w=>d(w)),_=T.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;T.useEffect(()=>{if(n){let w=function(E){if(_.paused||!i)return;const D=E.target;i.contains(D)?g.current=D:jv(g.current,{select:!0})},k=function(E){if(_.paused||!i)return;const D=E.relatedTarget;D!==null&&(i.contains(D)||jv(g.current,{select:!0}))},M=function(E){if(document.activeElement===document.body)for(const L of E)L.removedNodes.length>0&&jv(i)};document.addEventListener("focusin",w),document.addEventListener("focusout",k);const S=new MutationObserver(M);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",k),S.disconnect()}}},[n,i,_.paused]),T.useEffect(()=>{if(i){c4e.add(_);const w=document.activeElement;if(!i.contains(w)){const M=new CustomEvent(Bue,o4e);i.addEventListener(Bue,h),i.dispatchEvent(M),M.defaultPrevented||(xmt(wmt(mFe(i)),{select:!0}),document.activeElement===w&&jv(i))}return()=>{i.removeEventListener(Bue,h),setTimeout(()=>{const M=new CustomEvent($ue,o4e);i.addEventListener($ue,f),i.dispatchEvent(M),M.defaultPrevented||jv(w??document.body,{select:!0}),i.removeEventListener($ue,f),c4e.remove(_)},0)}}},[i,h,f,_]);const j=T.useCallback(w=>{if(!r&&!n||_.paused)return;const k=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,M=document.activeElement;if(k&&M){const S=w.currentTarget,[E,D]=ymt(S);E&&D?!w.shiftKey&&M===D?(w.preventDefault(),r&&jv(E,{select:!0})):w.shiftKey&&M===E&&(w.preventDefault(),r&&jv(D,{select:!0})):M===S&&w.preventDefault()}},[r,n,_.paused]);return e.jsx(Qr.div,{tabIndex:-1,...l,ref:v,onKeyDown:j})});T6.displayName=gmt;function xmt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(jv(n,{select:s}),document.activeElement!==r)return}function ymt(t){const s=mFe(t),r=l4e(s,t),n=l4e(s.reverse(),t);return[r,n]}function mFe(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 l4e(t,s){for(const r of t)if(!vmt(r,{upTo:s}))return r}function vmt(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 _mt(t){return t instanceof HTMLInputElement&&"select"in t}function jv(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&_mt(t)&&s&&t.select()}}var c4e=bmt();function bmt(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=d4e(t,s),t.unshift(s)},remove(s){var r;t=d4e(t,s),(r=t[0])==null||r.resume()}}}function d4e(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function wmt(t){return t.filter(s=>s.tagName!=="A")}var Uue="rovingFocusGroup.onEntryFocus",jmt={bubbles:!1,cancelable:!0},A6="RovingFocusGroup",[Cfe,pFe,kmt]=b6(A6),[Nmt,z3]=Dc(A6,[kmt]),[Smt,Cmt]=Nmt(A6),fFe=T.forwardRef((t,s)=>e.jsx(Cfe.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Cfe.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Mmt,{...t,ref:s})})}));fFe.displayName=A6;var Mmt=T.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...g}=t,v=T.useRef(null),_=ba(s,v),j=jN(o),[w,k]=Sh({prop:l,defaultProp:i??null,onChange:d,caller:A6}),[M,S]=T.useState(!1),E=Ac(h),D=pFe(r),L=T.useRef(!1),[B,$]=T.useState(0);return T.useEffect(()=>{const V=v.current;if(V)return V.addEventListener(Uue,E),()=>V.removeEventListener(Uue,E)},[E]),e.jsx(Smt,{scope:r,orientation:n,dir:j,loop:a,currentTabStopId:w,onItemFocus:T.useCallback(V=>k(V),[k]),onItemShiftTab:T.useCallback(()=>S(!0),[]),onFocusableItemAdd:T.useCallback(()=>$(V=>V+1),[]),onFocusableItemRemove:T.useCallback(()=>$(V=>V-1),[]),children:e.jsx(Qr.div,{tabIndex:M||B===0?-1:0,"data-orientation":n,...g,ref:_,style:{outline:"none",...t.style},onMouseDown:kr(t.onMouseDown,()=>{L.current=!0}),onFocus:kr(t.onFocus,V=>{const W=!L.current;if(V.target===V.currentTarget&&W&&!M){const G=new CustomEvent(Uue,jmt);if(V.currentTarget.dispatchEvent(G),!G.defaultPrevented){const J=D().filter(oe=>oe.focusable),ne=J.find(oe=>oe.active),ie=J.find(oe=>oe.id===w),de=[ne,ie,...J].filter(Boolean).map(oe=>oe.ref.current);yFe(de,f)}}L.current=!1}),onBlur:kr(t.onBlur,()=>S(!1))})})}),gFe="RovingFocusGroupItem",xFe=T.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=Id(),h=o||d,f=Cmt(gFe,r),g=f.currentTabStopId===h,v=pFe(r),{onFocusableItemAdd:_,onFocusableItemRemove:j,currentTabStopId:w}=f;return T.useEffect(()=>{if(n)return _(),()=>j()},[n,_,j]),e.jsx(Cfe.ItemSlot,{scope:r,id:h,focusable:n,active:a,children:e.jsx(Qr.span,{tabIndex:g?0:-1,"data-orientation":f.orientation,...i,ref:s,onMouseDown:kr(t.onMouseDown,k=>{n?f.onItemFocus(h):k.preventDefault()}),onFocus:kr(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:kr(t.onKeyDown,k=>{if(k.key==="Tab"&&k.shiftKey){f.onItemShiftTab();return}if(k.target!==k.currentTarget)return;const M=Emt(k,f.orientation,f.dir);if(M!==void 0){if(k.metaKey||k.ctrlKey||k.altKey||k.shiftKey)return;k.preventDefault();let E=v().filter(D=>D.focusable).map(D=>D.ref.current);if(M==="last")E.reverse();else if(M==="prev"||M==="next"){M==="prev"&&E.reverse();const D=E.indexOf(k.currentTarget);E=f.loop?Imt(E,D+1):E.slice(D+1)}setTimeout(()=>yFe(E))}}),children:typeof l=="function"?l({isCurrentTabStop:g,hasTabStop:w!=null}):l})})});xFe.displayName=gFe;var Tmt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Amt(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Emt(t,s,r){const n=Amt(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Tmt[n]}function yFe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function Imt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Ive=fFe,Pve=xFe,Pmt=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},wC=new WeakMap,$O=new WeakMap,UO={},que=0,vFe=function(t){return t&&(t.host||vFe(t.parentNode))},Lmt=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=vFe(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})},Dmt=function(t,s,r,n){var a=Lmt(s,Array.isArray(t)?t:[t]);UO[r]||(UO[r]=new WeakMap);var o=UO[r],l=[],i=new Set,d=new Set(a),h=function(g){!g||i.has(g)||(i.add(g),h(g.parentNode))};a.forEach(h);var f=function(g){!g||d.has(g)||Array.prototype.forEach.call(g.children,function(v){if(i.has(v))f(v);else try{var _=v.getAttribute(n),j=_!==null&&_!=="false",w=(wC.get(v)||0)+1,k=(o.get(v)||0)+1;wC.set(v,w),o.set(v,k),l.push(v),w===1&&j&&$O.set(v,!0),k===1&&v.setAttribute(r,"true"),j||v.setAttribute(n,"true")}catch(M){console.error("aria-hidden: cannot operate on ",v,M)}})};return f(s),i.clear(),que++,function(){l.forEach(function(g){var v=wC.get(g)-1,_=o.get(g)-1;wC.set(g,v),o.set(g,_),v||($O.has(g)||g.removeAttribute(n),$O.delete(g)),_||g.removeAttribute(r)}),que--,que||(wC=new WeakMap,wC=new WeakMap,$O=new WeakMap,UO={})}},Nie=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=Pmt(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),Dmt(n,a,r,"aria-hidden")):function(){return null}},_se="right-scroll-bar-position",bse="width-before-scroll-bar",Omt="with-scroll-bars-hidden",Rmt="--removed-body-scroll-bar-size";function Vue(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function Fmt(t,s){var r=T.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 zmt=typeof window<"u"?T.useLayoutEffect:T.useEffect,u4e=new WeakMap;function Bmt(t,s){var r=Fmt(null,function(n){return t.forEach(function(a){return Vue(a,n)})});return zmt(function(){var n=u4e.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||Vue(i,null)}),o.forEach(function(i){a.has(i)||Vue(i,l)})}u4e.set(r,t)},[t]),r}function $mt(t){return t}function Umt(t,s){s===void 0&&(s=$mt);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 f=l;l=[],f.forEach(o)},h=function(){return Promise.resolve().then(d)};h(),r={push:function(f){l.push(f),h()},filter:function(f){return l=l.filter(f),r}}}};return a}function qmt(t){t===void 0&&(t={});var s=Umt(null);return s.options=Fp({async:!0,ssr:!1},t),s}var _Fe=function(t){var s=t.sideCar,r=i_(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 T.createElement(n,Fp({},r))};_Fe.isSideCarExport=!0;function Vmt(t,s){return t.useMedium(s),_Fe}var bFe=qmt(),Hue=function(){},Sie=T.forwardRef(function(t,s){var r=T.useRef(null),n=T.useState({onScrollCapture:Hue,onWheelCapture:Hue,onTouchMoveCapture:Hue}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,d=t.className,h=t.removeScrollBar,f=t.enabled,g=t.shards,v=t.sideCar,_=t.noRelative,j=t.noIsolation,w=t.inert,k=t.allowPinchZoom,M=t.as,S=M===void 0?"div":M,E=t.gapMode,D=i_(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),L=v,B=Bmt([r,s]),$=Fp(Fp({},D),a);return T.createElement(T.Fragment,null,f&&T.createElement(L,{sideCar:bFe,removeScrollBar:h,shards:g,noRelative:_,noIsolation:j,inert:w,setCallbacks:o,allowPinchZoom:!!k,lockRef:r,gapMode:E}),l?T.cloneElement(T.Children.only(i),Fp(Fp({},$),{ref:B})):T.createElement(S,Fp({},$,{className:d,ref:B}),i))});Sie.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Sie.classNames={fullWidth:bse,zeroRight:_se};var Hmt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Wmt(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=Hmt();return s&&t.setAttribute("nonce",s),t}function Gmt(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function Kmt(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var Zmt=function(){var t=0,s=null;return{add:function(r){t==0&&(s=Wmt())&&(Gmt(s,r),Kmt(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},Ymt=function(){var t=Zmt();return function(s,r){T.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},wFe=function(){var t=Ymt(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},Xmt={left:0,top:0,right:0,gap:0},Wue=function(t){return parseInt(t||"",10)||0},Qmt=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[Wue(r),Wue(n),Wue(a)]},Jmt=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Xmt;var s=Qmt(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])}},ept=wFe(),J4="data-scroll-locked",tpt=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(Omt,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(J4,`] { 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(_se,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(bse,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(_se," .").concat(_se,` { right: 0 `).concat(n,`; } .`).concat(bse," .").concat(bse,` { margin-right: 0 `).concat(n,`; } body[`).concat(J4,`] { `).concat(Rmt,": ").concat(i,`px; } `)},h4e=function(){var t=parseInt(document.body.getAttribute(J4)||"0",10);return isFinite(t)?t:0},spt=function(){T.useEffect(function(){return document.body.setAttribute(J4,(h4e()+1).toString()),function(){var t=h4e()-1;t<=0?document.body.removeAttribute(J4):document.body.setAttribute(J4,t.toString())}},[])},rpt=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;spt();var o=T.useMemo(function(){return Jmt(a)},[a]);return T.createElement(ept,{styles:tpt(o,!s,a,r?"":"!important")})},Mfe=!1;if(typeof window<"u")try{var qO=Object.defineProperty({},"passive",{get:function(){return Mfe=!0,!0}});window.addEventListener("test",qO,qO),window.removeEventListener("test",qO,qO)}catch{Mfe=!1}var jC=Mfe?{passive:!1}:!1,npt=function(t){return t.tagName==="TEXTAREA"},jFe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!npt(t)&&r[s]==="visible")},apt=function(t){return jFe(t,"overflowY")},ipt=function(t){return jFe(t,"overflowX")},m4e=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=kFe(t,n);if(a){var o=NFe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},opt=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},lpt=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},kFe=function(t,s){return t==="v"?apt(s):ipt(s)},NFe=function(t,s){return t==="v"?opt(s):lpt(s)},cpt=function(t,s){return t==="h"&&s==="rtl"?-1:1},dpt=function(t,s,r,n,a){var o=cpt(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,d=s.contains(i),h=!1,f=l>0,g=0,v=0;do{if(!i)break;var _=NFe(t,i),j=_[0],w=_[1],k=_[2],M=w-k-o*j;(j||M)&&kFe(t,i)&&(g+=M,v+=j);var S=i.parentNode;i=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!d&&i!==document.body||d&&(s.contains(i)||s===i));return(f&&Math.abs(g)<1||!f&&Math.abs(v)<1)&&(h=!0),h},VO=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},p4e=function(t){return[t.deltaX,t.deltaY]},f4e=function(t){return t&&"current"in t?t.current:t},upt=function(t,s){return t[0]===s[0]&&t[1]===s[1]},hpt=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},mpt=0,kC=[];function ppt(t){var s=T.useRef([]),r=T.useRef([0,0]),n=T.useRef(),a=T.useState(mpt++)[0],o=T.useState(wFe)[0],l=T.useRef(t);T.useEffect(function(){l.current=t},[t]),T.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=_ve([t.lockRef.current],(t.shards||[]).map(f4e),!0).filter(Boolean);return w.forEach(function(k){return k.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(k){return k.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=T.useCallback(function(w,k){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var M=VO(w),S=r.current,E="deltaX"in w?w.deltaX:S[0]-M[0],D="deltaY"in w?w.deltaY:S[1]-M[1],L,B=w.target,$=Math.abs(E)>Math.abs(D)?"h":"v";if("touches"in w&&$==="h"&&B.type==="range")return!1;var V=m4e($,B);if(!V)return!0;if(V?L=$:(L=$==="v"?"h":"v",V=m4e($,B)),!V)return!1;if(!n.current&&"changedTouches"in w&&(E||D)&&(n.current=L),!L)return!0;var W=n.current||L;return dpt(W,k,w,W==="h"?E:D)},[]),d=T.useCallback(function(w){var k=w;if(!(!kC.length||kC[kC.length-1]!==o)){var M="deltaY"in k?p4e(k):VO(k),S=s.current.filter(function(L){return L.name===k.type&&(L.target===k.target||k.target===L.shadowParent)&&upt(L.delta,M)})[0];if(S&&S.should){k.cancelable&&k.preventDefault();return}if(!S){var E=(l.current.shards||[]).map(f4e).filter(Boolean).filter(function(L){return L.contains(k.target)}),D=E.length>0?i(k,E[0]):!l.current.noIsolation;D&&k.cancelable&&k.preventDefault()}}},[]),h=T.useCallback(function(w,k,M,S){var E={name:w,delta:k,target:M,should:S,shadowParent:fpt(M)};s.current.push(E),setTimeout(function(){s.current=s.current.filter(function(D){return D!==E})},1)},[]),f=T.useCallback(function(w){r.current=VO(w),n.current=void 0},[]),g=T.useCallback(function(w){h(w.type,p4e(w),w.target,i(w,t.lockRef.current))},[]),v=T.useCallback(function(w){h(w.type,VO(w),w.target,i(w,t.lockRef.current))},[]);T.useEffect(function(){return kC.push(o),t.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:v}),document.addEventListener("wheel",d,jC),document.addEventListener("touchmove",d,jC),document.addEventListener("touchstart",f,jC),function(){kC=kC.filter(function(w){return w!==o}),document.removeEventListener("wheel",d,jC),document.removeEventListener("touchmove",d,jC),document.removeEventListener("touchstart",f,jC)}},[]);var _=t.removeScrollBar,j=t.inert;return T.createElement(T.Fragment,null,j?T.createElement(o,{styles:hpt(a)}):null,_?T.createElement(rpt,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function fpt(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const gpt=Vmt(bFe,ppt);var E6=T.forwardRef(function(t,s){return T.createElement(Sie,Fp({},t,{ref:s,sideCar:gpt}))});E6.classNames=Sie.classNames;var Tfe=["Enter"," "],xpt=["ArrowDown","PageUp","Home"],SFe=["ArrowUp","PageDown","End"],ypt=[...xpt,...SFe],vpt={ltr:[...Tfe,"ArrowRight"],rtl:[...Tfe,"ArrowLeft"]},_pt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},I6="Menu",[nP,bpt,wpt]=b6(I6),[kN,CFe]=Dc(I6,[wpt,Wx,z3]),Cie=Wx(),MFe=z3(),[jpt,NN]=kN(I6),[kpt,P6]=kN(I6),TFe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=Cie(s),[d,h]=T.useState(null),f=T.useRef(!1),g=Ac(o),v=jN(a);return T.useEffect(()=>{const _=()=>{f.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},j=()=>f.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),e.jsx(N6,{...i,children:e.jsx(jpt,{scope:s,open:r,onOpenChange:g,content:d,onContentChange:h,children:e.jsx(kpt,{scope:s,onClose:T.useCallback(()=>g(!1),[g]),isUsingKeyboardRef:f,dir:v,modal:l,children:n})})})};TFe.displayName=I6;var Npt="MenuAnchor",Lve=T.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Cie(r);return e.jsx(I3,{...a,...n,ref:s})});Lve.displayName=Npt;var Dve="MenuPortal",[Spt,AFe]=kN(Dve,{forceMount:void 0}),EFe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=NN(Dve,s);return e.jsx(Spt,{scope:s,forceMount:r,children:e.jsx(Qc,{present:r||o.open,children:e.jsx(C3,{asChild:!0,container:a,children:n})})})};EFe.displayName=Dve;var Zp="MenuContent",[Cpt,Ove]=kN(Zp),IFe=T.forwardRef((t,s)=>{const r=AFe(Zp,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=NN(Zp,t.__scopeMenu),l=P6(Zp,t.__scopeMenu);return e.jsx(nP.Provider,{scope:t.__scopeMenu,children:e.jsx(Qc,{present:n||o.open,children:e.jsx(nP.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(Mpt,{...a,ref:s}):e.jsx(Tpt,{...a,ref:s})})})})}),Mpt=T.forwardRef((t,s)=>{const r=NN(Zp,t.__scopeMenu),n=T.useRef(null),a=ba(s,n);return T.useEffect(()=>{const o=n.current;if(o)return Nie(o)},[]),e.jsx(Rve,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:kr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Tpt=T.forwardRef((t,s)=>{const r=NN(Zp,t.__scopeMenu);return e.jsx(Rve,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Apt=W1("MenuContent.ScrollLock"),Rve=T.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:g,onInteractOutside:v,onDismiss:_,disableOutsideScroll:j,...w}=t,k=NN(Zp,r),M=P6(Zp,r),S=Cie(r),E=MFe(r),D=bpt(r),[L,B]=T.useState(null),$=T.useRef(null),V=ba(s,$,k.onContentChange),W=T.useRef(0),G=T.useRef(""),J=T.useRef(0),ne=T.useRef(null),ie=T.useRef("right"),ee=T.useRef(0),de=j?E6:T.Fragment,oe=j?{as:Apt,allowPinchZoom:!0}:void 0,ue=ge=>{var He,Ue;const Te=G.current+ge,ve=D().filter(De=>!De.disabled),ye=document.activeElement,Se=(He=ve.find(De=>De.ref.current===ye))==null?void 0:He.textValue,Ke=ve.map(De=>De.textValue),Ae=Upt(Ke,Te,Se),Ee=(Ue=ve.find(De=>De.textValue===Ae))==null?void 0:Ue.ref.current;(function De(Ge){G.current=Ge,window.clearTimeout(W.current),Ge!==""&&(W.current=window.setTimeout(()=>De(""),1e3))})(Te),Ee&&setTimeout(()=>Ee.focus())};T.useEffect(()=>()=>window.clearTimeout(W.current),[]),kie();const ce=T.useCallback(ge=>{var ve,ye;return ie.current===((ve=ne.current)==null?void 0:ve.side)&&Vpt(ge,(ye=ne.current)==null?void 0:ye.area)},[]);return e.jsx(Cpt,{scope:r,searchRef:G,onItemEnter:T.useCallback(ge=>{ce(ge)&&ge.preventDefault()},[ce]),onItemLeave:T.useCallback(ge=>{var Te;ce(ge)||((Te=$.current)==null||Te.focus(),B(null))},[ce]),onTriggerLeave:T.useCallback(ge=>{ce(ge)&&ge.preventDefault()},[ce]),pointerGraceTimerRef:J,onPointerGraceIntentChange:T.useCallback(ge=>{ne.current=ge},[]),children:e.jsx(de,{...oe,children:e.jsx(T6,{asChild:!0,trapped:a,onMountAutoFocus:kr(o,ge=>{var Te;ge.preventDefault(),(Te=$.current)==null||Te.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(n_,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:g,onInteractOutside:v,onDismiss:_,children:e.jsx(Ive,{asChild:!0,...E,dir:M.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:B,onEntryFocus:kr(d,ge=>{M.isUsingKeyboardRef.current||ge.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(S6,{role:"menu","aria-orientation":"vertical","data-state":KFe(k.open),"data-radix-menu-content":"",dir:M.dir,...S,...w,ref:V,style:{outline:"none",...w.style},onKeyDown:kr(w.onKeyDown,ge=>{const ve=ge.target.closest("[data-radix-menu-content]")===ge.currentTarget,ye=ge.ctrlKey||ge.altKey||ge.metaKey,Se=ge.key.length===1;ve&&(ge.key==="Tab"&&ge.preventDefault(),!ye&&Se&&ue(ge.key));const Ke=$.current;if(ge.target!==Ke||!ypt.includes(ge.key))return;ge.preventDefault();const Ee=D().filter(He=>!He.disabled).map(He=>He.ref.current);SFe.includes(ge.key)&&Ee.reverse(),Bpt(Ee)}),onBlur:kr(t.onBlur,ge=>{ge.currentTarget.contains(ge.target)||(window.clearTimeout(W.current),G.current="")}),onPointerMove:kr(t.onPointerMove,aP(ge=>{const Te=ge.target,ve=ee.current!==ge.clientX;if(ge.currentTarget.contains(Te)&&ve){const ye=ge.clientX>ee.current?"right":"left";ie.current=ye,ee.current=ge.clientX}}))})})})})})})});IFe.displayName=Zp;var Ept="MenuGroup",Fve=T.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"group",...n,ref:s})});Fve.displayName=Ept;var Ipt="MenuLabel",PFe=T.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{...n,ref:s})});PFe.displayName=Ipt;var Nre="MenuItem",g4e="menu.itemSelect",Mie=T.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=T.useRef(null),l=P6(Nre,t.__scopeMenu),i=Ove(Nre,t.__scopeMenu),d=ba(s,o),h=T.useRef(!1),f=()=>{const g=o.current;if(!r&&g){const v=new CustomEvent(g4e,{bubbles:!0,cancelable:!0});g.addEventListener(g4e,_=>n==null?void 0:n(_),{once:!0}),Z0e(g,v),v.defaultPrevented?h.current=!1:l.onClose()}};return e.jsx(LFe,{...a,ref:d,disabled:r,onClick:kr(t.onClick,f),onPointerDown:g=>{var v;(v=t.onPointerDown)==null||v.call(t,g),h.current=!0},onPointerUp:kr(t.onPointerUp,g=>{var v;h.current||(v=g.currentTarget)==null||v.click()}),onKeyDown:kr(t.onKeyDown,g=>{const v=i.searchRef.current!=="";r||v&&g.key===" "||Tfe.includes(g.key)&&(g.currentTarget.click(),g.preventDefault())})})});Mie.displayName=Nre;var LFe=T.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=Ove(Nre,r),i=MFe(r),d=T.useRef(null),h=ba(s,d),[f,g]=T.useState(!1),[v,_]=T.useState("");return T.useEffect(()=>{const j=d.current;j&&_((j.textContent??"").trim())},[o.children]),e.jsx(nP.ItemSlot,{scope:r,disabled:n,textValue:a??v,children:e.jsx(Pve,{asChild:!0,...i,focusable:!n,children:e.jsx(Qr.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:h,onPointerMove:kr(t.onPointerMove,aP(j=>{n?l.onItemLeave(j):(l.onItemEnter(j),j.defaultPrevented||j.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:kr(t.onPointerLeave,aP(j=>l.onItemLeave(j))),onFocus:kr(t.onFocus,()=>g(!0)),onBlur:kr(t.onBlur,()=>g(!1))})})})}),Ppt="MenuCheckboxItem",DFe=T.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(BFe,{scope:t.__scopeMenu,checked:r,children:e.jsx(Mie,{role:"menuitemcheckbox","aria-checked":Sre(r)?"mixed":r,...a,ref:s,"data-state":Bve(r),onSelect:kr(a.onSelect,()=>n==null?void 0:n(Sre(r)?!0:!r),{checkForDefaultPrevented:!1})})})});DFe.displayName=Ppt;var OFe="MenuRadioGroup",[Lpt,Dpt]=kN(OFe,{value:void 0,onValueChange:()=>{}}),RFe=T.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=Ac(n);return e.jsx(Lpt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(Fve,{...a,ref:s})})});RFe.displayName=OFe;var FFe="MenuRadioItem",zFe=T.forwardRef((t,s)=>{const{value:r,...n}=t,a=Dpt(FFe,t.__scopeMenu),o=r===a.value;return e.jsx(BFe,{scope:t.__scopeMenu,checked:o,children:e.jsx(Mie,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":Bve(o),onSelect:kr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});zFe.displayName=FFe;var zve="MenuItemIndicator",[BFe,Opt]=kN(zve,{checked:!1}),$Fe=T.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=Opt(zve,r);return e.jsx(Qc,{present:n||Sre(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{...a,ref:s,"data-state":Bve(o.checked)})})});$Fe.displayName=zve;var Rpt="MenuSeparator",UFe=T.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Qr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});UFe.displayName=Rpt;var Fpt="MenuArrow",qFe=T.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Cie(r);return e.jsx(C6,{...a,...n,ref:s})});qFe.displayName=Fpt;var zpt="MenuSub",[Gfs,VFe]=kN(zpt),QA="MenuSubTrigger",HFe=T.forwardRef((t,s)=>{const r=NN(QA,t.__scopeMenu),n=P6(QA,t.__scopeMenu),a=VFe(QA,t.__scopeMenu),o=Ove(QA,t.__scopeMenu),l=T.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,h={__scopeMenu:t.__scopeMenu},f=T.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return T.useEffect(()=>f,[f]),T.useEffect(()=>{const g=i.current;return()=>{window.clearTimeout(g),d(null)}},[i,d]),e.jsx(Lve,{asChild:!0,...h,children:e.jsx(LFe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":KFe(r.open),...t,ref:f0(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:kr(t.onPointerMove,aP(g=>{o.onItemEnter(g),!g.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),f()},100))})),onPointerLeave:kr(t.onPointerLeave,aP(g=>{var _,j;f();const v=(_=r.content)==null?void 0:_.getBoundingClientRect();if(v){const w=(j=r.content)==null?void 0:j.dataset.side,k=w==="right",M=k?-5:5,S=v[k?"left":"right"],E=v[k?"right":"left"];o.onPointerGraceIntentChange({area:[{x:g.clientX+M,y:g.clientY},{x:S,y:v.top},{x:E,y:v.top},{x:E,y:v.bottom},{x:S,y:v.bottom}],side:w}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(g),g.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:kr(t.onKeyDown,g=>{var _;const v=o.searchRef.current!=="";t.disabled||v&&g.key===" "||vpt[n.dir].includes(g.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),g.preventDefault())})})})});HFe.displayName=QA;var WFe="MenuSubContent",GFe=T.forwardRef((t,s)=>{const r=AFe(Zp,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=NN(Zp,t.__scopeMenu),l=P6(Zp,t.__scopeMenu),i=VFe(WFe,t.__scopeMenu),d=T.useRef(null),h=ba(s,d);return e.jsx(nP.Provider,{scope:t.__scopeMenu,children:e.jsx(Qc,{present:n||o.open,children:e.jsx(nP.Slot,{scope:t.__scopeMenu,children:e.jsx(Rve,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:h,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var g;l.isUsingKeyboardRef.current&&((g=d.current)==null||g.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:kr(t.onFocusOutside,f=>{f.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:kr(t.onEscapeKeyDown,f=>{l.onClose(),f.preventDefault()}),onKeyDown:kr(t.onKeyDown,f=>{var _;const g=f.currentTarget.contains(f.target),v=_pt[l.dir].includes(f.key);g&&v&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),f.preventDefault())})})})})})});GFe.displayName=WFe;function KFe(t){return t?"open":"closed"}function Sre(t){return t==="indeterminate"}function Bve(t){return Sre(t)?"indeterminate":t?"checked":"unchecked"}function Bpt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function $pt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function Upt(t,s,r){const a=s.length>1&&Array.from(s).every(h=>h===s[0])?s[0]:s,o=r?t.indexOf(r):-1;let l=$pt(t,Math.max(o,0));a.length===1&&(l=l.filter(h=>h!==r));const d=l.find(h=>h.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function qpt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=v>n&&r<(g-h)*(n-f)/(v-f)+h&&(a=!a)}return a}function Vpt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return qpt(r,s)}function aP(t){return s=>s.pointerType==="mouse"?t(s):void 0}var Hpt=TFe,Wpt=Lve,Gpt=EFe,Kpt=IFe,Zpt=Fve,Ypt=PFe,Xpt=Mie,Qpt=DFe,Jpt=RFe,eft=zFe,tft=$Fe,sft=UFe,rft=qFe,nft=HFe,aft=GFe,Tie="DropdownMenu",[ift]=Dc(Tie,[CFe]),Ph=CFe(),[oft,ZFe]=ift(Tie),YFe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=Ph(s),h=T.useRef(null),[f,g]=Sh({prop:a,defaultProp:o??!1,onChange:l,caller:Tie});return e.jsx(oft,{scope:s,triggerId:Id(),triggerRef:h,contentId:Id(),open:f,onOpenChange:g,onOpenToggle:T.useCallback(()=>g(v=>!v),[g]),modal:i,children:e.jsx(Hpt,{...d,open:f,onOpenChange:g,dir:n,modal:i,children:r})})};YFe.displayName=Tie;var XFe="DropdownMenuTrigger",QFe=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=ZFe(XFe,r),l=Ph(r);return e.jsx(Wpt,{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:f0(s,o.triggerRef),onPointerDown:kr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:kr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});QFe.displayName=XFe;var lft="DropdownMenuPortal",JFe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Ph(s);return e.jsx(Gpt,{...n,...r})};JFe.displayName=lft;var eze="DropdownMenuContent",tze=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=ZFe(eze,r),o=Ph(r),l=T.useRef(!1);return e.jsx(Kpt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:kr(t.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:kr(t.onInteractOutside,i=>{const d=i.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0,f=d.button===2||h;(!a.modal||f)&&(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)"}})});tze.displayName=eze;var cft="DropdownMenuGroup",dft=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(Zpt,{...a,...n,ref:s})});dft.displayName=cft;var uft="DropdownMenuLabel",sze=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(Ypt,{...a,...n,ref:s})});sze.displayName=uft;var hft="DropdownMenuItem",rze=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(Xpt,{...a,...n,ref:s})});rze.displayName=hft;var mft="DropdownMenuCheckboxItem",nze=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(Qpt,{...a,...n,ref:s})});nze.displayName=mft;var pft="DropdownMenuRadioGroup",fft=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(Jpt,{...a,...n,ref:s})});fft.displayName=pft;var gft="DropdownMenuRadioItem",aze=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(eft,{...a,...n,ref:s})});aze.displayName=gft;var xft="DropdownMenuItemIndicator",ize=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(tft,{...a,...n,ref:s})});ize.displayName=xft;var yft="DropdownMenuSeparator",oze=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(sft,{...a,...n,ref:s})});oze.displayName=yft;var vft="DropdownMenuArrow",_ft=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(rft,{...a,...n,ref:s})});_ft.displayName=vft;var bft="DropdownMenuSubTrigger",lze=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(nft,{...a,...n,ref:s})});lze.displayName=bft;var wft="DropdownMenuSubContent",cze=T.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Ph(r);return e.jsx(aft,{...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)"}})});cze.displayName=wft;var jft=YFe,kft=QFe,Nft=JFe,dze=tze,uze=sze,hze=rze,mze=nze,pze=aze,fze=ize,gze=oze,xze=lze,yze=cze;const Hu=jft,Wu=kft,Sft=T.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(xze,{ref:a,className:$t("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(Ri,{className:"ml-auto h-4 w-4"})]}));Sft.displayName=xze.displayName;const Cft=T.forwardRef(({className:t,...s},r)=>e.jsx(yze,{ref:r,className:$t("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}));Cft.displayName=yze.displayName;const ju=T.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Nft,{children:e.jsx(dze,{ref:n,sideOffset:s,className:$t("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})}));ju.displayName=dze.displayName;const Va=T.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(hze,{ref:n,className:$t("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}));Va.displayName=hze.displayName;const Mft=T.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(mze,{ref:a,className:$t("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(fze,{children:e.jsx(ma,{className:"h-4 w-4"})})}),s]}));Mft.displayName=mze.displayName;const Tft=T.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(pze,{ref:n,className:$t("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(fze,{children:e.jsx(Td,{className:"h-2 w-2 fill-current"})})}),s]}));Tft.displayName=pze.displayName;const Afe=T.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(uze,{ref:n,className:$t("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));Afe.displayName=uze.displayName;const eN=T.forwardRef(({className:t,...s},r)=>e.jsx(gze,{ref:r,className:$t("-mx-1 my-1 h-px bg-muted",t),...s}));eN.displayName=gze.displayName;const Aft=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n}=Ave();if(!(t&&!!s))return null;const o=l=>l.split(" ").map(i=>i[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:[e.jsx(br,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"}),r.length>1?e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsxs(Y,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[e.jsxs(fn,{className:"h-5 w-5",children:[e.jsx(_a,{src:s.avatar_url||void 0}),e.jsx(gn,{className:"text-[10px] bg-primary-foreground/30",children:o(s.name)})]}),e.jsx("strong",{children:s.name}),e.jsx(Gc,{className:"h-3 w-3"})]})}),e.jsx(ju,{align:"start",children:r.map(l=>e.jsxs(Va,{onClick:()=>n(l),className:"gap-2",children:[e.jsxs(fn,{className:"h-6 w-6",children:[e.jsx(_a,{src:l.avatar_url||void 0}),e.jsx(gn,{className:"text-[10px]",children:o(l.name)})]}),e.jsx("span",{children:l.name}),l.id===s.id&&e.jsx(ct,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},l.id))})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(fn,{className:"h-5 w-5",children:[e.jsx(_a,{src:s.avatar_url||void 0}),e.jsx(gn,{className:"text-[10px] bg-primary-foreground/30",children:o(s.name)})]}),e.jsx("strong",{children:s.name})]})]}),e.jsx(ct,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:"Assistant Mode"})]})})},Sr=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,isAdmin:o,isBrokerageManager:l}=Ys();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(Nue,{to:"/dashboard",replace:!0}):r&&!l&&!o?e.jsx(Nue,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Nue,{to:"/auth",replace:!0})};var $ve={};(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 Te=new OffscreenCanvas(1,1),ve=Te.getContext("2d");ve.fillRect(0,0,1,1);var ye=Te.transferToImageBitmap();ve.createPattern(ye,"no-repeat")}catch{return!1}return!0}();function d(){}function h(Te){var ve=r.exports.Promise,ye=ve!==void 0?ve:s.Promise;return typeof ye=="function"?new ye(Te):(Te(d,d),null)}var f=function(Te,ve){return{transform:function(ye){if(Te)return ye;if(ve.has(ye))return ve.get(ye);var Se=new OffscreenCanvas(ye.width,ye.height),Ke=Se.getContext("2d");return Ke.drawImage(ye,0,0),ve.set(ye,Se),Se},clear:function(){ve.clear()}}}(i,new Map),g=function(){var Te=Math.floor(16.666666666666668),ve,ye,Se={},Ke=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ve=function(Ae){var Ee=Math.random();return Se[Ee]=requestAnimationFrame(function He(Ue){Ke===Ue||Ke+Te-1{const{data:s,error:r}=await Z.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 Ift(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function Pft(){const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{error:n}=await Z.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 Aie="Dialog",[vze,_ze]=Dc(Aie),[Lft,Tg]=vze(Aie),bze=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=T.useRef(null),d=T.useRef(null),[h,f]=Sh({prop:n,defaultProp:a??!1,onChange:o,caller:Aie});return e.jsx(Lft,{scope:s,triggerRef:i,contentRef:d,contentId:Id(),titleId:Id(),descriptionId:Id(),open:h,onOpenChange:f,onOpenToggle:T.useCallback(()=>f(g=>!g),[f]),modal:l,children:r})};bze.displayName=Aie;var wze="DialogTrigger",jze=T.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Tg(wze,r),o=ba(s,a.triggerRef);return e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Vve(a.open),...n,ref:o,onClick:kr(t.onClick,a.onOpenToggle)})});jze.displayName=wze;var Uve="DialogPortal",[Dft,kze]=vze(Uve,{forceMount:void 0}),Nze=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=Tg(Uve,s);return e.jsx(Dft,{scope:s,forceMount:r,children:T.Children.map(n,l=>e.jsx(Qc,{present:r||o.open,children:e.jsx(C3,{asChild:!0,container:a,children:l})}))})};Nze.displayName=Uve;var Cre="DialogOverlay",Sze=T.forwardRef((t,s)=>{const r=kze(Cre,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Tg(Cre,t.__scopeDialog);return o.modal?e.jsx(Qc,{present:n||o.open,children:e.jsx(Rft,{...a,ref:s})}):null});Sze.displayName=Cre;var Oft=W1("DialogOverlay.RemoveScroll"),Rft=T.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Tg(Cre,r);return e.jsx(E6,{as:Oft,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Qr.div,{"data-state":Vve(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),tN="DialogContent",Cze=T.forwardRef((t,s)=>{const r=kze(tN,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Tg(tN,t.__scopeDialog);return e.jsx(Qc,{present:n||o.open,children:o.modal?e.jsx(Fft,{...a,ref:s}):e.jsx(zft,{...a,ref:s})})});Cze.displayName=tN;var Fft=T.forwardRef((t,s)=>{const r=Tg(tN,t.__scopeDialog),n=T.useRef(null),a=ba(s,r.contentRef,n);return T.useEffect(()=>{const o=n.current;if(o)return Nie(o)},[]),e.jsx(Mze,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:kr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:kr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:kr(t.onFocusOutside,o=>o.preventDefault())})}),zft=T.forwardRef((t,s)=>{const r=Tg(tN,t.__scopeDialog),n=T.useRef(!1),a=T.useRef(!1);return e.jsx(Mze,{...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,h;(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;((h=r.triggerRef.current)==null?void 0:h.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),Mze=T.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=Tg(tN,r),d=T.useRef(null),h=ba(s,d);return kie(),e.jsxs(e.Fragment,{children:[e.jsx(T6,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(n_,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Vve(i.open),...l,ref:h,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx($ft,{titleId:i.titleId}),e.jsx(qft,{contentRef:d,descriptionId:i.descriptionId})]})]})}),qve="DialogTitle",Tze=T.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Tg(qve,r);return e.jsx(Qr.h2,{id:a.titleId,...n,ref:s})});Tze.displayName=qve;var Aze="DialogDescription",Eze=T.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Tg(Aze,r);return e.jsx(Qr.p,{id:a.descriptionId,...n,ref:s})});Eze.displayName=Aze;var Ize="DialogClose",Pze=T.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Tg(Ize,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:kr(t.onClick,()=>a.onOpenChange(!1))})});Pze.displayName=Ize;function Vve(t){return t?"open":"closed"}var Lze="DialogTitleWarning",[Bft,Dze]=_nt(Lze,{contentName:tN,titleName:qve,docsSlug:"dialog"}),$ft=({titleId:t})=>{const s=Dze(Lze),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 T.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},Uft="DialogDescriptionWarning",qft=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Dze(Uft).contentName}}.`;return T.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},Eie=bze,Hve=jze,Iie=Nze,B3=Sze,$3=Cze,L6=Tze,D6=Eze,Pie=Pze;const js=Eie,Fi=Hve,Vft=Iie,Oze=T.forwardRef(({className:t,...s},r)=>e.jsx(B3,{ref:r,className:$t("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}));Oze.displayName=B3.displayName;const _s=T.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(Vft,{children:[e.jsx(Oze,{}),e.jsxs($3,{ref:n,className:$t("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(Pie,{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(Xr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_s.displayName=$3.displayName;const Ls=({className:t,...s})=>e.jsx("div",{className:$t("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});Ls.displayName="DialogHeader";const Hn=({className:t,...s})=>e.jsx("div",{className:$t("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Hn.displayName="DialogFooter";const Ps=T.forwardRef(({className:t,...s},r)=>e.jsx(L6,{ref:r,className:$t("text-lg font-semibold leading-none tracking-tight",t),...s}));Ps.displayName=L6.displayName;const en=T.forwardRef(({className:t,...s},r)=>e.jsx(D6,{ref:r,className:$t("text-sm text-muted-foreground",t),...s}));en.displayName=D6.displayName;const Hft={points_earned:vo,listing_created:Zn,deal_closed:Ad,custom:qn},y4e={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"};function Wft(){const{user:t}=Ys(),s=vs(),{data:r}=Eft(),n=Ift(),[a,o]=T.useState(null),[l,i]=T.useState(!1),d=T.useCallback(()=>{const _=Date.now()+3e3,j={startVelocity:30,spread:360,ticks:60,zIndex:9999},w=(M,S)=>Math.random()*(S-M)+M,k=setInterval(()=>{const M=_-Date.now();if(M<=0){clearInterval(k);return}const S=50*(M/3e3);x4e({...j,particleCount:S,origin:{x:w(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),x4e({...j,particleCount:S,origin:{x:w(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);T.useEffect(()=>{r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(d,100))},[r,a,d]);const h=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(j=>j.id!==v))??[]),await n.mutateAsync(v)}};if(!a)return null;const f=Hft[a.celebration_type]||qn,g=y4e[a.celebration_type]||y4e.custom;return e.jsx(js,{open:l,onOpenChange:v=>!v&&h(),children:e.jsxs(_s,{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(f,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(Sn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(Sn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(Sn,{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(Y,{onClick:h,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 Rze="/assets/levelup-logo-horizontal-DEFNc0ms.png",Wve="/assets/levelup-logo-white-C2RAgAoG.png",Gft="/assets/listings-hero-BI9Ki9Dq.jpg",Be=T.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:$t("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}));Be.displayName="Input";var Fze={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(By,function(){var r,n,a;function o(i,d){if(!r)r=d;else if(!n)n=d;else{var h="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;",f={};r(f),a=d(f),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([h],{type:"text/javascript"})))}}o(["exports"],function(i){var d=1e-6,h=typeof Float32Array<"u"?Float32Array:Array;function f(p,c){var m=c[0],y=c[1],b=c[2],A=c[3],I=m*A-b*y;return I?(p[0]=A*(I=1/I),p[1]=-y*I,p[2]=-b*I,p[3]=m*I,p):null}function g(){var p=new h(9);return h!=Float32Array&&(p[1]=0,p[2]=0,p[3]=0,p[5]=0,p[6]=0,p[7]=0),p[0]=1,p[4]=1,p[8]=1,p}function v(p,c){var m=c[0],y=c[1],b=c[2],A=c[3],I=c[4],O=c[5],z=c[6],q=c[7],X=c[8];return p[0]=I*X-O*q,p[1]=b*q-y*X,p[2]=y*O-b*I,p[3]=O*z-A*X,p[4]=m*X-b*z,p[5]=b*A-m*O,p[6]=A*q-I*z,p[7]=y*z-m*q,p[8]=m*I-y*A,p}function _(p,c,m){var y=c[0],b=c[1],A=c[2],I=c[3],O=c[4],z=c[5],q=c[6],X=c[7],Q=c[8],se=m[0],ae=m[1],le=m[2],xe=m[3],Me=m[4],Ce=m[5],ze=m[6],Ve=m[7],Je=m[8];return p[0]=se*y+ae*I+le*q,p[1]=se*b+ae*O+le*X,p[2]=se*A+ae*z+le*Q,p[3]=xe*y+Me*I+Ce*q,p[4]=xe*b+Me*O+Ce*X,p[5]=xe*A+Me*z+Ce*Q,p[6]=ze*y+Ve*I+Je*q,p[7]=ze*b+Ve*O+Je*X,p[8]=ze*A+Ve*z+Je*Q,p}function j(){var p=new h(16);return h!=Float32Array&&(p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[11]=0,p[12]=0,p[13]=0,p[14]=0),p[0]=1,p[5]=1,p[10]=1,p[15]=1,p}function w(p){var c=new h(16);return c[0]=p[0],c[1]=p[1],c[2]=p[2],c[3]=p[3],c[4]=p[4],c[5]=p[5],c[6]=p[6],c[7]=p[7],c[8]=p[8],c[9]=p[9],c[10]=p[10],c[11]=p[11],c[12]=p[12],c[13]=p[13],c[14]=p[14],c[15]=p[15],c}function k(p){return p[0]=1,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=1,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=1,p[11]=0,p[12]=0,p[13]=0,p[14]=0,p[15]=1,p}function M(p,c){var m=c[0],y=c[1],b=c[2],A=c[3],I=c[4],O=c[5],z=c[6],q=c[7],X=c[8],Q=c[9],se=c[10],ae=c[11],le=c[12],xe=c[13],Me=c[14],Ce=c[15],ze=m*O-y*I,Ve=m*z-b*I,Je=m*q-A*I,vt=y*z-b*O,mt=y*q-A*O,St=b*q-A*z,It=X*xe-Q*le,Ot=X*Me-se*le,ns=X*Ce-ae*le,qt=Q*Me-se*xe,us=Q*Ce-ae*xe,gs=se*Ce-ae*Me,xs=ze*gs-Ve*us+Je*qt+vt*ns-mt*Ot+St*It;return xs?(p[0]=(O*gs-z*us+q*qt)*(xs=1/xs),p[1]=(b*us-y*gs-A*qt)*xs,p[2]=(xe*St-Me*mt+Ce*vt)*xs,p[3]=(se*mt-Q*St-ae*vt)*xs,p[4]=(z*ns-I*gs-q*Ot)*xs,p[5]=(m*gs-b*ns+A*Ot)*xs,p[6]=(Me*Je-le*St-Ce*Ve)*xs,p[7]=(X*St-se*Je+ae*Ve)*xs,p[8]=(I*us-O*ns+q*It)*xs,p[9]=(y*ns-m*us-A*It)*xs,p[10]=(le*mt-xe*Je+Ce*ze)*xs,p[11]=(Q*Je-X*mt-ae*ze)*xs,p[12]=(O*Ot-I*qt-z*It)*xs,p[13]=(m*qt-y*Ot+b*It)*xs,p[14]=(xe*Ve-le*vt-Me*ze)*xs,p[15]=(X*vt-Q*Ve+se*ze)*xs,p):null}function S(p,c,m){var y=c[0],b=c[1],A=c[2],I=c[3],O=c[4],z=c[5],q=c[6],X=c[7],Q=c[8],se=c[9],ae=c[10],le=c[11],xe=c[12],Me=c[13],Ce=c[14],ze=c[15],Ve=m[0],Je=m[1],vt=m[2],mt=m[3];return p[0]=Ve*y+Je*O+vt*Q+mt*xe,p[1]=Ve*b+Je*z+vt*se+mt*Me,p[2]=Ve*A+Je*q+vt*ae+mt*Ce,p[3]=Ve*I+Je*X+vt*le+mt*ze,p[4]=(Ve=m[4])*y+(Je=m[5])*O+(vt=m[6])*Q+(mt=m[7])*xe,p[5]=Ve*b+Je*z+vt*se+mt*Me,p[6]=Ve*A+Je*q+vt*ae+mt*Ce,p[7]=Ve*I+Je*X+vt*le+mt*ze,p[8]=(Ve=m[8])*y+(Je=m[9])*O+(vt=m[10])*Q+(mt=m[11])*xe,p[9]=Ve*b+Je*z+vt*se+mt*Me,p[10]=Ve*A+Je*q+vt*ae+mt*Ce,p[11]=Ve*I+Je*X+vt*le+mt*ze,p[12]=(Ve=m[12])*y+(Je=m[13])*O+(vt=m[14])*Q+(mt=m[15])*xe,p[13]=Ve*b+Je*z+vt*se+mt*Me,p[14]=Ve*A+Je*q+vt*ae+mt*Ce,p[15]=Ve*I+Je*X+vt*le+mt*ze,p}function E(p,c,m){var y,b,A,I,O,z,q,X,Q,se,ae,le,xe=m[0],Me=m[1],Ce=m[2];return c===p?(p[12]=c[0]*xe+c[4]*Me+c[8]*Ce+c[12],p[13]=c[1]*xe+c[5]*Me+c[9]*Ce+c[13],p[14]=c[2]*xe+c[6]*Me+c[10]*Ce+c[14],p[15]=c[3]*xe+c[7]*Me+c[11]*Ce+c[15]):(b=c[1],A=c[2],I=c[3],O=c[4],z=c[5],q=c[6],X=c[7],Q=c[8],se=c[9],ae=c[10],le=c[11],p[0]=y=c[0],p[1]=b,p[2]=A,p[3]=I,p[4]=O,p[5]=z,p[6]=q,p[7]=X,p[8]=Q,p[9]=se,p[10]=ae,p[11]=le,p[12]=y*xe+O*Me+Q*Ce+c[12],p[13]=b*xe+z*Me+se*Ce+c[13],p[14]=A*xe+q*Me+ae*Ce+c[14],p[15]=I*xe+X*Me+le*Ce+c[15]),p}function D(p,c,m){var y=m[0],b=m[1],A=m[2];return p[0]=c[0]*y,p[1]=c[1]*y,p[2]=c[2]*y,p[3]=c[3]*y,p[4]=c[4]*b,p[5]=c[5]*b,p[6]=c[6]*b,p[7]=c[7]*b,p[8]=c[8]*A,p[9]=c[9]*A,p[10]=c[10]*A,p[11]=c[11]*A,p[12]=c[12],p[13]=c[13],p[14]=c[14],p[15]=c[15],p}function L(p,c,m){var y=Math.sin(m),b=Math.cos(m),A=c[4],I=c[5],O=c[6],z=c[7],q=c[8],X=c[9],Q=c[10],se=c[11];return c!==p&&(p[0]=c[0],p[1]=c[1],p[2]=c[2],p[3]=c[3],p[12]=c[12],p[13]=c[13],p[14]=c[14],p[15]=c[15]),p[4]=A*b+q*y,p[5]=I*b+X*y,p[6]=O*b+Q*y,p[7]=z*b+se*y,p[8]=q*b-A*y,p[9]=X*b-I*y,p[10]=Q*b-O*y,p[11]=se*b-z*y,p}function B(p,c,m){var y=Math.sin(m),b=Math.cos(m),A=c[0],I=c[1],O=c[2],z=c[3],q=c[8],X=c[9],Q=c[10],se=c[11];return c!==p&&(p[4]=c[4],p[5]=c[5],p[6]=c[6],p[7]=c[7],p[12]=c[12],p[13]=c[13],p[14]=c[14],p[15]=c[15]),p[0]=A*b-q*y,p[1]=I*b-X*y,p[2]=O*b-Q*y,p[3]=z*b-se*y,p[8]=A*y+q*b,p[9]=I*y+X*b,p[10]=O*y+Q*b,p[11]=z*y+se*b,p}function $(p,c,m){var y=Math.sin(m),b=Math.cos(m),A=c[0],I=c[1],O=c[2],z=c[3],q=c[4],X=c[5],Q=c[6],se=c[7];return c!==p&&(p[8]=c[8],p[9]=c[9],p[10]=c[10],p[11]=c[11],p[12]=c[12],p[13]=c[13],p[14]=c[14],p[15]=c[15]),p[0]=A*b+q*y,p[1]=I*b+X*y,p[2]=O*b+Q*y,p[3]=z*b+se*y,p[4]=q*b-A*y,p[5]=X*b-I*y,p[6]=Q*b-O*y,p[7]=se*b-z*y,p}function V(p,c){return p[0]=c[0],p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=c[1],p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=c[2],p[11]=0,p[12]=0,p[13]=0,p[14]=0,p[15]=1,p}function W(p,c,m){var y,b,A,I=m[0],O=m[1],z=m[2],q=Math.sqrt(I*I+O*O+z*z);return q0&&(A=1/Math.sqrt(A)),p[0]=c[0]*A,p[1]=c[1]*A,p[2]=c[2]*A,p}function Ge(p,c){return p[0]*c[0]+p[1]*c[1]+p[2]*c[2]}function wt(p,c,m){var y=c[0],b=c[1],A=c[2],I=m[0],O=m[1],z=m[2];return p[0]=b*z-A*O,p[1]=A*I-y*z,p[2]=y*O-b*I,p}function Ie(p,c,m,y){var b=c[0],A=c[1],I=c[2];return p[0]=b+y*(m[0]-b),p[1]=A+y*(m[1]-A),p[2]=I+y*(m[2]-I),p}function st(p,c,m){var y=c[0],b=c[1],A=c[2],I=m[3]*y+m[7]*b+m[11]*A+m[15];return p[0]=(m[0]*y+m[4]*b+m[8]*A+m[12])/(I=I||1),p[1]=(m[1]*y+m[5]*b+m[9]*A+m[13])/I,p[2]=(m[2]*y+m[6]*b+m[10]*A+m[14])/I,p}function he(p,c,m){var y=c[0],b=c[1],A=c[2];return p[0]=y*m[0]+b*m[3]+A*m[6],p[1]=y*m[1]+b*m[4]+A*m[7],p[2]=y*m[2]+b*m[5]+A*m[8],p}function We(p,c,m){var y=m[0],b=m[1],A=m[2],I=m[3],O=c[0],z=c[1],q=c[2],X=b*q-A*z,Q=A*O-y*q,se=y*z-b*O;return p[0]=O+I*(X+=X)+b*(se+=se)-A*(Q+=Q),p[1]=z+I*Q+A*X-y*se,p[2]=q+I*se+y*Q-b*X,p}function et(p){return p[0]=0,p[1]=0,p[2]=0,p}function Ye(p,c){return p[0]===c[0]&&p[1]===c[1]&&p[2]===c[2]}var ke=ge,at=Te,Fe=de;function it(){var p=new h(4);return h!=Float32Array&&(p[0]=0,p[1]=0,p[2]=0,p[3]=0),p}function dt(p,c,m){return p[0]=c[0]*m,p[1]=c[1]*m,p[2]=c[2]*m,p[3]=c[3]*m,p}function tt(p,c){var m=c[0],y=c[1],b=c[2],A=c[3],I=m*m+y*y+b*b+A*A;return I>0&&(I=1/Math.sqrt(I)),p[0]=m*I,p[1]=y*I,p[2]=b*I,p[3]=A*I,p}function ut(p,c,m){var y=c[0],b=c[1],A=c[2],I=c[3];return p[0]=m[0]*y+m[4]*b+m[8]*A+m[12]*I,p[1]=m[1]*y+m[5]*b+m[9]*A+m[13]*I,p[2]=m[2]*y+m[6]*b+m[10]*A+m[14]*I,p[3]=m[3]*y+m[7]*b+m[11]*A+m[15]*I,p}function xt(){var p=new h(4);return h!=Float32Array&&(p[0]=0,p[1]=0,p[2]=0),p[3]=1,p}function _t(p){return p[0]=0,p[1]=0,p[2]=0,p[3]=1,p}function qe(p,c,m){m*=.5;var y=c[0],b=c[1],A=c[2],I=c[3],O=Math.sin(m),z=Math.cos(m);return p[0]=y*z+I*O,p[1]=b*z+A*O,p[2]=A*z-b*O,p[3]=I*z-y*O,p}function Lt(p,c,m){m*=.5;var y=c[0],b=c[1],A=c[2],I=c[3],O=Math.sin(m),z=Math.cos(m);return p[0]=y*z-A*O,p[1]=b*z+I*O,p[2]=A*z+y*O,p[3]=I*z-b*O,p}ie(),it();var Rt,Kt,Xt,ss=tt,fs=(Rt=ie(),Kt=oe(1,0,0),Xt=oe(0,1,0),function(p,c,m){var y=Ge(c,m);return y<-.999999?(wt(Rt,Kt,c),Fe(Rt)<1e-6&&wt(Rt,Xt,c),De(Rt,Rt),function(b,A,I){I*=.5;var O=Math.sin(I);b[0]=O*A[0],b[1]=O*A[1],b[2]=O*A[2],b[3]=Math.cos(I)}(p,Rt,Math.PI),p):y>.999999?(p[0]=0,p[1]=0,p[2]=0,p[3]=1,p):(wt(Rt,c,m),p[0]=Rt[0],p[1]=Rt[1],p[2]=Rt[2],p[3]=1+y,ss(p,p))});function fr(){var p=new h(2);return h!=Float32Array&&(p[0]=0,p[1]=0),p}function yt(p,c){var m=new h(2);return m[0]=p,m[1]=c,m}function bs(p,c,m){return p[0]=c,p[1]=m,p}function gr(p,c,m){return p[0]=c[0]+m[0],p[1]=c[1]+m[1],p}function Br(p,c,m){return p[0]=c[0]-m[0],p[1]=c[1]-m[1],p}function na(p,c,m){return p[0]=c[0]*m,p[1]=c[1]*m,p}function za(p){var c=p[0],m=p[1];return Math.sqrt(c*c+m*m)}function go(p,c){var m=c[0],y=c[1],b=m*m+y*y;return b>0&&(b=1/Math.sqrt(b)),p[0]=c[0]*b,p[1]=c[1]*b,p}function Ia(p,c){return p[0]*c[0]+p[1]*c[1]}xt(),xt(),g();var nn,Qt,lr=Br;function Vr(p){return p&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default")?p.default:p}fr();var Pr=function(){if(Qt)return nn;function p(c,m,y,b){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*(b-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=c,this.p1y=m,this.p2x=y,this.p2y=b}return Qt=1,nn=p,p.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,b=0;b<8;b++){var A=this.sampleCurveX(y)-c;if(Math.abs(A)A?O=y:z=y,y=.5*(z-O)+O;return y},solve:function(c,m){return this.sampleCurveY(this.solveCurveX(c,m))}},nn}(),on=Vr(Pr);function cs(p,c){this.x=p,this.y=c}function ka(p,c){if(Array.isArray(p)){if(!Array.isArray(c)||p.length!==c.length)return!1;for(let m=0;m=1)return 1;const c=p*p,m=c*p;return 4*(p<.5?m:3*(p-c)+m-.75)}function Fc(p,c,m,y){const b=new on(p,c,m,y);return function(A){return b.solve(A)}}const rt=Fc(.25,.1,.25,1);function _e(p,c,m){return Math.min(m,Math.max(c,p))}function Pe(p,c,m){return(m=_e((m-p)/(c-p),0,1))*m*(3-2*m)}function Qe(p,c,m){const y=m-c,b=((p-c)%y+y)%y+c;return b===c?m:b}function Tt(p,c,m){if(!p.length)return m(null,[]);let y=p.length;const b=new Array(p.length);let A=null;p.forEach((I,O)=>{c(I,(z,q)=>{z&&(A=z),b[O]=q,--y==0&&m(A,b)})})}let kt=1;function Dt(){return kt++}function Zt(p){return p<=1?1:Math.pow(2,Math.ceil(Math.log2(p)))}function Ft(p,c){p.forEach(m=>{c[m]&&(c[m]=c[m].bind(c))})}function Jt(p,c,m){const y={};for(const b in p)y[b]=c.call(this,p[b],b,p);return y}function Ss(p,c,m){const y={};for(const b in p)c.call(this,p[b],b,p)&&(y[b]=p[b]);return y}function ps(p){return Array.isArray(p)?p.map(ps):typeof p=="object"&&p?Jt(p,ps):p}function ur(p,c){for(let m=0;m=0)return!0;return!1}const Dr={};function cr(p){Dr[p]||(typeof console<"u"&&console.warn(p),Dr[p]=!0)}function jn(p,c,m){return(m.y-p.y)*(c.x-p.x)>(c.y-p.y)*(m.x-p.x)}function kn(p){let c=0;for(let m,y,b=0,A=p.length,I=A-1;b@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,y,b,A)=>{const I=b||A;return c[y]=!I||I.toLowerCase(),""}),c["max-age"]){const m=parseInt(c["max-age"],10);isNaN(m)?delete c["max-age"]:c["max-age"]=m}return c}let Po=null;function Pa(p,c){return[p[4*c],p[4*c+1],p[4*c+2],p[4*c+3]]}function Fo(p,c,m,y){for(;c>1;p[b]>1;p[b]<=y?c=b+1:m=b}return c}function pa(p){return p>0?1/(1.001-p):1+p}function Zi(p){return p>0?1-1/(1.001-p):-p}function ci(p,c,m){return(p-c.min)*(m.max-m.min)/(c.max-c.min)+m.min}const Xn={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(!Xn.API_URL)return null;try{const p=new URL(Xn.API_URL);return p.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":p.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 Yi(p){return Xn.API_URL_REGEX.test(p)}function Ll(p){return Xn.API_SPRITE_REGEX.test(p)}let Zl,fd,dp,al,nu,zc;function Lh(){return Zl==null&&(Zl=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Zl}const il={now:()=>al!==void 0?al:performance.now(),setNow(p){al=p},restoreNow(){al=void 0},frame(p){const c=requestAnimationFrame(p);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(p,c=0){const{width:m,height:y}=p;nu||(nu=document.createElement("canvas"));const b=nu.getContext("2d",{willReadFrequently:!0});if(!b)throw new Error("failed to create canvas 2d context");return(m>nu.width||y>nu.height)&&(nu.width=m,nu.height=y),b.clearRect(-c,-c,m+2*c,y+2*c),b.drawImage(p,0,0,m,y),b.getImageData(-c,-c,m+2*c,y+2*c)},resolveURL:p=>(fd||(fd=document.createElement("a")),fd.href=p,fd.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(dp==null&&(dp=window.matchMedia("(prefers-reduced-motion: reduce)")),dp.matches)},hasCanvasFingerprintNoise(){if(zc!==void 0)return zc;if(!Lh())return zc=!1,!1;const p=new OffscreenCanvas(85,1),c=p.getContext("2d",{willReadFrequently:!0});let m=0;for(let b=0;b0?`?${A}`:""}`}const A0="mapbox-tiles";let E0=500,I0=50;const ym=["language","worldview","jobid"];let Xu,gd;function ku(){try{return caches}catch{}}function Bc(){const p=ku();p&&Xu==null&&(Xu=p.open(A0))}let xd=1/0;const Jo={supported:!1,testSupport:function(p){!au&&vm&&(uf?Qx(p):Qu=p)}};let Qu,vm,au=!1,uf=!1;const P0=typeof self<"u"?self:{};function Qx(p){const c=p.createTexture();p.bindTexture(p.TEXTURE_2D,c);try{if(p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,vm),p.isContextLost())return;Jo.supported=!0}catch{}p.deleteTexture(c),au=!0}P0.document&&(vm=P0.document.createElement("img"),vm.onload=function(){Qu&&Qx(Qu),Qu=null,uf=!0},vm.onerror=function(){au=!0,Qu=null},vm.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const hf={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(hf);class Dd extends Error{constructor(c,m,y){m===401&&Yi(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 L0=aa()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,up=function(p,c){if(!(/^file:/.test(m=p.url)||/^file:/.test(L0())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(y,b){const A=new AbortController,I=new Request(y.url,{method:y.method||"GET",body:y.body,credentials:y.credentials,headers:y.headers,referrer:L0(),referrerPolicy:y.referrerPolicy,signal:A.signal});let O=!1,z=!1;const q=(X=I.url).indexOf("sku=")>0&&Yi(X);var X;y.type==="json"&&I.headers.set("Accept","application/json");const Q=(ae,le,xe)=>{if(z)return;if(ae&&ae.message!=="SecurityError"&&cr(ae.toString()),le&&xe)return se(le);const Me=Date.now();fetch(I).then(Ce=>{if(Ce.ok){const ze=q?Ce.clone():null;return se(Ce,ze,Me)}return b(new Dd(Ce.statusText,Ce.status,y.url))}).catch(Ce=>{Ce.name!=="AbortError"&&b(new Error(`${Ce.message} ${y.url}`))})},se=(ae,le,xe)=>{(y.type==="arrayBuffer"?ae.arrayBuffer():y.type==="json"?ae.json():ae.text()).then(Me=>{z||(le&&xe&&function(Ce,ze,Ve){if(Bc(),Xu==null)return;const Je=so(ze.headers.get("Cache-Control")||"");if(Je["no-store"])return;const vt={status:ze.status,statusText:ze.statusText,headers:new Headers};ze.headers.forEach((It,Ot)=>vt.headers.set(Ot,It)),Je["max-age"]&&vt.headers.set("Expires",new Date(Ve+1e3*Je["max-age"]).toUTCString());const mt=vt.headers.get("Expires");if(!mt||new Date(mt).getTime()-Ve<42e4)return;let St=Lg(Ce.url,{persistentParams:ym});if(ze.status===206){const It=Ce.headers.get("Range");if(!It)return;vt.status=200,St=df(St,{range:It})}(function(It,Ot){if(gd===void 0)try{new Response(new ReadableStream),gd=!0}catch{gd=!1}gd?Ot(It.body):It.blob().then(Ot).catch(ns=>cr(ns.message))})(ze,It=>{const Ot=new Response((ns=ze.status)!==200&&ns!==404&&[101,103,204,205,304].includes(ns)?null:It,vt);var ns;Bc(),Xu!=null&&Xu.then(qt=>qt.put(St,Ot)).catch(qt=>cr(qt.message))})}(I,le,xe),O=!0,b(null,Me,ae.headers))}).catch(Me=>{z||b(new Error(Me.message))})};return q?function(ae,le){if(Bc(),Xu==null)return le(null);Xu.then(xe=>{let Me=Lg(ae.url,{persistentParams:ym});const Ce=ae.headers.get("Range");Ce&&(Me=df(Me,{range:Ce})),xe.match(Me).then(ze=>{const Ve=function(Je){if(!Je)return!1;const vt=new Date(Je.headers.get("Expires")||0),mt=so(Je.headers.get("Cache-Control")||"");return Number(vt)>Date.now()&&!mt["no-cache"]}(ze);xe.delete(Me).catch(le),Ve&&xe.put(Me,ze.clone()).catch(le),le(null,ze,Ve)}).catch(le)}).catch(le)}(I,Q):Q(null,null),{cancel:()=>{z=!0,O||A.abort()}}}(p,c);if(aa(self)&&self.worker.actor)return self.worker.actor.send("getResource",p,c,void 0,!0)}var m;return function(y,b){const A=new XMLHttpRequest;A.open(y.method||"GET",y.url,!0),y.type==="arrayBuffer"&&(A.responseType="arraybuffer");for(const I in y.headers)A.setRequestHeader(I,y.headers[I]);return y.type==="json"&&(A.responseType="text",A.setRequestHeader("Accept","application/json")),A.withCredentials=y.credentials==="include",A.onerror=()=>{b(new Error(A.statusText))},A.onload=()=>{if((A.status>=200&&A.status<300||A.status===0)&&A.response!==null){let I=A.response;if(y.type==="json")try{I=JSON.parse(A.response)}catch(z){return b(z)}const O=new Headers;A.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(z=>{const q=z.split(": "),X=q.shift(),Q=q.join(": ");O.append(X,Q)}),b(null,I,O)}else b(new Dd(A.statusText,A.status,y.url))},A.send(y.body),{cancel:()=>A.abort()}}(p,c)},Ju=function(p,c){return up(Object.assign(p,{type:"arrayBuffer"}),c)};function fM(p){const c=document.createElement("a");return c.href=p,c.protocol===location.protocol&&c.host===location.host}const DN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Jx,da;Jx=[],da=0;const D0=function(p,c){if(Jo.supported&&(p.headers||(p.headers={}),p.headers.accept="image/webp,*/*"),da>=Xn.MAX_PARALLEL_IMAGE_REQUESTS){const A={requestParameters:p,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return Jx.push(A),A}da++;let m=!1;const y=()=>{if(!m)for(m=!0,da--;Jx.length&&da{y(),A?c(A):I&&(self.createImageBitmap?function(z,q){const X=new Blob([new Uint8Array(z)],{type:"image/png"});createImageBitmap(X).then(Q=>{q(null,Q)}).catch(Q=>{q(new Error(`Could not load image because of ${Q.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(I,(z,q)=>c(z,q,O)):function(z,q){const X=new Image;X.onload=()=>{q(null,X),URL.revokeObjectURL(X.src),X.onload=null,requestAnimationFrame(()=>{X.src=DN})},X.onerror=()=>q(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 Q=new Blob([new Uint8Array(z)],{type:"image/png"});X.src=z.byteLength?URL.createObjectURL(Q):DN}(I,(z,q)=>c(z,q,O)))});return{cancel:()=>{b.cancel(),y()}}};var w_,ON,RN,hp={exports:{}},Dg={exports:{}},ey={exports:{}},Nt=function(){if(RN)return hp.exports;RN=1;var p=(w_||(w_=1,Dg.exports=function(m,y){var b,A,I,O,z,q,X,Q;for(A=m.length-(b=3&m.length),I=y,z=3432918353,q=461845907,Q=0;Q>>16)*z&65535)<<16)&4294967295)<<15|X>>>17))*q+(((X>>>16)*q&65535)<<16)&4294967295)<<13|I>>>19))+((5*(I>>>16)&65535)<<16)&4294967295))+((58964+(O>>>16)&65535)<<16);switch(X=0,b){case 3:X^=(255&m.charCodeAt(Q+2))<<16;case 2:X^=(255&m.charCodeAt(Q+1))<<8;case 1:I^=X=(65535&(X=(X=(65535&(X^=255&m.charCodeAt(Q)))*z+(((X>>>16)*z&65535)<<16)&4294967295)<<15|X>>>17))*q+(((X>>>16)*q&65535)<<16)&4294967295}return I^=m.length,I=2246822507*(65535&(I^=I>>>16))+((2246822507*(I>>>16)&65535)<<16)&4294967295,I=3266489909*(65535&(I^=I>>>13))+((3266489909*(I>>>16)&65535)<<16)&4294967295,(I^=I>>>16)>>>0}),Dg.exports),c=(ON||(ON=1,ey.exports=function(m,y){for(var b,A=m.length,I=y^A,O=0;A>=4;)b=1540483477*(65535&(b=255&m.charCodeAt(O)|(255&m.charCodeAt(++O))<<8|(255&m.charCodeAt(++O))<<16|(255&m.charCodeAt(++O))<<24))+((1540483477*(b>>>16)&65535)<<16),I=1540483477*(65535&I)+((1540483477*(I>>>16)&65535)<<16)^(b=1540483477*(65535&(b^=b>>>24))+((1540483477*(b>>>16)&65535)<<16)),A-=4,++O;switch(A){case 3:I^=(255&m.charCodeAt(O+2))<<16;case 2:I^=(255&m.charCodeAt(O+1))<<8;case 1:I=1540483477*(65535&(I^=255&m.charCodeAt(O)))+((1540483477*(I>>>16)&65535)<<16)}return I=1540483477*(65535&(I^=I>>>13))+((1540483477*(I>>>16)&65535)<<16),(I^=I>>>15)>>>0}),ey.exports);return hp.exports=p,hp.exports.murmur3=p,hp.exports.murmur2=c,hp.exports}(),Cs=Vr(Nt);class Ks{constructor(c,...m){Object.assign(this,m[0]||{}),this.type=c}}class dn extends Ks{constructor(c,m={}){super("error",Object.assign({error:c},m))}}function vn(p,c,m){m[p]&&m[p].indexOf(c)!==-1||(m[p]=m[p]||[],m[p].push(c))}function fa(p,c,m){if(m&&m[p]){const y=m[p].indexOf(c);y!==-1&&m[p].splice(y,1)}}class Qn{on(c,m){return this._listeners=this._listeners||{},vn(c,m,this._listeners),this}off(c,m){return fa(c,m,this._listeners),fa(c,m,this._oneTimeListeners),this}once(c,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},vn(c,m,this._oneTimeListeners),this):new Promise(y=>{this.once(c,y)})}fire(c,m){const y=typeof c=="string"?new Ks(c,m):c,b=y.type;if(this.listens(b)){y.target=this;const A=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const z of A)z.call(this,y);const I=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const z of I)fa(b,z,this._oneTimeListeners),z.call(this,y);const O=this._eventedParent;if(O){const z=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(y,z),O.fire(y)}}else y instanceof dn&&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 La{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new La(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[m,y]=c.split("");return new La({name:m,iconsetId:y})}static isEqual(c,m){return c.name===m.name&&c.iconsetId===m.iconsetId}toString(){return La.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var _m,Nu={},Yl=function(){if(_m)return Nu;_m=1;var p={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(A){return(A=Math.round(A))<0?0:A>255?255:A}function m(A){return c(A[A.length-1]==="%"?parseFloat(A)/100*255:parseInt(A))}function y(A){return(I=A[A.length-1]==="%"?parseFloat(A)/100:parseFloat(A))<0?0:I>1?1:I;var I}function b(A,I,O){return O<0?O+=1:O>1&&(O-=1),6*O<1?A+(I-A)*O*6:2*O<1?I:3*O<2?A+(I-A)*(2/3-O)*6:A}try{Nu.parseCSSColor=function(A){var I,O=A.replace(/ /g,"").toLowerCase();if(O in p)return p[O].slice();if(O[0]==="#")return O.length===4?(I=parseInt(O.substr(1),16))>=0&&I<=4095?[(3840&I)>>4|(3840&I)>>8,240&I|(240&I)>>4,15&I|(15&I)<<4,1]:null:O.length===7&&(I=parseInt(O.substr(1),16))>=0&&I<=16777215?[(16711680&I)>>16,(65280&I)>>8,255&I,1]:null;var z=O.indexOf("("),q=O.indexOf(")");if(z!==-1&&q+1===O.length){var X=O.substr(0,z),Q=O.substr(z+1,q-(z+1)).split(","),se=1;switch(X){case"rgba":if(Q.length!==4)return null;se=y(Q.pop());case"rgb":return Q.length!==3?null:[m(Q[0]),m(Q[1]),m(Q[2]),se];case"hsla":if(Q.length!==4)return null;se=y(Q.pop());case"hsl":if(Q.length!==3)return null;var ae=(parseFloat(Q[0])%360+360)%360/360,le=y(Q[1]),xe=y(Q[2]),Me=xe<=.5?xe*(le+1):xe+le-xe*le,Ce=2*xe-Me;return[c(255*b(Ce,Me,ae+1/3)),c(255*b(Ce,Me,ae)),c(255*b(Ce,Me,ae-1/3)),se];default:return null}}return null}}catch{}return Nu}();class Da{constructor(c,m,y,b=1){this.r=c,this.g=m,this.b=y,this.a=b}static parse(c){if(!c)return;if(c instanceof Da)return c;if(typeof c!="string")return;const m=Yl.parseCSSColor(c);return m?new Da(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[c,m,y,b]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*c)},${Math.round(255*m)},${Math.round(255*y)},${b})`}toNonPremultipliedRenderColor(c){const{r:m,g:y,b,a:A}=this;return new gL(c,m,y,b,A)}toPremultipliedRenderColor(c){const{r:m,g:y,b,a:A}=this;return new xL(c,m*A,y*A,b*A,A)}clone(){return new Da(this.r,this.g,this.b,this.a)}}class FN{constructor(c,m,y,b,A,I=!1){if(this.premultiplied=!1,this.premultiplied=I,c){const O=c.image.height,z=O*O;this.premultiplied?(m=A===0?0:m/A*(O-1),y=A===0?0:y/A*(O-1),b=A===0?0:b/A*(O-1)):(m*=O-1,y*=O-1,b*=O-1);const q=Math.floor(m),X=Math.floor(y),Q=Math.floor(b),se=Math.ceil(m),ae=Math.ceil(y),le=Math.ceil(b),xe=m-q,Me=y-X,Ce=b-Q,ze=c.image.data,Ve=4*(q+X*z+Q*O),Je=4*(q+X*z+le*O),vt=4*(q+ae*z+Q*O),mt=4*(q+ae*z+le*O),St=4*(se+X*z+Q*O),It=4*(se+X*z+le*O),Ot=4*(se+ae*z+Q*O),ns=4*(se+ae*z+le*O);if(Ve<0||ns>=ze.length)throw new Error("out of range");this.r=Jr(Jr(Jr(ze[Ve],ze[Je],Ce),Jr(ze[vt],ze[mt],Ce),Me),Jr(Jr(ze[St],ze[It],Ce),Jr(ze[Ot],ze[ns],Ce),Me),xe)/255*(this.premultiplied?A:1),this.g=Jr(Jr(Jr(ze[Ve+1],ze[Je+1],Ce),Jr(ze[vt+1],ze[mt+1],Ce),Me),Jr(Jr(ze[St+1],ze[It+1],Ce),Jr(ze[Ot+1],ze[ns+1],Ce),Me),xe)/255*(this.premultiplied?A:1),this.b=Jr(Jr(Jr(ze[Ve+2],ze[Je+2],Ce),Jr(ze[vt+2],ze[mt+2],Ce),Me),Jr(Jr(ze[St+2],ze[It+2],Ce),Jr(ze[Ot+2],ze[ns+2],Ce),Me),xe)/255*(this.premultiplied?A:1),this.a=A}else this.r=m,this.g=y,this.b=b,this.a=A}toArray(){const{r:c,g:m,b:y,a:b}=this;return[255*c,255*m,255*y,b]}toHslaArray(){let{r:c,g:m,b:y,a:b}=this;if(this.premultiplied){if(b===0)return[0,0,0,0];const le=1/b;c*=le,m*=le,y*=le}const A=Math.min(Math.max(c,0),1),I=Math.min(Math.max(m,0),1),O=Math.min(Math.max(y,0),1),z=Math.min(A,I,O),q=Math.max(A,I,O),X=q-z,Q=.5*(z+q);if(X===0)return[0,0,100*Q,b];const se=Q>.5?X/(2-q-z):X/(q+z);let ae;switch(q){case A:ae=60*((I-O)/X+(IJr(y,c[b],m))}Da.black=new Da(0,0,0,1),Da.white=new Da(1,1,1,1),Da.transparent=new Da(0,0,0,0),Da.red=new Da(1,0,0,1),Da.blue=new Da(0,0,1,1);var j_=Object.freeze({__proto__:null,array:gM,color:function(p,c,m){return new Da(Jr(p.r,c.r,m),Jr(p.g,c.g,m),Jr(p.b,c.b,m),Jr(p.a,c.a,m))},number:Jr});class Dh extends Error{constructor(c,m){super(m),this.message=m,this.key=c}}class O0{constructor(c,m=[]){this.parent=c,this.bindings={};for(const[y,b]of m)this.bindings[y]=b}concat(c){return new O0(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 bm={kind:"null"},Er={kind:"number"},ga={kind:"string"},ai={kind:"boolean"},iu={kind:"color"},mp={kind:"object"},Ka={kind:"value"},zN={kind:"collator"},k_={kind:"formatted"},N_={kind:"resolvedImage"};function Jc(p,c){return{kind:"array",itemType:p,N:c}}function Ko(p){if(p.kind==="array"){const c=Ko(p.itemType);return typeof p.N=="number"?`array<${c}, ${p.N}>`:p.itemType.kind==="value"?"array":`array<${c}>`}return p.kind}const Wle=[bm,Er,ga,ai,iu,k_,mp,Jc(Ka),N_];function Og(p,c){if(c.kind==="error")return null;if(p.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!Og(p.itemType,c.itemType))&&(typeof p.N!="number"||p.N===c.N))return null}else{if(p.kind===c.kind)return null;if(p.kind==="value"){for(const m of Wle)if(!Og(m,c))return null}}return`Expected ${Ko(p)} but found ${Ko(c)} instead.`}function xM(p,c){return c.some(m=>m.kind===p.kind)}function S_(p,c){return c.some(m=>m==="null"?p===null:m==="array"?Array.isArray(p):m==="object"?p&&!Array.isArray(p)&&typeof p=="object":m===typeof p)}function BN(p,c){return p.kind==="array"&&c.kind==="array"?p.N===c.N&&BN(p.itemType,c.itemType):p.kind===c.kind}class yM{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 $N{constructor(c,m,y,b,A){this.text=c.normalize?c.normalize():c,this.image=m,this.scale=y,this.fontStack=b,this.textColor=A}}class Od{constructor(c){this.sections=c}static fromString(c){return new Od([new $N(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 Od?c:Od.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 b=m.image.getPrimary().id.toString();c.push(["image",b]);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 mf{constructor(c,m={}){this.id=La.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,b,A;try{({id:m,params:y,sx:b,sy:A}=JSON.parse(c)||{})}catch{return null}return m?new mf(m,{params:y,sx:b,sy:A}):null}scaleSelf(c,m=c){return this.sx*=c,this.sy*=m,this}}class Rd{constructor(c,m,y,b,A=!1){this.primaryId=La.from(c),this.primaryOptions=m,y&&(this.secondaryId=La.from(y)),this.secondaryOptions=b,this.available=A}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new mf(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new mf(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Rd.build({name:c}):c}static build(c,m,y,b){return!c||typeof c=="object"&&!("name"in c)?null:new Rd(c,y,m,b)}}function ty(p,c,m,y){return typeof p=="number"&&p>=0&&p<=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 [${[p,c,m,y].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof y=="number"?[p,c,m,y]:[p,c,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function R0(p){if(p===null||typeof p=="string"||typeof p=="boolean"||typeof p=="number"||p instanceof Da||p instanceof yM||p instanceof Od||p instanceof Rd)return!0;if(Array.isArray(p)){for(const c of p)if(!R0(c))return!1;return!0}if(typeof p=="object"){for(const c in p)if(!R0(p[c]))return!1;return!0}return!1}function Dl(p){if(p===null)return bm;if(typeof p=="string")return ga;if(typeof p=="boolean")return ai;if(typeof p=="number")return Er;if(p instanceof Da)return iu;if(p instanceof yM)return zN;if(p instanceof Od)return k_;if(p instanceof Rd)return N_;if(Array.isArray(p)){const c=p.length;let m;for(const y of p){const b=Dl(y);if(m){if(m===b)continue;m=Ka;break}m=b}return Jc(m||Ka,c)}return mp}function Oh(p){const c=typeof p;return p===null?"":c==="string"||c==="number"||c==="boolean"?String(p):p instanceof Od||p instanceof Rd||p instanceof Da?p.toString():JSON.stringify(p)}class pf{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(!R0(c[1]))return m.error("invalid value");const y=c[1];let b=Dl(y);const A=m.expectedType;return b.kind!=="array"||b.N!==0||!A||A.kind!=="array"||typeof A.N=="number"&&A.N!==0||(b=A),new pf(b,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 Da?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Od?this.value.serialize():this.value}}class kl{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const vM={string:ga,number:Er,boolean:ai,object:mp};class wm{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,b=1;const A=c[0];if(A==="array"){let O,z;if(c.length>2){const q=c[1];if(typeof q!="string"||!(q in vM)||q==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);O=vM[q],b++}else O=Ka;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);z=c[2],b++}y=Jc(O,z)}else y=vM[A];const I=[];for(;bc.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 b=c.N;(typeof b=="number"||this.args.length>1)&&m.push(b)}}return m.concat(this.args.map(y=>y.serialize()))}}class pp{constructor(c){this.type=k_,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 b=[];let A=!1;for(let I=1;I<=c.length-1;++I){const O=c[I];if(A&&typeof O=="object"&&!Array.isArray(O)){A=!1;let z=null;if(O["font-scale"]&&(z=m.parseObjectValue(O["font-scale"],I,"font-scale",Er),!z))return null;let q=null;if(O["text-font"]&&(q=m.parseObjectValue(O["text-font"],I,"text-font",Jc(ga)),!q))return null;let X=null;if(O["text-color"]&&(X=m.parseObjectValue(O["text-color"],I,"text-color",iu),!X))return null;const Q=b[b.length-1];Q.scale=z,Q.font=q,Q.textColor=X}else{const z=m.parse(c[I],I,Ka);if(!z)return null;const q=z.type.kind;if(q!=="string"&&q!=="value"&&q!=="null"&&q!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");A=!0,b.push({content:z,scale:null,font:null,textColor:null})}}return new pp(b)}evaluate(c){return new Od(this.sections.map(m=>{const y=m.content.evaluate(c);return BN(Dl(y),N_)?new $N("",y,null,null,null):new $N(Oh(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 Cn{constructor(c,m,y,b){this._imageWarnHistory={},this.type=N_,this.namePrimary=c,this.nameSecondary=m,y&&(this.paramsPrimary=y.params,this.iconsetIdPrimary=y.iconset?y.iconset.id:void 0),b&&(this.paramsSecondary=b.params,this.iconsetIdSecondary=b.iconset?b.iconset.id:void 0)}static parse(c,m){if(c.length<2)return m.error("Expected two or more arguments.");let y=1;const b=[];function A(){if(yLa.isEqual(I,A)),b.available){const I=b.getSecondary()?b.getSecondary().id:null;I&&(b.available=c.availableImages.some(O=>La.isEqual(O,I)))}}return b}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 b in c)c[b]&&(y.params[b]=c[b].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 Cr(p){return sn(p)?"string":F0(p)?"number":qN(p)?"boolean":Array.isArray(p)?"array":p===null?"null":UN(p)?"object":typeof p}function UN(p){return p!=null&&!Array.isArray(p)&&typeof p!="function"&&!(p instanceof String||p instanceof Number||p instanceof Boolean)&&typeof p=="object"}function sn(p){return typeof p=="string"||p instanceof String}function F0(p){return typeof p=="number"||p instanceof Number}function qN(p){return typeof p=="boolean"||p instanceof Boolean}const tn={"to-boolean":ai,"to-color":iu,"to-number":Er,"to-string":ga};class fp{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],b=[];let A=bm;if(y==="to-array"){if(!Array.isArray(c[1]))return null;const I=c[1].length;if(m.expectedType){if(m.expectedType.kind!=="array")return m.error(`Expected ${m.expectedType.kind} but found array.`);A=Jc(m.expectedType.itemType,I)}else{if(!(I>0&&R0(c[1][0])))return null;A=Jc(Dl(c[1][0]),I)}for(let O=0;O4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:ty(m[0],m[1],m[2],m[3]),!y))return new Da(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new kl(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 b=Number(m);if(!isNaN(b))return b}throw new kl(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Od.fromString(Oh(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Rd.build(Oh(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(m=>m.evaluate(c)):Oh(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 pp([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Cn(this.args[0]).serialize();const c=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{c.push(m.serialize())}),c}}const _M=["Unknown","Point","LineString","Polygon"];class VN{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"?_M[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:b}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(y*m-c[0])+this.featureDistanceData.bearing[1]*(b*m-c[1])}return 0}parseColor(c){let m=this._parseColorCache[c];return m||(m=this._parseColorCache[c]=Da.parse(c)),m}getConfig(c){return this.options?this.options.get(c):null}}class Fd{constructor(c,m,y,b,A){this.name=c,this.type=m,this._evaluate=y,this.args=b,this._overloadIndex=A}evaluate(c){if(!this._evaluate){const m=Fd.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],b=Fd.definitions[y];if(!b)return m.error(`Unknown expression "${y}". If you wanted a literal array, use ["literal", [...]].`,0);const A=Array.isArray(b)?b[0]:b.type,I=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,O=[];let z=null,q=-1;for(const[X,Q]of I){if(Array.isArray(X)&&X.length!==c.length-1)continue;O.push(X),q++,z=new sS(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const se=[];let ae=!1;for(let le=1;lese)).map(HN).join(" | "),Q=[];for(let se=1;sem;){if(y-m>600){const z=y-m+1,q=c-m+1,X=Math.log(z),Q=.5*Math.exp(2*X/3),se=.5*Math.sqrt(X*Q*(z-Q)/z)*(q-z/2<0?-1:1);WN(p,c,Math.max(m,Math.floor(c-q*Q/z+se)),Math.min(y,Math.floor(c+(z-q)*Q/z+se)),b)}const A=p[c];let I=m,O=y;for(jm(p,m,c),b(p[y],A)>0&&jm(p,m,y);I0;)O--}b(p[m],A)===0?jm(p,m,O):(O++,jm(p,O,y)),O<=c&&(m=O+1),c<=O&&(y=O-1)}}function jm(p,c,m){const y=p[c];p[c]=p[m],p[m]=y}function bM(p,c){return pc?1:0}function Rg(p){let c=0;for(let m,y,b=0,A=p.length,I=A-1;b=c[2]||p[1]<=c[1]||p[3]>=c[3])}function Gle(p,c,m){const y=p[0]-c[0],b=p[1]-c[1],A=p[0]-m[0],I=p[1]-m[1];return y*I-A*b==0&&y*A<=0&&b*I<=0}function z0(p,c,m=!1){let y=!1;for(let O=0,z=c.length;O(b=p)[1]!=(I=le)[1]>b[1]&&b[0]<(I[0]-A[0])*(b[1]-A[1])/(I[1]-A[1])+A[0]&&(y=!y)}}var b,A,I;return y}function M_(p,c,m,y){const b=y[0]-m[0],A=y[1]-m[1],I=(p[0]-m[0])*A-b*(p[1]-m[1]),O=(c[0]-m[0])*A-b*(c[1]-m[1]);return I>0&&O<0||I<0&&O>0}function T_(p,c,m,y){return(b=[y[0]-m[0],y[1]-m[1]])[0]*(A=[c[0]-p[0],c[1]-p[1]])[1]-b[1]*A[0]!=0&&!(!M_(p,c,m,y)||!M_(m,y,p,c));var b,A}function ff(p){const c=new cs(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new cs(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const y of p[0])c.x>y.x&&(c.x=y.x),c.y>y.y&&(c.y=y.y),m.xm[2]){const b=.5*y;let A=p[0]-m[0]>b?-y:m[0]-p[0]>b?y:0;A===0&&(A=p[0]-m[2]>b?-y:m[2]-p[0]>b?y:0),p[0]+=A}Rh(c,p)}function bL(p,c,m,y){const b=Math.pow(2,y.z)*Fg,A=[y.x*Fg,y.y*Fg],I=[];if(!p)return I;for(const O of p)for(const z of O){const q=[z.x+A[0],z.y+A[1]];_L(q,c,m,b),I.push(q)}return I}function GN(p,c,m,y){const b=Math.pow(2,y.z)*Fg,A=[y.x*Fg,y.y*Fg],I=[];if(!p)return I;for(const z of p){const q=[];for(const X of z){const Q=[X.x+A[0],X.y+A[1]];Rh(c,Q),q.push(Q)}I.push(q)}if(c[2]-c[0]<=b/2){(O=c)[0]=O[1]=1/0,O[2]=O[3]=-1/0;for(const z of I)for(const q of z)_L(q,c,m,b)}var O;return I}class Bg{constructor(c,m){this.type=ai,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(R0(c[1])){const y=c[1];if(y.type==="FeatureCollection")for(let b=0;bm)return KN(A,I,(m-(y-O))/O)}return c[c.length-1]}pointToSegmentDistance(c,m,y){let[b,A]=m,I=eh(y[0]-b)*this.kx,O=(y[1]-A)*this.ky;if(I!==0||O!==0){const z=(eh(c[0]-b)*this.kx*I+(c[1]-A)*this.ky*O)/(I*I+O*O);z>1?(b=y[0],A=y[1]):z>0&&(b+=I/this.kx*z,A+=O/this.ky*z)}return I=eh(c[0]-b)*this.kx,O=(c[1]-A)*this.ky,Math.sqrt(I*I+O*O)}pointOnLine(c,m){let y=1/0,b=c[0][0],A=c[0][1],I=0,O=0;for(let z=0;z1?(q=c[z+1][0],X=c[z+1][1]):ae>0&&(q+=Q/this.kx*ae,X+=se/this.ky*ae)),Q=eh(m[0]-q)*this.kx,se=(m[1]-X)*this.ky;const le=Q*Q+se*se;leA.index||b.index===A.index&&b.t>A.t){const q=b;b=A,A=q}const I=[b.point],O=b.index+1,z=A.index;!kM(y[O],I[0])&&O<=z&&I.push(y[O]);for(let q=O+1;q<=z;q++)I.push(y[q]);return kM(y[z],A.point)||I.push(A.point),I}lineSliceAlong(c,m,y){let b=0;const A=[];for(let I=0;Ic&&A.length===0&&A.push(KN(O,z,(c-(b-q))/q)),b>=m)return A.push(KN(O,z,(m-(b-q))/q)),A;b>c&&A.push(z)}return A}bufferPoint(c,m){const y=m/this.ky,b=m/this.kx;return[c[0]-b,c[1]-y,c[0]+b,c[1]+y]}bufferBBox(c,m){const y=m/this.ky,b=m/this.kx;return[c[0]-b,c[1]-y,c[2]+b,c[3]+y]}insideBBox(c,m){return eh(c[0]-m[0])>=0&&eh(c[0]-m[2])<=0&&c[1]>=m[1]&&c[1]<=m[3]}}function kM(p,c){return p[0]===c[0]&&p[1]===c[1]}function KN(p,c,m){const y=eh(c[0]-p[0]);return[p[0]+y*m,p[1]+(c[1]-p[1])*m]}function eh(p){for(;p<-180;)p+=360;for(;p>180;)p-=360;return p}class ZN{constructor(c=[],m=(y,b)=>yb?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,b=m[c];for(;c>0;){const A=c-1>>1,I=m[A];if(y(b,I)>=0)break;m[c]=I,c=A}m[c]=b}_down(c){const{data:m,compare:y}=this,b=this.length>>1,A=m[c];for(;c=0)break;m[c]=m[I],c=I}m[c]=A}}var Hs=8192;function NM(p,c){return c.dist-p.dist}const YN=100,XN=50;function SM(p){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==p.length)return!1;for(let m=0;m=p[0]&&p[1]p[1])return[null,null];const m=E_(p);if(c){if(m===2)return[p,null];const y=Math.floor(m/2);return[[p[0],p[0]+y],[p[0]+y,p[1]]]}{if(m===1)return[p,null];const y=Math.floor(m/2)-1;return[[p[0],p[0]+y],[p[0]+y+1,p[1]]]}}function sy(p,c){const m=[1/0,1/0,-1/0,-1/0];if(!gp(c,p.length))return m;for(let y=c[0];y<=c[1];++y)Rh(m,p[y]);return m}function ry(p){const c=[1/0,1/0,-1/0,-1/0];for(let m=0;mc[2]&&(y=p[0]-c[2]),p[1]>c[3]&&(b=p[1]-c[3]),p[3]=y)return y;if(C_(b,A)){if(TM(p,c))return 0}else if(TM(c,p))return 0;let I=y;for(const O of p)for(let z=0,q=O.length,X=q-1;z=A)continue;const X=q.range1;if(E_(X)<=O){if(!gp(X,p.length))return NaN;if(c){const Q=Jle(p,X,m,y);if((A=Math.min(A,Q))===0)return A}else for(let Q=X[0];Q<=X[1];++Q){const se=Qle(p[Q],m,y);if((A=Math.min(A,se))===0)return A}}else{const Q=CM(X,c);if(Q[0]!==null){const se=$g(sy(p,Q[0]),z,y);se=I)continue;const Q=X.range1,se=X.range2;if(E_(Q)<=z&&E_(se)<=q){if(!gp(Q,p.length)||!gp(se,m.length))return NaN;if(c&&y?I=Math.min(I,xa(p,Q,m,se,b)):c||y?c&&!y?I=Math.min(I,MM(m,se,p,Q,b)):!c&&y&&(I=Math.min(I,MM(p,Q,m,se,b))):I=Math.min(I,Xle(p,Q,m,se,b)),I===0)return I}else{const ae=CM(Q,c),le=CM(se,y);Xi(O,I,b,p,m,ae[0],le[0]),Xi(O,I,b,p,m,ae[0],le[1]),Xi(O,I,b,p,m,ae[1],le[0]),Xi(O,I,b,p,m,ae[1],le[1])}}return I}function AM(p,c,m,y,b=1/0){let A=b;const I=sy(p,[0,p.length-1]);for(const O of m)if(!(A!==1/0&&$g(I,sy(O,[0,O.length-1]),y)>=A)&&(A=Math.min(A,NL(p,c,O,!0,y,A)),A===0))return A;return A}function eS(p,c,m,y,b=1/0){let A=b;const I=sy(p,[0,p.length-1]);for(const O of m){if(A!==1/0&&$g(I,ry(O),y)>=A)continue;const z=tce(p,c,O,y,A);if(isNaN(z))return z;if((A=Math.min(A,z))===0)return A}return A}function EM(p){return p==="Point"||p==="MultiPoint"||p==="LineString"||p==="MultiLineString"||p==="Polygon"||p==="MultiPolygon"}class ny{constructor(c,m){this.type=Er,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(R0(c[1])){const y=c[1];if(y.type==="FeatureCollection"){for(let b=0;b{c&&!U0(m)&&(c=!1)}),c}function I_(p){if(p instanceof Fd&&p.name==="feature-state")return!1;let c=!0;return p.eachChild(m=>{c&&!I_(m)&&(c=!1)}),c}function q0(p,c){if(p instanceof Fd&&c.indexOf(p.name)>=0)return!1;let m=!0;return p.eachChild(y=>{m&&!q0(y,c)&&(m=!1)}),m}function SL(p,c,m){return[p,c,m].filter(Boolean).join("")}function IM(p,c){switch(p){case"string":return Oh(c);case"number":return+c;case"boolean":return!!c;case"color":return Da.parse(c);case"formatted":return Od.fromString(Oh(c));case"resolvedImage":return Rd.build(Oh(c))}return c}function CL(p,c,m,y){return y!==void 0&&(p=y*Math.round(p/y)),c!==void 0&&pm&&(p=m),p}class V0{constructor(c,m,y,b=!1){this.type=c,this.key=m,this.scope=y,this.featureConstant=b}static parse(c,m){let y=m.expectedType;if(y==null&&(y=Ka),c.length<2||c.length>3)return m.error("Invalid number of arguments for 'config' expression.");const b=m.parse(c[1],1);if(!(b instanceof pf))return m.error("Key name of 'config' expression must be a string literal.");let A,I=!0;const O=Oh(b.value);if(c.length>=3){const z=m.parse(c[2],2);if(!(z instanceof pf))return m.error("Scope of 'config' expression must be a string literal.");A=Oh(z.value)}if(m.options){const z=SL(O,A,m._scope),q=m.options.get(z);q&&(I=U0(q.value||q.default))}return new V0(y,O,A,I)}evaluate(c){const m=SL(this.key,this.scope,c.scope),y=c.getConfig(m);if(!y)return null;const{type:b,value:A,values:I,minValue:O,maxValue:z,stepValue:q}=y,X=y.default.evaluate(c);let Q=X;if(A){const se=c.scope;c.scope=(se||"").split("").slice(1).join(""),Q=A.evaluate(c),c.scope=se}return b&&(Q=IM(b,Q)),Q===void 0||O===void 0&&z===void 0&&q===void 0||(typeof Q=="number"?Q=CL(Q,O,z,q):Array.isArray(Q)&&(Q=Q.map(se=>typeof se=="number"?CL(se,O,z,q):se))),A!==void 0&&Q!==void 0&&I&&!I.includes(Q)&&(Q=X,b&&(Q=IM(b,Q))),(b&&b!==this.type||Q!==void 0&&!BN(Dl(Q),this.type))&&(Q=IM(this.type.kind,Q)),Q}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 sS{constructor(c,m=[],y,b=new O0,A=[],I,O,z){this.registry=c,this.path=m,this.key=m.map(q=>typeof q=="string"?`['${q}']`:`[${q}]`).join(""),this.scope=b,this.errors=A,this.expectedType=y,this._scope=I,this.options=O,this.iconImageUseTheme=z}parse(c,m,y,b,A={}){return m||y?this.concat(m,null,y,b)._parse(c,A):this._parse(c,A)}parseObjectValue(c,m,y,b,A,I={}){return this.concat(m,y,b,A)._parse(c,I)}_parse(c,m){function y(b,A,I){return I==="assert"?new wm(A,[b]):I==="coerce"?new fp(A,[b]):b}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 b=typeof c[0]=="string"?this.registry[c[0]]:void 0;if(b){let A=b.parse(c,this);if(!A)return null;if(this.expectedType){const I=this.expectedType,O=A.type;if(I.kind!=="string"&&I.kind!=="number"&&I.kind!=="boolean"&&I.kind!=="object"&&I.kind!=="array"||O.kind!=="value")if(I.kind!=="color"&&I.kind!=="formatted"&&I.kind!=="resolvedImage"||O.kind!=="value"&&O.kind!=="string"){if(this.checkSubtype(I,O))return null}else A=y(A,I,m.typeAnnotation||"coerce");else A=y(A,I,m.typeAnnotation||"assert")}if(!(A instanceof pf)&&A.type.kind!=="resolvedImage"&&PM(A)){const I=new VN(this._scope,this.options,this.iconImageUseTheme);try{A=new pf(A.type,A.evaluate(I))}catch(O){return this.error(O.message),null}}return A}return fp.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,b){let A=typeof c=="number"?this.path.concat(c):this.path;A=typeof m=="string"?A.concat(m):A;const I=b?this.scope.concat(b):this.scope;return new sS(this.registry,A,y||null,I,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(c,...m){const y=`${this.key}${m.map(b=>`[${b}]`).join("")}`;this.errors.push(new Dh(y,c))}checkSubtype(c,m){const y=Og(c,m);return y&&this.error(y),y}}function PM(p){if(p instanceof tS)return PM(p.boundExpression);if(p instanceof Fd&&p.name==="error"||p instanceof Xl||p instanceof Bg||p instanceof ny||p instanceof V0)return!1;const c=p instanceof fp||p instanceof wm;let m=!0;return p.eachChild(y=>{m=c?m&&PM(y):m&&y instanceof pf}),!!m&&U0(p)&&q0(p,["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 rS(p,c){const m=p.length-1;let y,b,A=0,I=m,O=0;for(;A<=I;)if(O=Math.floor((A+I)/2),y=p[O],b=p[O+1],y<=c){if(O===m||cc))throw new kl("Input is not a number.");I=O-1}return 0}class P_{constructor(c,m,y){this.type=c,this.input=m,this.labels=[],this.outputs=[];for(const[b,A]of y)this.labels.push(b),this.outputs.push(A)}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,Er);if(!y)return null;const b=[];let A=null;m.expectedType&&m.expectedType.kind!=="value"&&(A=m.expectedType);for(let I=1;I=O)return m.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',q);const Q=m.parse(z,X,A);if(!Q)return null;A=A||Q.type,b.push([O,Q])}return new P_(A,y,b)}evaluate(c){const m=this.labels,y=this.outputs;if(m.length===1)return y[0].evaluate(c);const b=this.input.evaluate(c);if(b<=m[0])return y[0].evaluate(c);const A=m.length;return b>=m[A-1]?y[A-1].evaluate(c):y[rS(m,b)].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 ML=.95047,TL=1.08883,AL=4/29,H0=6/29,EL=3*H0*H0,sce=H0*H0*H0,rce=Math.PI/180,nce=180/Math.PI;function LM(p){return p>sce?Math.pow(p,1/3):p/EL+AL}function DM(p){return p>H0?p*p*p:EL*(p-AL)}function OM(p){return 255*(p<=.0031308?12.92*p:1.055*Math.pow(p,1/2.4)-.055)}function RM(p){return(p/=255)<=.04045?p/12.92:Math.pow((p+.055)/1.055,2.4)}function IL(p){const c=RM(p.r),m=RM(p.g),y=RM(p.b),b=LM((.4124564*c+.3575761*m+.1804375*y)/ML),A=LM((.2126729*c+.7151522*m+.072175*y)/1);return{l:116*A-16,a:500*(b-A),b:200*(A-LM((.0193339*c+.119192*m+.9503041*y)/TL)),alpha:p.a}}function nS(p){let c=(p.l+16)/116,m=isNaN(p.a)?c:c+p.a/500,y=isNaN(p.b)?c:c-p.b/200;return c=1*DM(c),m=ML*DM(m),y=TL*DM(y),new Da(OM(3.2404542*m-1.5371385*c-.4985314*y),OM(-.969266*m+1.8760108*c+.041556*y),OM(.0556434*m-.2040259*c+1.0572252*y),p.alpha)}function aS(p,c,m){const y=c-p;return p+m*(y>180||y<-180?y-360*Math.round(y/360):y)}const W0={forward:IL,reverse:nS,interpolate:function(p,c,m){return{l:Jr(p.l,c.l,m),a:Jr(p.a,c.a,m),b:Jr(p.b,c.b,m),alpha:Jr(p.alpha,c.alpha,m)}}},L_={forward:function(p){const{l:c,a:m,b:y}=IL(p),b=Math.atan2(y,m)*nce;return{h:b<0?b+360:b,c:Math.sqrt(m*m+y*y),l:c,alpha:p.a}},reverse:function(p){const c=p.h*rce,m=p.c;return nS({l:p.l,a:Math.cos(c)*m,b:Math.sin(c)*m,alpha:p.alpha})},interpolate:function(p,c,m){return{h:aS(p.h,c.h,m),c:Jr(p.c,c.c,m),l:Jr(p.l,c.l,m),alpha:Jr(p.alpha,c.alpha,m)}}};var PL=Object.freeze({__proto__:null,hcl:L_,lab:W0});class th{constructor(c,m,y,b,A){this.type=c,this.operator=m,this.interpolation=y,this.input=b,this.labels=[],this.outputs=[];for(const[I,O]of A)this.labels.push(I),this.outputs.push(O)}static interpolationFactor(c,m,y,b){let A=0;if(c.name==="exponential")A=iS(m,c.base,y,b);else if(c.name==="linear")A=iS(m,1,y,b);else if(c.name==="cubic-bezier"){const I=c.controlPoints;A=new on(I[0],I[1],I[2],I[3]).solve(iS(m,1,y,b))}return A}static parse(c,m){let[y,b,A,...I]=c;if(!Array.isArray(b)||b.length===0)return m.error("Expected an interpolation type expression.",1);if(b[0]==="linear")b={name:"linear"};else if(b[0]==="exponential"){const q=b[1];if(typeof q!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:q}}else{if(b[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const q=b.slice(1);if(q.length!==4||q.some(X=>typeof X!="number"||X<0||X>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:q}}}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(A=m.parse(A,2,Er),!A)return null;const O=[];let z=null;y==="interpolate-hcl"||y==="interpolate-lab"?z=iu:m.expectedType&&m.expectedType.kind!=="value"&&(z=m.expectedType);for(let q=0;q=X)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',se);const le=m.parse(Q,ae,z);if(!le)return null;z=z||le.type,O.push([X,le])}return z.kind==="number"||z.kind==="color"||z.kind==="array"&&z.itemType.kind==="number"&&typeof z.N=="number"?new th(z,y,b,A,O):m.error(`Type ${Ko(z)} is not interpolatable.`)}evaluate(c){const m=this.labels,y=this.outputs;if(m.length===1)return y[0].evaluate(c);const b=this.input.evaluate(c);if(b<=m[0])return y[0].evaluate(c);const A=m.length;if(b>=m[A-1])return y[A-1].evaluate(c);const I=rS(m,b),O=th.interpolationFactor(this.interpolation,b,m[I],m[I+1]),z=y[I].evaluate(c),q=y[I+1].evaluate(c);return this.operator==="interpolate"?j_[this.type.kind.toLowerCase()](z,q,O):this.operator==="interpolate-hcl"?L_.reverse(L_.interpolate(L_.forward(z),L_.forward(q),O)):W0.reverse(W0.interpolate(W0.forward(z),W0.forward(q),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;yOg(b,O.type));return new D_(I?Ka:y,A)}evaluate(c){let m,y=null,b=0;for(const A of this.args){if(b++,y=A.evaluate(c),y&&y instanceof Rd&&!y.available&&(m||(m=y),y=null,b===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 gf{constructor(c,m){this.type=m.type,this.bindings=[].concat(c),this.result=m}evaluate(c){return this.result.evaluate(c)}eachChild(c){for(const m of this.bindings)c(m[1]);c(this.result)}static parse(c,m){if(c.length<4)return m.error(`Expected at least 3 arguments, but found ${c.length-1} instead.`);const y=[];for(let A=1;A=y.length)throw new kl("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new kl("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 lS{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,Er),b=m.parse(c[2],2,Jc(m.expectedType||Ka));return y&&b?new lS(b.type.itemType,y,b):null}evaluate(c){const m=this.index.evaluate(c),y=this.input.evaluate(c);if(m<0)throw new kl(`Array index out of bounds: ${m} < 0.`);if(m>y.length-1)throw new kl(`Array index out of bounds: ${m} > ${y.length-1}.`);if(m===Math.floor(m))return y[m];const b=Math.floor(m),A=Math.ceil(m),I=y[b],O=y[A];if(typeof I!="number"||typeof O!="number")throw new kl(`Cannot interpolate between non-number values at index ${m}.`);const z=m-b;return I*(1-z)+O*z}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class FM{constructor(c,m){this.type=ai,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,Ka),b=m.parse(c[2],2,Ka);return y&&b?xM(y.type,[ai,ga,Er,bm,Ka])?new FM(y,b):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ko(y.type)} instead`):null}evaluate(c){const m=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(y==null)return!1;if(!S_(m,["boolean","string","number","null"]))throw new kl(`Expected first argument to be of type boolean, string, number or null, but found ${Ko(Dl(m))} instead.`);if(!S_(y,["string","array"]))throw new kl(`Expected second argument to be of type array or string, but found ${Ko(Dl(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 G0{constructor(c,m,y){this.type=Er,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,Ka),b=m.parse(c[2],2,Ka);if(!y||!b)return null;if(!xM(y.type,[ai,ga,Er,bm,Ka]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ko(y.type)} instead`);if(c.length===4){const A=m.parse(c[3],3,Er);return A?new G0(y,b,A):null}return new G0(y,b)}evaluate(c){const m=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(!S_(m,["boolean","string","number","null"]))throw new kl(`Expected first argument to be of type boolean, string, number or null, but found ${Ko(Dl(m))} instead.`);if(!S_(y,["string","array"]))throw new kl(`Expected second argument to be of type array or string, but found ${Ko(Dl(y))} instead.`);if(this.fromIndex){const b=this.fromIndex.evaluate(c);return y.indexOf(m,b)}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 O_{constructor(c,m,y,b,A,I){this.inputType=c,this.type=m,this.input=y,this.cases=b,this.outputs=A,this.otherwise=I}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,b;m.expectedType&&m.expectedType.kind!=="value"&&(b=m.expectedType);const A={},I=[];for(let q=2;qNumber.MAX_SAFE_INTEGER)return se.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof le=="number"&&Math.floor(le)!==le)return se.error("Numeric branch labels must be integer values.");if(y){if(se.checkSubtype(y,Dl(le)))return null}else y=Dl(le);if(A[String(le)]!==void 0)return se.error("Branch labels must be unique.");A[String(le)]=I.length}const ae=m.parse(Q,q,b);if(!ae)return null;b=b||ae.type,I.push(ae)}const O=m.parse(c[1],1,Ka);if(!O)return null;const z=m.parse(c[c.length-1],c.length-1,b);return z?O.type.kind!=="value"&&m.concat(1).checkSubtype(y,O.type)?null:new O_(y,b,O,A,I,z):null}evaluate(c){const m=this.input.evaluate(c);return(BN(Dl(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=[],b={};for(const I of m){const O=b[this.cases[I]];O===void 0?(b[this.cases[I]]=y.length,y.push([this.cases[I],[I]])):y[O][1].push(I)}const A=I=>this.inputType.kind==="number"?Number(I):I;for(const[I,O]of y)c.push(O.length===1?A(O[0]):O.map(A)),c.push(this.outputs[I].serialize());return c.push(this.otherwise.serialize()),c}}class R_{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 b=[];for(let I=1;Im.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["case"];return this.eachChild(m=>{c.push(m.serialize())}),c}}class cS{constructor(c,m,y,b){this.type=c,this.input=m,this.beginIndex=y,this.endIndex=b}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,Ka),b=m.parse(c[2],2,Er);if(!y||!b)return null;if(!xM(y.type,[Jc(Ka),ga,Ka]))return m.error(`Expected first argument to be of type array or string, but found ${Ko(y.type)} instead`);if(c.length===4){const A=m.parse(c[3],3,Er);return A?new cS(y.type,y,b,A):null}return new cS(y.type,y,b)}evaluate(c){const m=this.input.evaluate(c),y=this.beginIndex.evaluate(c);if(!S_(m,["string","array"]))throw new kl(`Expected first argument to be of type array or string, but found ${Ko(Dl(m))} instead.`);if(this.endIndex){const b=this.endIndex.evaluate(c);return m.slice(y,b)}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 zM{constructor(c,m){this.type=Jc(ga),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,ga),b=m.parse(c[2],2,ga);return y&&b?new zM(y,b):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 BM(p,c){return p==="=="||p==="!="?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 $M(p,c,m,y){return y.compare(c,m)===0}function K0(p,c,m){const y=p!=="=="&&p!=="!=";return class zze{constructor(A,I,O){this.type=ai,this.lhs=A,this.rhs=I,this.collator=O,this.hasUntypedArgument=A.type.kind==="value"||I.type.kind==="value"}static parse(A,I){if(A.length!==3&&A.length!==4)return I.error("Expected two or three arguments.");const O=A[0];let z=I.parse(A[1],1,Ka);if(!z)return null;if(!BM(O,z.type))return I.concat(1).error(`"${O}" comparisons are not supported for type '${Ko(z.type)}'.`);let q=I.parse(A[2],2,Ka);if(!q)return null;if(!BM(O,q.type))return I.concat(2).error(`"${O}" comparisons are not supported for type '${Ko(q.type)}'.`);if(z.type.kind!==q.type.kind&&z.type.kind!=="value"&&q.type.kind!=="value")return I.error(`Cannot compare types '${Ko(z.type)}' and '${Ko(q.type)}'.`);y&&(z.type.kind==="value"&&q.type.kind!=="value"?z=new wm(q.type,[z]):z.type.kind!=="value"&&q.type.kind==="value"&&(q=new wm(z.type,[q])));let X=null;if(A.length===4){if(z.type.kind!=="string"&&q.type.kind!=="string"&&z.type.kind!=="value"&&q.type.kind!=="value")return I.error("Cannot use collator to compare non-string types.");if(X=I.parse(A[3],3,zN),!X)return null}return new zze(z,q,X)}evaluate(A){const I=this.lhs.evaluate(A),O=this.rhs.evaluate(A);if(y&&this.hasUntypedArgument){const z=Dl(I),q=Dl(O);if(z.kind!==q.kind||z.kind!=="string"&&z.kind!=="number")throw new kl(`Expected arguments for "${p}" to be (string, string) or (number, number), but found (${z.kind}, ${q.kind}) instead.`)}if(this.collator&&!y&&this.hasUntypedArgument){const z=Dl(I),q=Dl(O);if(z.kind!=="string"||q.kind!=="string")return c(A,I,O)}return this.collator?m(A,I,O,this.collator.evaluate(A)):c(A,I,O)}eachChild(A){A(this.lhs),A(this.rhs),this.collator&&A(this.collator)}outputDefined(){return!0}serialize(){const A=[p];return this.eachChild(I=>{A.push(I.serialize())}),A}}}const ace=K0("==",function(p,c,m){return c===m},$M),ice=K0("!=",function(p,c,m){return c!==m},function(p,c,m,y){return!$M(0,c,m,y)}),LL=K0("<",function(p,c,m){return c",function(p,c,m){return c>m},function(p,c,m,y){return y.compare(c,m)>0}),dS=K0("<=",function(p,c,m){return c<=m},function(p,c,m,y){return y.compare(c,m)<=0}),oce=K0(">=",function(p,c,m){return c>=m},function(p,c,m,y){return y.compare(c,m)>=0});class uS{constructor(c,m,y,b,A,I){this.type=ga,this.number=c,this.locale=m,this.currency=y,this.unit=b,this.minFractionDigits=A,this.maxFractionDigits=I}static parse(c,m){if(c.length!==3)return m.error("Expected two arguments.");const y=m.parse(c[1],1,Er);if(!y)return null;const b=c[2];if(typeof b!="object"||Array.isArray(b))return m.error("NumberFormat options argument must be an object.");let A=null;if(b.locale&&(A=m.parseObjectValue(b.locale,2,"locale",ga),!A))return null;let I=null;if(b.currency&&(I=m.parseObjectValue(b.currency,2,"currency",ga),!I))return null;let O=null;if(b.unit&&(O=m.parseObjectValue(b.unit,2,"unit",ga),!O))return null;let z=null;if(b["min-fraction-digits"]&&(z=m.parseObjectValue(b["min-fraction-digits"],2,"min-fraction-digits",Er),!z))return null;let q=null;return b["max-fraction-digits"]&&(q=m.parseObjectValue(b["max-fraction-digits"],2,"max-fraction-digits",Er),!q)?null:new uS(y,A,I,O,z,q)}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 UM{constructor(c){this.type=Er,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 ${Ko(y.type)} instead.`):new UM(y):null}evaluate(c){const m=this.input.evaluate(c);if(typeof m=="string"||Array.isArray(m))return m.length;throw new kl(`Expected value to be of type string or array, but found ${Ko(Dl(m))} instead.`)}eachChild(c){c(this.input)}outputDefined(){return!1}serialize(){const c=["length"];return this.eachChild(m=>{c.push(m.serialize())}),c}}function OL(p){return function(){p=1831565813+(p|=0)|0;let c=Math.imul(p^p>>>15,1|p);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const Z0={"==":ace,"!=":ice,">":DL,"<":LL,">=":oce,"<=":dS,array:wm,at:oS,"at-interpolated":lS,boolean:wm,case:R_,coalesce:D_,collator:Xl,format:pp,image:Cn,in:FM,"index-of":G0,interpolate:th,"interpolate-hcl":th,"interpolate-lab":th,length:UM,let:gf,literal:pf,match:O_,number:wm,"number-format":uS,object:wm,slice:cS,step:P_,string:wm,"to-boolean":fp,"to-color":fp,"to-number":fp,"to-string":fp,var:tS,within:Bg,distance:ny,config:V0,split:zM};function qM(p,[c,m,y,b]){c=c.evaluate(p),m=m.evaluate(p),y=y.evaluate(p);const A=b?b.evaluate(p):1,I=ty(c,m,y,A);if(I)throw new kl(I);return new Da(c/255,m/255,y/255,A)}function VM(p,[c,m,y,b]){c=c.evaluate(p),m=m.evaluate(p),y=y.evaluate(p);const A=b?b.evaluate(p):1,I=function(q,X,Q,se){return typeof q=="number"&&q>=0&&q<=360?typeof X=="number"&&X>=0&&X<=100&&typeof Q=="number"&&Q>=0&&Q<=100?se===void 0||typeof se=="number"&&se>=0&&se<=1?null:`Invalid hsla value [${[q,X,Q,se].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof se=="number"?[q,X,Q,se]:[q,X,Q]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof se=="number"?[q,X,Q,se]:[q,X,Q]).join(", ")}]: 'h' must be between 0 and 360.`}(c,m,y,A);if(I)throw new kl(I);const O=`hsla(${c}, ${m}%, ${y}%, ${A})`,z=Da.parse(O);if(!z)throw new kl(`Failed to parse HSLA color: ${O}`);return z}function RL(p,c){return p in c}function HM(p,c){const m=c[p];return m===void 0?null:m}function qg(p){return{type:p}}function ay(p){if(p instanceof V0)return new Set([p.key]);let c=new Set;return p.eachChild(m=>{c=new Set([...c,...ay(m)])}),c}function hS(p){if(p instanceof Fd&&p.name==="is-active-floor")return!0;let c=!1;return p.eachChild(m=>{!c&&hS(m)&&(c=!0)}),c}function FL(p){return{result:"success",value:p}}function Vg(p){return{result:"error",value:p}}function WM(p,c){return!!p&&!!p.parameters&&p.parameters.indexOf(c)>-1}function F_(p){return p["property-type"]==="data-driven"}function zL(p){return WM(p.expression,"measure-light")}function BL(p){return WM(p.expression,"zoom")}function mS(p){return!!p.expression&&p.expression.interpolated}function pS(p){return typeof p=="object"&&p!==null&&!Array.isArray(p)}function $L(p){return p}function UL(p,c){const m=c.type==="color",y=p.stops&&typeof p.stops[0][0]=="object",b=y||!(y||p.property!==void 0),A=p.type||(mS(c)?"exponential":"interval");if(m&&((p=Object.assign({},p)).stops&&(p.stops=p.stops.map(q=>[q[0],Da.parse(q[1])])),p.default=Da.parse(p.default?p.default:c.default)),p.colorSpace&&p.colorSpace!=="rgb"&&!PL[p.colorSpace])throw new Error(`Unknown color space: ${p.colorSpace}`);let I,O,z;if(A==="exponential")I=qL;else if(A==="interval")I=cce;else if(A==="categorical"){I=lce,O=Object.create(null);for(const q of p.stops)O[q[0]]=q[1];z=typeof p.stops[0][0]}else{if(A!=="identity")throw new Error(`Unknown function type "${A}"`);I=VL}if(y){const q={},X=[];for(let ae=0;aeae[0]),evaluate:({zoom:ae},le)=>qL({stops:Q,base:p.base},c,ae).evaluate(ae,le)}}if(b){const q=A==="exponential"?{name:"exponential",base:p.base!==void 0?p.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:th.interpolationFactor.bind(void 0,q),zoomStops:p.stops.map(X=>X[0]),evaluate:({zoom:X})=>I(p,c,X,O,z)}}return{kind:"source",evaluate(q,X){const Q=X&&X.properties?X.properties[p.property]:void 0;return Q===void 0?xp(p.default,c.default):I(p,c,Q,O,z)}}}function xp(p,c,m){return p!==void 0?p:c!==void 0?c:m!==void 0?m:void 0}function lce(p,c,m,y,b){return xp(typeof m===b?y[m]:void 0,p.default,c.default)}function cce(p,c,m){if(!F0(m))return xp(p.default,c.default);const y=p.stops.length;if(y===1||m<=p.stops[0][0])return p.stops[0][1];if(m>=p.stops[y-1][0])return p.stops[y-1][1];const b=rS(p.stops.map(A=>A[0]),m);return p.stops[b][1]}function qL(p,c,m){const y=p.base!==void 0?p.base:1;if(!F0(m))return xp(p.default,c.default);const b=p.stops.length;if(b===1||m<=p.stops[0][0])return p.stops[0][1];if(m>=p.stops[b-1][0])return p.stops[b-1][1];const A=rS(p.stops.map(X=>X[0]),m),I=function(X,Q,se,ae){const le=ae-se,xe=X-se;return le===0?0:Q===1?xe/le:(Math.pow(Q,xe)-1)/(Math.pow(Q,le)-1)}(m,y,p.stops[A][0],p.stops[A+1][0]),O=p.stops[A][1],z=p.stops[A+1][1];let q=j_[c.type]||$L;if(p.colorSpace&&p.colorSpace!=="rgb"){const X=PL[p.colorSpace];q=(Q,se)=>X.reverse(X.interpolate(X.forward(Q),X.forward(se),I))}return typeof O.evaluate=="function"?{evaluate(...X){const Q=O.evaluate.apply(void 0,X),se=z.evaluate.apply(void 0,X);if(Q!==void 0&&se!==void 0)return q(Q,se,I)}}:q(O,z,I)}function VL(p,c,m){return c.type==="color"?m=Da.parse(m):c.type==="formatted"?m=Od.fromString(m.toString()):c.type==="resolvedImage"?m=Rd.build(m.toString()):Cr(m)===c.type||c.type==="enum"&&c.values[m]||(m=void 0),xp(m,p.default,c.default)}Fd.register(Z0,{error:[{kind:"error"},[ga],(p,[c])=>{throw new kl(c.evaluate(p))}],typeof:[ga,[Ka],(p,[c])=>Ko(Dl(c.evaluate(p)))],"to-rgba":[Jc(Er,4),[iu],(p,[c])=>c.evaluate(p).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Jc(Er,4),[iu],(p,[c])=>c.evaluate(p).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[iu,[Er,Er,Er],qM],rgba:[iu,[Er,Er,Er,Er],qM],hsl:[iu,[Er,Er,Er],VM],hsla:[iu,[Er,Er,Er,Er],VM],has:{type:ai,overloads:[[[ga],(p,[c])=>RL(c.evaluate(p),p.properties())],[[ga,mp],(p,[c,m])=>RL(c.evaluate(p),m.evaluate(p))]]},get:{type:Ka,overloads:[[[ga],(p,[c])=>HM(c.evaluate(p),p.properties())],[[ga,mp],(p,[c,m])=>HM(c.evaluate(p),m.evaluate(p))]]},"feature-state":[Ka,[ga],(p,[c])=>HM(c.evaluate(p),p.featureState||{})],properties:[mp,[],p=>p.properties()],"geometry-type":[ga,[],p=>p.geometryType()],worldview:[ga,[],p=>p.globals.worldview||""],"is-active-floor":[ai,qg(ga),(p,c)=>{if(!(p.globals.activeFloors&&p.globals.activeFloors.size>0))return!1;const m=p.globals.activeFloors;return c.some(y=>{const b=y.evaluate(p);return m.has(b)})}],id:[Ka,[],p=>p.id()],zoom:[Er,[],p=>p.globals.zoom],pitch:[Er,[],p=>p.globals.pitch||0],"distance-from-center":[Er,[],p=>p.distanceFromCenter()],"measure-light":[Er,[ga],(p,[c])=>p.measureLight(c.evaluate(p))],"heatmap-density":[Er,[],p=>p.globals.heatmapDensity||0],"line-progress":[Er,[],p=>p.globals.lineProgress||0],"raster-value":[Er,[],p=>p.globals.rasterValue||0],"raster-particle-speed":[Er,[],p=>p.globals.rasterParticleSpeed||0],"sky-radial-progress":[Er,[],p=>p.globals.skyRadialProgress||0],accumulated:[Ka,[],p=>p.globals.accumulated===void 0?null:p.globals.accumulated],"+":[Er,qg(Er),(p,c)=>{let m=0;for(const y of c)m+=y.evaluate(p);return m}],"*":[Er,qg(Er),(p,c)=>{let m=1;for(const y of c)m*=y.evaluate(p);return m}],"-":{type:Er,overloads:[[[Er,Er],(p,[c,m])=>c.evaluate(p)-m.evaluate(p)],[[Er],(p,[c])=>-c.evaluate(p)]]},"/":[Er,[Er,Er],(p,[c,m])=>c.evaluate(p)/m.evaluate(p)],"%":[Er,[Er,Er],(p,[c,m])=>c.evaluate(p)%m.evaluate(p)],ln2:[Er,[],()=>Math.LN2],pi:[Er,[],()=>Math.PI],e:[Er,[],()=>Math.E],"^":[Er,[Er,Er],(p,[c,m])=>Math.pow(c.evaluate(p),m.evaluate(p))],sqrt:[Er,[Er],(p,[c])=>Math.sqrt(c.evaluate(p))],log10:[Er,[Er],(p,[c])=>Math.log(c.evaluate(p))/Math.LN10],ln:[Er,[Er],(p,[c])=>Math.log(c.evaluate(p))],log2:[Er,[Er],(p,[c])=>Math.log2(c.evaluate(p))],sin:[Er,[Er],(p,[c])=>Math.sin(c.evaluate(p))],cos:[Er,[Er],(p,[c])=>Math.cos(c.evaluate(p))],tan:[Er,[Er],(p,[c])=>Math.tan(c.evaluate(p))],asin:[Er,[Er],(p,[c])=>Math.asin(c.evaluate(p))],acos:[Er,[Er],(p,[c])=>Math.acos(c.evaluate(p))],atan:[Er,[Er],(p,[c])=>Math.atan(c.evaluate(p))],min:[Er,qg(Er),(p,c)=>Math.min(...c.map(m=>m.evaluate(p)))],max:[Er,qg(Er),(p,c)=>Math.max(...c.map(m=>m.evaluate(p)))],abs:[Er,[Er],(p,[c])=>Math.abs(c.evaluate(p))],round:[Er,[Er],(p,[c])=>{const m=c.evaluate(p);return m<0?-Math.round(-m):Math.round(m)}],floor:[Er,[Er],(p,[c])=>Math.floor(c.evaluate(p))],ceil:[Er,[Er],(p,[c])=>Math.ceil(c.evaluate(p))],"filter-==":[ai,[ga,Ka],(p,[c,m])=>p.properties()[c.value]===m.value],"filter-id-==":[ai,[Ka],(p,[c])=>p.id()===c.value],"filter-type-==":[ai,[ga],(p,[c])=>p.geometryType()===c.value],"filter-<":[ai,[ga,Ka],(p,[c,m])=>{const y=p.properties()[c.value],b=m.value;return typeof y==typeof b&&y{const m=p.id(),y=c.value;return typeof m==typeof y&&m":[ai,[ga,Ka],(p,[c,m])=>{const y=p.properties()[c.value],b=m.value;return typeof y==typeof b&&y>b}],"filter-id->":[ai,[Ka],(p,[c])=>{const m=p.id(),y=c.value;return typeof m==typeof y&&m>y}],"filter-<=":[ai,[ga,Ka],(p,[c,m])=>{const y=p.properties()[c.value],b=m.value;return typeof y==typeof b&&y<=b}],"filter-id-<=":[ai,[Ka],(p,[c])=>{const m=p.id(),y=c.value;return typeof m==typeof y&&m<=y}],"filter->=":[ai,[ga,Ka],(p,[c,m])=>{const y=p.properties()[c.value],b=m.value;return typeof y==typeof b&&y>=b}],"filter-id->=":[ai,[Ka],(p,[c])=>{const m=p.id(),y=c.value;return typeof m==typeof y&&m>=y}],"filter-has":[ai,[Ka],(p,[c])=>c.value in p.properties()],"filter-has-id":[ai,[],p=>p.id()!==null&&p.id()!==void 0],"filter-type-in":[ai,[Jc(ga)],(p,[c])=>c.value.indexOf(p.geometryType())>=0],"filter-id-in":[ai,[Jc(Ka)],(p,[c])=>c.value.indexOf(p.id())>=0],"filter-in-small":[ai,[ga,Jc(Ka)],(p,[c,m])=>m.value.indexOf(p.properties()[c.value])>=0],"filter-in-large":[ai,[ga,Jc(Ka)],(p,[c,m])=>function(y,b,A,I){for(;A<=I;){const O=A+I>>1;if(b[O]===y)return!0;b[O]>y?I=O-1:A=O+1}return!1}(p.properties()[c.value],m.value,0,m.value.length-1)],all:{type:ai,overloads:[[[ai,ai],(p,[c,m])=>c.evaluate(p)&&m.evaluate(p)],[qg(ai),(p,c)=>{for(const m of c)if(!m.evaluate(p))return!1;return!0}]]},any:{type:ai,overloads:[[[ai,ai],(p,[c,m])=>c.evaluate(p)||m.evaluate(p)],[qg(ai),(p,c)=>{for(const m of c)if(m.evaluate(p))return!0;return!1}]]},"!":[ai,[ai],(p,[c])=>!c.evaluate(p)],"is-supported-script":[ai,[ga],(p,[c])=>{const m=p.globals&&p.globals.isSupportedScript;return!m||m(c.evaluate(p))}],upcase:[ga,[ga],(p,[c])=>c.evaluate(p).toUpperCase()],downcase:[ga,[ga],(p,[c])=>c.evaluate(p).toLowerCase()],concat:[ga,qg(Ka),(p,c)=>c.map(m=>Oh(m.evaluate(p))).join("")],"resolved-locale":[ga,[zN],(p,[c])=>c.evaluate(p).resolvedLocale()],random:[Er,[Er,Er,Ka],(p,c)=>{const[m,y,b]=c.map(I=>I.evaluate(p));if(m>y||m===y)return m;let A;if(typeof b=="string")A=function(I){let O=0;if(I.length===0)return O;for(let z=0;zJSON.stringify(Q)).join(", ")}, but found ${JSON.stringify(X)} instead.`);return X}catch(X){const Q=X;return this._warningHistory[Q.message]||(this._warningHistory[Q.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${Q.message}`)),this._defaultValue}}}function z_(p){return Array.isArray(p)&&p.length>0&&typeof p[0]=="string"&&p[0]in Z0}function Hg(p,c,m,y,b){const A=new sS(Z0,[],c?function(O){const z={color:iu,string:ga,number:Er,enum:ga,boolean:ai,formatted:k_,resolvedImage:N_};return O.type==="array"?Jc(z[O.value]||Ka,O.length):z[O.type]}(c):void 0,void 0,void 0,m,y,b),I=A.parse(p,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return I?FL(new fS(I,c,m,y,b)):Vg(A.errors)}class Y0{constructor(c,m,y,b){this.kind=c,this._styleExpression=m,this.isLightConstant=y,this.isLineProgressConstant=b,this.isStateDependent=c!=="constant"&&!I_(m.expression),this.configDependencies=ay(m.expression),this.isIndoorDependent=hS(m.expression)}evaluateWithoutErrorHandling(c,m,y,b,A,I){return this._styleExpression.evaluateWithoutErrorHandling(c,m,y,b,A,I)}evaluate(c,m,y,b,A,I,O){return this._styleExpression.evaluate(c,m,y,b,A,I,void 0,void 0,O)}}class iy{constructor(c,m,y,b,A,I){this.kind=c,this.zoomStops=y,this._styleExpression=m,this.isStateDependent=c!=="camera"&&!I_(m.expression),this.isIndoorDependent=hS(m.expression),this.isLightConstant=A,this.isLineProgressConstant=I,this.configDependencies=ay(m.expression),this.interpolationType=b}evaluateWithoutErrorHandling(c,m,y,b,A,I){return this._styleExpression.evaluateWithoutErrorHandling(c,m,y,b,A,I)}evaluate(c,m,y,b,A,I){return this._styleExpression.evaluate(c,m,y,b,A,I)}interpolationFactor(c,m,y){return this.interpolationType?th.interpolationFactor(this.interpolationType,c,m,y):0}}function GM(p,c,m,y,b){if((p=Hg(p,c,m,y,b)).result==="error")return p;const A=p.value.expression,I=U0(A);if(!I&&!F_(c))return Vg([new Dh("","data expressions not supported")]);const O=q0(A,["zoom","pitch","distance-from-center"]);if(!O&&!BL(c))return Vg([new Dh("","zoom expressions not supported")]);const z=q0(A,["measure-light"]);if(!z&&!zL(c))return Vg([new Dh("","measure-light expression not supported")]);const q=q0(A,["line-progress"]);if(!q&&!function(se){return WM(se.expression,"line-progress")}(c))return Vg([new Dh("","line-progress expression not supported")]);const X=c.expression&&c.expression.relaxZoomRestriction,Q=km(A);return Q||O||X?Q instanceof Dh?Vg([Q]):Q instanceof th&&!mS(c)?Vg([new Dh("",'"interpolate" expressions cannot be used with this property')]):FL(Q?new iy(I&&q?"camera":"composite",p.value,Q.labels,Q instanceof th?Q.interpolation:void 0,z,q):new Y0(I&&q?"constant":"source",p.value,z,q)):Vg([new Dh("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class gS{constructor(c,m){this._parameters=c,this._specification=m,Object.assign(this,UL(this._parameters,this._specification))}static deserialize(c){return new gS(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function km(p){let c=null;if(p instanceof gf)c=km(p.result);else if(p instanceof D_){for(const m of p.args)if(c=km(m),c)break}else(p instanceof P_||p instanceof th)&&p.input instanceof Fd&&p.input.name==="zoom"&&(c=p);return c instanceof Dh||p.eachChild(m=>{const y=km(m);y instanceof Dh?c=y:c&&y&&c!==y&&(c=new Dh("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var KM,HL,WL=function(){if(HL)return KM;HL=1,KM=c;var p=3;function c(m,y,b){var A=this.cells=[];if(m instanceof ArrayBuffer){this.arrayBuffer=m;var I=new Int32Array(this.arrayBuffer);m=I[0],this.d=(y=I[1])+2*(b=I[2]);for(var O=0;O=se[xe+0]&&A>=se[xe+1])?(z[le]=!0,O.push(Q[le])):z[le]=!1}}},c.prototype._forEachCell=function(m,y,b,A,I,O,z,q){for(var X=this._convertToCellCoord(m),Q=this._convertToCellCoord(y),se=this._convertToCellCoord(b),ae=this._convertToCellCoord(A),le=X;le<=se;le++)for(var xe=Q;xe<=ae;xe++){var Me=this.d*xe+le;if((!q||q(this._convertFromCellCoord(le),this._convertFromCellCoord(xe),this._convertFromCellCoord(le+1),this._convertFromCellCoord(xe+1)))&&I.call(this,m,y,b,A,Me,O,z,q))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=p+this.cells.length+1+1,b=0,A=0;A=0||(b[A]=xf(p[A],c)));p instanceof Error&&(b.message=p.message)}if(b.$name)throw new Error("$name property is reserved for worker serialization logic.");return y!=="Object"&&(b.$name=y),b}throw new Error("can't serialize object of type "+typeof p)}function Wg(p){if(p==null||typeof p=="boolean"||typeof p=="number"||typeof p=="string"||p instanceof Boolean||p instanceof Number||p instanceof String||p instanceof Date||p instanceof RegExp||B_(p)||p instanceof ImageBitmap||ArrayBuffer.isView(p)||p instanceof ImageData)return p;if(Array.isArray(p))return p.map(Wg);if(typeof p=="object"){const c=p.$name||"Object";if(c==="Map"){const b=p.entries||[],A=new Map;for(let I=0;Ip>=128&&p<=255,Arabic:p=>p>=1536&&p<=1791,"Arabic Supplement":p=>p>=1872&&p<=1919,"Arabic Extended-A":p=>p>=2208&&p<=2303,"Hangul Jamo":p=>p>=4352&&p<=4607,"Unified Canadian Aboriginal Syllabics":p=>p>=5120&&p<=5759,Khmer:p=>p>=6016&&p<=6143,"Unified Canadian Aboriginal Syllabics Extended":p=>p>=6320&&p<=6399,"General Punctuation":p=>p>=8192&&p<=8303,"Letterlike Symbols":p=>p>=8448&&p<=8527,"Number Forms":p=>p>=8528&&p<=8591,"Miscellaneous Technical":p=>p>=8960&&p<=9215,"Control Pictures":p=>p>=9216&&p<=9279,"Optical Character Recognition":p=>p>=9280&&p<=9311,"Enclosed Alphanumerics":p=>p>=9312&&p<=9471,"Geometric Shapes":p=>p>=9632&&p<=9727,"Miscellaneous Symbols":p=>p>=9728&&p<=9983,"Miscellaneous Symbols and Arrows":p=>p>=11008&&p<=11263,"CJK Radicals Supplement":p=>p>=11904&&p<=12031,"Kangxi Radicals":p=>p>=12032&&p<=12255,"Ideographic Description Characters":p=>p>=12272&&p<=12287,"CJK Symbols and Punctuation":p=>p>=12288&&p<=12351,Hiragana:p=>p>=12352&&p<=12447,Katakana:p=>p>=12448&&p<=12543,Bopomofo:p=>p>=12544&&p<=12591,"Hangul Compatibility Jamo":p=>p>=12592&&p<=12687,Kanbun:p=>p>=12688&&p<=12703,"Bopomofo Extended":p=>p>=12704&&p<=12735,"CJK Strokes":p=>p>=12736&&p<=12783,"Katakana Phonetic Extensions":p=>p>=12784&&p<=12799,"Enclosed CJK Letters and Months":p=>p>=12800&&p<=13055,"CJK Compatibility":p=>p>=13056&&p<=13311,"CJK Unified Ideographs Extension A":p=>p>=13312&&p<=19903,"Yijing Hexagram Symbols":p=>p>=19904&&p<=19967,"CJK Unified Ideographs":p=>p>=19968&&p<=40959,"Yi Syllables":p=>p>=40960&&p<=42127,"Yi Radicals":p=>p>=42128&&p<=42191,"Hangul Jamo Extended-A":p=>p>=43360&&p<=43391,"Hangul Syllables":p=>p>=44032&&p<=55215,"Hangul Jamo Extended-B":p=>p>=55216&&p<=55295,"Private Use Area":p=>p>=57344&&p<=63743,"CJK Compatibility Ideographs":p=>p>=63744&&p<=64255,"Arabic Presentation Forms-A":p=>p>=64336&&p<=65023,"Vertical Forms":p=>p>=65040&&p<=65055,"CJK Compatibility Forms":p=>p>=65072&&p<=65103,"Small Form Variants":p=>p>=65104&&p<=65135,"Arabic Presentation Forms-B":p=>p>=65136&&p<=65279,"Halfwidth and Fullwidth Forms":p=>p>=65280&&p<=65519,Osage:p=>p>=66736&&p<=66815,"CJK Unified Ideographs Extension B":p=>p>=131072&&p<=173791};function $_(p){for(const c of p)if(xS(c.charCodeAt(0)))return!0;return!1}function ZM(p){for(const c of p)if(!GL(c.charCodeAt(0)))return!1;return!0}function GL(p){return!(qr.Arabic(p)||qr["Arabic Supplement"](p)||qr["Arabic Extended-A"](p)||qr["Arabic Presentation Forms-A"](p)||qr["Arabic Presentation Forms-B"](p))}function xS(p){return!(p!==746&&p!==747&&(p<4352||!(qr["Bopomofo Extended"](p)||qr.Bopomofo(p)||qr["CJK Compatibility Forms"](p)&&!(p>=65097&&p<=65103)||qr["CJK Compatibility Ideographs"](p)||qr["CJK Compatibility"](p)||qr["CJK Radicals Supplement"](p)||qr["CJK Strokes"](p)||!(!qr["CJK Symbols and Punctuation"](p)||p>=12296&&p<=12305||p>=12308&&p<=12319||p===12336)||qr["CJK Unified Ideographs Extension A"](p)||qr["CJK Unified Ideographs"](p)||qr["Enclosed CJK Letters and Months"](p)||qr["Hangul Compatibility Jamo"](p)||qr["Hangul Jamo Extended-A"](p)||qr["Hangul Jamo Extended-B"](p)||qr["Hangul Jamo"](p)||qr["Hangul Syllables"](p)||qr.Hiragana(p)||qr["Ideographic Description Characters"](p)||qr.Kanbun(p)||qr["Kangxi Radicals"](p)||qr["Katakana Phonetic Extensions"](p)||qr.Katakana(p)&&p!==12540||!(!qr["Halfwidth and Fullwidth Forms"](p)||p===65288||p===65289||p===65293||p>=65306&&p<=65310||p===65339||p===65341||p===65343||p>=65371&&p<=65503||p===65507||p>=65512&&p<=65519)||!(!qr["Small Form Variants"](p)||p>=65112&&p<=65118||p>=65123&&p<=65126)||qr["Unified Canadian Aboriginal Syllabics"](p)||qr["Unified Canadian Aboriginal Syllabics Extended"](p)||qr["Vertical Forms"](p)||qr["Yijing Hexagram Symbols"](p)||qr["Yi Syllables"](p)||qr["Yi Radicals"](p))))}function yS(p){return!(xS(p)||function(c){return!!(qr["Latin-1 Supplement"](c)&&(c===167||c===169||c===174||c===177||c===188||c===189||c===190||c===215||c===247)||qr["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)||qr["Letterlike Symbols"](c)||qr["Number Forms"](c)||qr["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)||qr["Control Pictures"](c)&&c!==9251||qr["Optical Character Recognition"](c)||qr["Enclosed Alphanumerics"](c)||qr["Geometric Shapes"](c)||qr["Miscellaneous Symbols"](c)&&!(c>=9754&&c<=9759)||qr["Miscellaneous Symbols and Arrows"](c)&&(c>=11026&&c<=11055||c>=11088&&c<=11097||c>=11192&&c<=11243)||qr["CJK Symbols and Punctuation"](c)||qr.Katakana(c)||qr["Private Use Area"](c)||qr["CJK Compatibility Forms"](c)||qr["Small Form Variants"](c)||qr["Halfwidth and Fullwidth Forms"](c)||c===8734||c===8756||c===8757||c>=9984&&c<=10087||c>=10102&&c<=10131||c===65532||c===65533)}(p))}function vS(p){return qr.Arabic(p)||qr["Arabic Supplement"](p)||qr["Arabic Extended-A"](p)||qr["Arabic Presentation Forms-A"](p)||qr["Arabic Presentation Forms-B"](p)}function YM(p){return p>=1424&&p<=2303||qr["Arabic Presentation Forms-A"](p)||qr["Arabic Presentation Forms-B"](p)}function yf(p,c){return!(!c&&YM(p)||p>=2304&&p<=3583||p>=3840&&p<=4255||qr.Khmer(p))}function dce(p){for(const c of p)if(YM(c.charCodeAt(0)))return!0;return!1}const Su={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let XM=null,zd=Su.unavailable,vf=null;const U_=function(p){p&&typeof p=="string"&&p.indexOf("NetworkError")>-1&&(zd=Su.error),XM&&XM(p)};function _S(){bS.fire(new Ks("pluginStateChange",{pluginStatus:zd,pluginURL:vf}))}const bS=new Qn,q_=function(){return zd},KL=function(){if(zd!==Su.deferred||!vf)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");zd=Su.loading,_S(),vf&&Ju({url:vf},p=>{p?U_(p):(zd=Su.loaded,_S())})},_f={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>zd===Su.loaded||_f.applyArabicShaping!=null,isLoading:()=>zd===Su.loading,setState(p){zd=p.pluginStatus,vf=p.pluginURL},isParsing:()=>zd===Su.parsing,isParsed:()=>zd===Su.parsed,getPluginURL:()=>vf};class Si{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 b of m)if(!yf(b.charCodeAt(0),y))return!1;return!0}(c,_f.isLoaded())}}class wS{constructor(c,m,y,b,A){this.property=c,this.value=m,this.expression=function(I,O,z,q,X){if(pS(I))return new gS(I,O);if(z_(I)||Array.isArray(I)&&I.length>0){const Q=GM(I,O,z,q,X);if(Q.result==="error")throw new Error(Q.value.map(se=>`${se.key}: ${se.message}`).join(", "));return Q.value}{let Q=I;return typeof I=="string"&&O.type==="color"&&(Q=Da.parse(I)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>Q}}}(m===void 0?c.specification.default:m,c.specification,y,b,A)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(c,m,y,b){return this.property.possiblyEvaluate(this,c,m,y,b)}}class QM{constructor(c,m,y,b){this.property=c,this.value=new wS(c,void 0,m,y,b)}transitioned(c,m){return new YL(this.property,this.value,m,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new YL(this.property,this.value,null,{},0)}}class ZL{constructor(c,m,y,b){this._properties=c,this._values=Object.create(c.defaultTransitionablePropertyValues),this._scope=m,this._options=y,this._iconImageUseTheme=b,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(c){return ps(this._values[c].value.value)}setValue(c,m){this._values.hasOwnProperty(c)||(this._values[c]=new QM(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new wS(this._values[c].property,m===null?void 0:ps(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 b in c){const A=c[b];if(b.endsWith("-transition")){const I=b.slice(0,-11);y[I]&&this.setTransition(I,A)}else y.hasOwnProperty(b)&&this.setValue(b,A)}}getTransition(c){return ps(this._values[c].transition)}setTransition(c,m){this._values.hasOwnProperty(c)||(this._values[c]=new QM(this._values[c].property)),this._values[c].transition=ps(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 b=this.getTransition(m);b!==void 0&&(c[`${m}-transition`]=b)}return c}transitioned(c,m){const y=new XL(this._properties);for(const b of Object.keys(this._values))y._values[b]=this._values[b].transitioned(c,m._values[b]);return y}untransitioned(){const c=new XL(this._properties);for(const m of Object.keys(this._values))c._values[m]=this._values[m].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class YL{constructor(c,m,y,b,A){const I=b.delay||0,O=b.duration||0;A=A||0,this.property=c,this.value=m,this.begin=A+I,this.end=this.begin+O,c.specification.transition&&(b.delay||b.duration)&&(this.prior=y)}possiblyEvaluate(c,m,y){const b=c.now||0,A=this.value.possiblyEvaluate(c,m,y),I=this.prior;if(I){if(b>this.end)return this.prior=null,A;if(this.value.isDataDriven())return this.prior=null,A;if(b":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 JL(p){return p instanceof Number||p instanceof String||p instanceof Boolean?p.valueOf():p}function jS(p){if(Array.isArray(p))return p.map(jS);if(p instanceof Object&&!(p instanceof Number||p instanceof String||p instanceof Boolean)){const c={};for(const m in p)c[m]=jS(p[m]);return c}return JL(p)}function yp(p){if(p===!0||p===!1)return!0;if(!Array.isArray(p)||p.length===0)return!1;switch(p[0]){case"has":return p.length>=2&&p[1]!=="$id"&&p[1]!=="$type";case"in":return p.length>=3&&(typeof p[1]!="string"||Array.isArray(p[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return p.length!==3||Array.isArray(p[1])||Array.isArray(p[2]);case"any":case"all":for(const c of p.slice(1))if(!yp(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function kS(p,c="",m=null,y="fill"){if(p==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};yp(p)||(p=NS(p));const b=p;let A=!0;try{A=function(X){if(!Q0(X))return X;let Q=jS(X);return eD(Q),Q=uy(Q),Q}(b)}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(b,null,2)} `)}let I=null,O=null;if(y!=="background"&&y!=="sky"&&y!=="slot"){O=Vt[`filter_${y}`];const X=Hg(A,O,c,m);if(X.result==="error")throw new Error(X.value.map(Q=>`${Q.key}: ${Q.message}`).join(", "));I=(Q,se,ae)=>X.value.evaluate(Q,se,{},ae)}let z=null,q=null;if(A!==b){const X=Hg(b,O,c,m);if(X.result==="error")throw new Error(X.value.map(Q=>`${Q.key}: ${Q.message}`).join(", "));z=(Q,se,ae,le,xe)=>X.value.evaluate(Q,se,{},ae,void 0,void 0,le,xe),q=!U0(X.value.expression)}return{filter:I,dynamicFilter:z||void 0,needGeometry:tD(A),needFeature:!!q}}function uy(p){if(!Array.isArray(p))return p;const c=function(m){if(uce.has(m[0])){for(let y=1;yuy(m))}function eD(p){let c=!1;const m=[];if(p[0]==="case"){for(let y=1;y",">=","<","<=","to-boolean"]);function hce(p,c){return pc?1:0}function tD(p){if(!Array.isArray(p))return!1;if(p[0]==="within"||p[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?SS(p[1],p[2],c):c==="any"?(m=p.slice(1),["any"].concat(m.map(NS))):c==="all"?["all"].concat(p.slice(1).map(NS)):c==="none"?["all"].concat(p.slice(1).map(NS).map(V_)):c==="in"?CS(p[1],p.slice(2)):c==="!in"?V_(CS(p[1],p.slice(2))):c==="has"?MS(p[1]):c!=="!has"||V_(MS(p[1]));var m}function SS(p,c,m){switch(p){case"$type":return[`filter-type-${m}`,c];case"$id":return[`filter-id-${m}`,c];default:return[`filter-${m}`,p,c]}}function CS(p,c){if(c.length===0)return!1;switch(p){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",p,["literal",c.sort(hce)]]:["filter-in-small",p,["literal",c]]}}function MS(p){switch(p){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",p]}}function V_(p){return["!",p]}const hy="";function Nm(p,c){return c?`${p}${hy}${c}`:p}let sD;const rD=()=>sD||(sD=new xo({"icon-size":new Xs(Vt.layout_symbol["icon-size"]),"icon-image":new Xs(Vt.layout_symbol["icon-image"]),"icon-rotate":new Xs(Vt.layout_symbol["icon-rotate"]),"icon-offset":new Xs(Vt.layout_symbol["icon-offset"]),"text-size":new Xs(Vt.layout_symbol["text-size"]),"text-rotate":new Xs(Vt.layout_symbol["text-rotate"]),"text-offset":new Xs(Vt.layout_symbol["text-offset"])}));class nD{constructor(c,m,y,b,A,I){const O=Hg(c,Vt.appearance.condition);if(O.result==="success"&&(this.condition=O.value),this.name=m,y){this.properties=new cy(rD()),this.unevaluatedLayout=new QL(rD(),b,A,I);for(const z in y)this.unevaluatedLayout.setValue(z,y[z])}}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"),b=this.hasProperty("icon-rotate");return c||m||y||b}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 aD="-transition",vp=new Set(["fill","line","background","hillshade","raster"]);class Bd extends Qn{constructor(c,m,y,b,A,I){if(super(),this.id=c.id,this.fqid=Nm(this.id,y),this.type=c.type,this.scope=y,this.lut=b,this.options=A,this.iconImageUseTheme=I,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=Hg(this.filter,Vt[`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 QL(m.layout,this.scope,A,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 ZL(m.paint,this.scope,A);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 cy(m.paint)}}}onAdd(c){}onRemove(c){}isDraped(c){return!this.is3D(!0)&&vp.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 nD(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(aD)?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,b=y._properties.properties;if(c.endsWith(aD)){const Q=c.slice(0,-11);return b[Q]&&y.setTransition(Q,m||void 0),!1}if(!b[c])return!1;const A=y._values[c],I=A.value.isDataDriven(),O=A.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 z=y._values[c].value,q=z.isDataDriven(),X=c.endsWith("pattern")||c==="line-dasharray";return q||I||X||this._handleOverridablePaintPropertyUpdate(c,O,z)}_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())),Ss(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 ly&&F_(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const c of this.appearances)if(!I_(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=kS(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,b,A,I,O,z,q){}}const iD={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class H_{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 mce=new ArrayBuffer(0);class Bi{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=mce),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 ea(p,c=1){let m=0,y=0;return{members:p.map(b=>{const A=iD[b.type].BYTES_PER_ELEMENT,I=m=oD(m,Math.max(c,A)),O=b.components||1;return y=Math.max(y,A),m+=A*O,{name:b.name,type:b.type,components:O,offset:I}}),size:oD(m,Math.max(y,c)),alignment:c}}function oD(p,c){return Math.ceil(p/c)*c}class Gg extends Bi{_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 b=2*c;return this.int16[b+0]=m,this.int16[b+1]=y,c}}Gg.prototype.bytesPerElement=4,xr(Gg,"StructArrayLayout2i4");class J0 extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,m,y)}emplace(c,m,y,b){const A=3*c;return this.int16[A+0]=m,this.int16[A+1]=y,this.int16[A+2]=b,c}}J0.prototype.bytesPerElement=6,xr(J0,"StructArrayLayout3i6");class ev extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,b){const A=this.length;return this.resize(A+1),this.emplace(A,c,m,y,b)}emplace(c,m,y,b,A){const I=4*c;return this.int16[I+0]=m,this.int16[I+1]=y,this.int16[I+2]=b,this.int16[I+3]=A,c}}ev.prototype.bytesPerElement=8,xr(ev,"StructArrayLayout4i8");class bf extends Bi{_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}}bf.prototype.bytesPerElement=4,xr(bf,"StructArrayLayout1f4");class JM extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,m,y)}emplace(c,m,y,b){const A=4*c,I=2*c;return this.int16[A+0]=m,this.int16[A+1]=y,this.float32[I+1]=b,c}}JM.prototype.bytesPerElement=8,xr(JM,"StructArrayLayout2i1f8");class eT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,m,y)}emplace(c,m,y,b){const A=4*c;return this.int16[A+0]=m,this.int16[A+1]=y,this.int16[A+2]=b,c}}eT.prototype.bytesPerElement=8,xr(eT,"StructArrayLayout3i8");class tT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A){const I=this.length;return this.resize(I+1),this.emplace(I,c,m,y,b,A)}emplace(c,m,y,b,A,I){const O=5*c;return this.int16[O+0]=m,this.int16[O+1]=y,this.int16[O+2]=b,this.int16[O+3]=A,this.int16[O+4]=I,c}}tT.prototype.bytesPerElement=10,xr(tT,"StructArrayLayout5i10");class TS extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I,O){const z=this.length;return this.resize(z+1),this.emplace(z,c,m,y,b,A,I,O)}emplace(c,m,y,b,A,I,O,z){const q=6*c,X=12*c,Q=3*c;return this.int16[q+0]=m,this.int16[q+1]=y,this.uint8[X+4]=b,this.uint8[X+5]=A,this.uint8[X+6]=I,this.uint8[X+7]=O,this.float32[Q+2]=z,c}}TS.prototype.bytesPerElement=12,xr(TS,"StructArrayLayout2i4ub1f12");class sh extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,m,y)}emplace(c,m,y,b){const A=3*c;return this.float32[A+0]=m,this.float32[A+1]=y,this.float32[A+2]=b,c}}sh.prototype.bytesPerElement=12,xr(sh,"StructArrayLayout3f12");class ou extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A){const I=this.length;return this.resize(I+1),this.emplace(I,c,m,y,b,A)}emplace(c,m,y,b,A,I){const O=6*c,z=3*c;return this.uint16[O+0]=m,this.uint16[O+1]=y,this.uint16[O+2]=b,this.uint16[O+3]=A,this.float32[z+2]=I,c}}ou.prototype.bytesPerElement=12,xr(ou,"StructArrayLayout4ui1f12");class my extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,b){const A=this.length;return this.resize(A+1),this.emplace(A,c,m,y,b)}emplace(c,m,y,b,A){const I=4*c;return this.uint16[I+0]=m,this.uint16[I+1]=y,this.uint16[I+2]=b,this.uint16[I+3]=A,c}}my.prototype.bytesPerElement=8,xr(my,"StructArrayLayout4ui8");class AS extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,b,A,I)}emplace(c,m,y,b,A,I,O){const z=6*c;return this.int16[z+0]=m,this.int16[z+1]=y,this.int16[z+2]=b,this.int16[z+3]=A,this.int16[z+4]=I,this.int16[z+5]=O,c}}AS.prototype.bytesPerElement=12,xr(AS,"StructArrayLayout6i12");class sT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I,O,z,q,X,Q,se){const ae=this.length;return this.resize(ae+1),this.emplace(ae,c,m,y,b,A,I,O,z,q,X,Q,se)}emplace(c,m,y,b,A,I,O,z,q,X,Q,se,ae){const le=12*c;return this.int16[le+0]=m,this.int16[le+1]=y,this.int16[le+2]=b,this.int16[le+3]=A,this.uint16[le+4]=I,this.uint16[le+5]=O,this.uint16[le+6]=z,this.uint16[le+7]=q,this.int16[le+8]=X,this.int16[le+9]=Q,this.int16[le+10]=se,this.int16[le+11]=ae,c}}sT.prototype.bytesPerElement=24,xr(sT,"StructArrayLayout4i4ui4i24");class rT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,b,A,I)}emplace(c,m,y,b,A,I,O){const z=10*c,q=5*c;return this.int16[z+0]=m,this.int16[z+1]=y,this.int16[z+2]=b,this.float32[q+2]=A,this.float32[q+3]=I,this.float32[q+4]=O,c}}rT.prototype.bytesPerElement=20,xr(rT,"StructArrayLayout3i3f20");class Kg extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b){const A=this.length;return this.resize(A+1),this.emplace(A,c,m,y,b)}emplace(c,m,y,b,A){const I=4*c;return this.float32[I+0]=m,this.float32[I+1]=y,this.float32[I+2]=b,this.float32[I+3]=A,c}}Kg.prototype.bytesPerElement=16,xr(Kg,"StructArrayLayout4f16");class ES extends Bi{_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}}ES.prototype.bytesPerElement=4,xr(ES,"StructArrayLayout1ul4");class rh extends Bi{_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 b=2*c;return this.uint16[b+0]=m,this.uint16[b+1]=y,c}}rh.prototype.bytesPerElement=4,xr(rh,"StructArrayLayout2ui4");class IS extends Bi{_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,b,A,I,O,z,q,X,Q,se,ae){const le=this.length;return this.resize(le+1),this.emplace(le,c,m,y,b,A,I,O,z,q,X,Q,se,ae)}emplace(c,m,y,b,A,I,O,z,q,X,Q,se,ae,le){const xe=20*c,Me=10*c;return this.int16[xe+0]=m,this.int16[xe+1]=y,this.int16[xe+2]=b,this.int16[xe+3]=A,this.int16[xe+4]=I,this.float32[Me+3]=O,this.float32[Me+4]=z,this.float32[Me+5]=q,this.float32[Me+6]=X,this.int16[xe+14]=Q,this.uint32[Me+8]=se,this.uint16[xe+18]=ae,this.uint16[xe+19]=le,c}}IS.prototype.bytesPerElement=40,xr(IS,"StructArrayLayout5i4f1i1ul2ui40");class PS extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I,O){const z=this.length;return this.resize(z+1),this.emplace(z,c,m,y,b,A,I,O)}emplace(c,m,y,b,A,I,O,z){const q=8*c;return this.int16[q+0]=m,this.int16[q+1]=y,this.int16[q+2]=b,this.int16[q+4]=A,this.int16[q+5]=I,this.int16[q+6]=O,this.int16[q+7]=z,c}}PS.prototype.bytesPerElement=16,xr(PS,"StructArrayLayout3i2i2i16");class LS extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A){const I=this.length;return this.resize(I+1),this.emplace(I,c,m,y,b,A)}emplace(c,m,y,b,A,I){const O=4*c,z=8*c;return this.float32[O+0]=m,this.float32[O+1]=y,this.float32[O+2]=b,this.int16[z+6]=A,this.int16[z+7]=I,c}}LS.prototype.bytesPerElement=16,xr(LS,"StructArrayLayout2f1f2i16");class nT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,b,A,I)}emplace(c,m,y,b,A,I,O){const z=20*c,q=5*c;return this.uint8[z+0]=m,this.uint8[z+1]=y,this.float32[q+1]=b,this.float32[q+2]=A,this.float32[q+3]=I,this.float32[q+4]=O,c}}nT.prototype.bytesPerElement=20,xr(nT,"StructArrayLayout2ub4f20");class ol extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,m,y)}emplace(c,m,y,b){const A=3*c;return this.uint16[A+0]=m,this.uint16[A+1]=y,this.uint16[A+2]=b,c}}ol.prototype.bytesPerElement=6,xr(ol,"StructArrayLayout3ui6");class tv extends Bi{_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,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze,Ve,Je,vt){const mt=this.length;return this.resize(mt+1),this.emplace(mt,c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze,Ve,Je,vt)}emplace(c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze,Ve,Je,vt,mt){const St=30*c,It=15*c,Ot=60*c;return this.int16[St+0]=m,this.int16[St+1]=y,this.int16[St+2]=b,this.float32[It+2]=A,this.float32[It+3]=I,this.uint16[St+8]=O,this.uint16[St+9]=z,this.uint32[It+5]=q,this.uint32[It+6]=X,this.uint32[It+7]=Q,this.uint16[St+16]=se,this.uint16[St+17]=ae,this.uint16[St+18]=le,this.float32[It+10]=xe,this.float32[It+11]=Me,this.uint8[Ot+48]=Ce,this.uint8[Ot+49]=ze,this.uint8[Ot+50]=Ve,this.uint32[It+13]=Je,this.int16[St+28]=vt,this.uint8[Ot+58]=mt,c}}tv.prototype.bytesPerElement=60,xr(tv,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class aT extends Bi{_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,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze,Ve,Je,vt,mt,St,It,Ot,ns,qt,us,gs,xs,As,Is,Ns){const Ms=this.length;return this.resize(Ms+1),this.emplace(Ms,c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze,Ve,Je,vt,mt,St,It,Ot,ns,qt,us,gs,xs,As,Is,Ns)}emplace(c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze,Ve,Je,vt,mt,St,It,Ot,ns,qt,us,gs,xs,As,Is,Ns,Ms){const ds=20*c,as=40*c,Ts=80*c;return this.float32[ds+0]=m,this.float32[ds+1]=y,this.int16[as+4]=b,this.int16[as+5]=A,this.int16[as+6]=I,this.int16[as+7]=O,this.int16[as+8]=z,this.int16[as+9]=q,this.int16[as+10]=X,this.int16[as+11]=Q,this.int16[as+12]=se,this.uint16[as+13]=ae,this.uint16[as+14]=le,this.uint16[as+15]=xe,this.uint16[as+16]=Me,this.uint16[as+17]=Ce,this.uint16[as+18]=ze,this.uint16[as+19]=Ve,this.uint16[as+20]=Je,this.uint16[as+21]=vt,this.uint16[as+22]=mt,this.uint16[as+23]=St,this.uint16[as+24]=It,this.uint16[as+25]=Ot,this.uint16[as+26]=ns,this.uint16[as+27]=qt,this.uint32[ds+14]=us,this.float32[ds+15]=gs,this.float32[ds+16]=xs,this.float32[ds+17]=As,this.float32[ds+18]=Is,this.uint8[Ts+76]=Ns,this.uint16[as+39]=Ms,c}}aT.prototype.bytesPerElement=80,xr(aT,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class iT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I){const O=this.length;return this.resize(O+1),this.emplace(O,c,m,y,b,A,I)}emplace(c,m,y,b,A,I,O){const z=6*c;return this.float32[z+0]=m,this.float32[z+1]=y,this.float32[z+2]=b,this.float32[z+3]=A,this.float32[z+4]=I,this.float32[z+5]=O,c}}iT.prototype.bytesPerElement=24,xr(iT,"StructArrayLayout6f24");class py extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A){const I=this.length;return this.resize(I+1),this.emplace(I,c,m,y,b,A)}emplace(c,m,y,b,A,I){const O=5*c;return this.float32[O+0]=m,this.float32[O+1]=y,this.float32[O+2]=b,this.float32[O+3]=A,this.float32[O+4]=I,c}}py.prototype.bytesPerElement=20,xr(py,"StructArrayLayout5f20");class oT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I,O){const z=this.length;return this.resize(z+1),this.emplace(z,c,m,y,b,A,I,O)}emplace(c,m,y,b,A,I,O,z){const q=7*c;return this.float32[q+0]=m,this.float32[q+1]=y,this.float32[q+2]=b,this.float32[q+3]=A,this.float32[q+4]=I,this.float32[q+5]=O,this.float32[q+6]=z,c}}oT.prototype.bytesPerElement=28,xr(oT,"StructArrayLayout7f28");class lT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I,O,z,q,X,Q){const se=this.length;return this.resize(se+1),this.emplace(se,c,m,y,b,A,I,O,z,q,X,Q)}emplace(c,m,y,b,A,I,O,z,q,X,Q,se){const ae=11*c;return this.float32[ae+0]=m,this.float32[ae+1]=y,this.float32[ae+2]=b,this.float32[ae+3]=A,this.float32[ae+4]=I,this.float32[ae+5]=O,this.float32[ae+6]=z,this.float32[ae+7]=q,this.float32[ae+8]=X,this.float32[ae+9]=Q,this.float32[ae+10]=se,c}}lT.prototype.bytesPerElement=44,xr(lT,"StructArrayLayout11f44");class sv extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I,O,z,q){const X=this.length;return this.resize(X+1),this.emplace(X,c,m,y,b,A,I,O,z,q)}emplace(c,m,y,b,A,I,O,z,q,X){const Q=9*c;return this.float32[Q+0]=m,this.float32[Q+1]=y,this.float32[Q+2]=b,this.float32[Q+3]=A,this.float32[Q+4]=I,this.float32[Q+5]=O,this.float32[Q+6]=z,this.float32[Q+7]=q,this.float32[Q+8]=X,c}}sv.prototype.bytesPerElement=36,xr(sv,"StructArrayLayout9f36");class _p extends Bi{_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 b=2*c;return this.float32[b+0]=m,this.float32[b+1]=y,c}}_p.prototype.bytesPerElement=8,xr(_p,"StructArrayLayout2f8");class lu extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,m,y,b){const A=this.length;return this.resize(A+1),this.emplace(A,c,m,y,b)}emplace(c,m,y,b,A){const I=6*c;return this.uint32[3*c+0]=m,this.uint16[I+2]=y,this.uint16[I+3]=b,this.uint16[I+4]=A,c}}lu.prototype.bytesPerElement=12,xr(lu,"StructArrayLayout1ul3ui12");class Zg extends Bi{_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}}Zg.prototype.bytesPerElement=2,xr(Zg,"StructArrayLayout1ui2");class cT extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me)}emplace(c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce){const ze=16*c;return this.float32[ze+0]=m,this.float32[ze+1]=y,this.float32[ze+2]=b,this.float32[ze+3]=A,this.float32[ze+4]=I,this.float32[ze+5]=O,this.float32[ze+6]=z,this.float32[ze+7]=q,this.float32[ze+8]=X,this.float32[ze+9]=Q,this.float32[ze+10]=se,this.float32[ze+11]=ae,this.float32[ze+12]=le,this.float32[ze+13]=xe,this.float32[ze+14]=Me,this.float32[ze+15]=Ce,c}}cT.prototype.bytesPerElement=64,xr(cT,"StructArrayLayout16f64");class DS extends Bi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,m,y,b,A,I,O){const z=this.length;return this.resize(z+1),this.emplace(z,c,m,y,b,A,I,O)}emplace(c,m,y,b,A,I,O,z){const q=10*c,X=5*c;return this.uint16[q+0]=m,this.uint16[q+1]=y,this.uint16[q+2]=b,this.uint16[q+3]=A,this.float32[X+2]=I,this.float32[X+3]=O,this.float32[X+4]=z,c}}DS.prototype.bytesPerElement=20,xr(DS,"StructArrayLayout4ui3f20");class dT extends Bi{_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}}dT.prototype.bytesPerElement=2,xr(dT,"StructArrayLayout1i2");class OS extends Bi{_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}}OS.prototype.bytesPerElement=1,xr(OS,"StructArrayLayout1ub1");class RS extends H_{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]}}RS.prototype.size=40;class lD extends IS{get(c){return new RS(this,c)}}xr(lD,"CollisionBoxArray");class FS extends H_{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}}FS.prototype.size=60;class cD extends tv{get(c){return new FS(this,c)}}xr(cD,"PlacedSymbolArray");class dD extends H_{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]}}dD.prototype.size=80;class uT extends aT{get(c){return new dD(this,c)}}xr(uT,"SymbolInstanceArray");class zS extends bf{getoffsetX(c){return this.float32[1*c+0]}}xr(zS,"GlyphOffsetArray");class uD extends Gg{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}xr(uD,"SymbolLineVertexArray");class hT extends H_{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]}}hT.prototype.size=12;class mT extends lu{get(c){return new hT(this,c)}}xr(mT,"FeatureIndexArray");class hD extends rh{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}xr(hD,"FillExtrusionCentroidArray");class BS extends H_{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]}}BS.prototype.size=6;class W_ extends J0{get(c){return new BS(this,c)}}xr(W_,"FillExtrusionWallArray");const mD=ea([{name:"a_pos",components:2,type:"Int16"}],4),pce=ea([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),pD=ea([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ro{constructor(c=[]){this.segments=c}_prepareSegment(c,m,y,b){let A=this.segments[this.segments.length-1];return c>ro.MAX_VERTEX_ARRAY_LENGTH&&cr(`Max vertices per segment is ${ro.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!A||A.vertexLength+c>ro.MAX_VERTEX_ARRAY_LENGTH||A.sortKey!==b)&&(A={vertexOffset:m,primitiveOffset:y,vertexLength:0,primitiveLength:0},b!==void 0&&(A.sortKey=b),this.segments.push(A)),A}prepareSegment(c,m,y,b){return this._prepareSegment(c,m.length,y.length,b)}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,b){return new ro([{vertexOffset:c,primitiveOffset:m,vertexLength:y,primitiveLength:b,vaos:{},sortKey:0}])}}function $S(p,c){return 256*(p=_e(Math.floor(p),0,255))+_e(Math.floor(c),0,255)}ro.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,xr(ro,"SegmentVector");const fce=ea([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),gce=ea([{name:"a_pattern_b",components:4,type:"Uint16"}]),xce=ea([{name:"a_dash",components:4,type:"Uint16"}]);class G_{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,m,y,b){this.ids.push(pT(c)),this.positions.push(m,y,b)}eachPosition(c,m){const y=pT(c);let b=0,A=this.ids.length-1;for(;b>1;this.ids[I]>=y?A=I:b=I+1}for(;this.ids[b]===y;)m(this.positions[3*b],this.positions[3*b+1],this.positions[3*b+2]),b++}static serialize(c,m){const y=new Float64Array(c.ids),b=new Uint32Array(c.positions);return fT(y,b,0,y.length-1),m&&(m.add(y.buffer),m.add(b.buffer)),{ids:y,positions:b}}static deserialize(c){const m=new G_;let y;m.ids=c.ids,m.positions=c.positions;for(const b of m.ids)b!==y&&m.uniqueIds.push(b),y=b;return m.indexed=!0,m}}function pT(p){const c=+p;return Number.isSafeInteger(c)?c:Cs(String(p))}function fT(p,c,m,y){for(;m>1];let A=m-1,I=y+1;for(;;){do A++;while(p[A]b);if(A>=I)break;US(p,A,I),US(c,3*A,3*I),US(c,3*A+1,3*I+1),US(c,3*A+2,3*I+2)}I-m`u_${A}`),this.type=y,this.context=b}setUniform(c,m,y,b,A){const I=b.constantOr(this.value);m.set(c,A,I instanceof Da?I.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):I)}getBinding(c,m){return this.type==="color"?new Z_(c):new ll(c)}}class rv{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,b,A){let I=null;A!=="u_pattern"&&A!=="u_dash"||(I=this.pattern),A==="u_pattern_b"&&(I=this.patternTransition),A==="u_pixel_ratio"&&(I=this.pixelRatio),I&&m.set(c,A,I)}getBinding(c,m){return m==="u_pattern"||m==="u_pattern_b"||m==="u_dash"?new VS(c):new ll(c)}}class jf{constructor(c,m,y,b){this.expression=c,this.type=y,this.maxValue=0,this.paintVertexAttributes=m.map(A=>({name:`a_${A}`,type:"Float32",components:y==="color"?2:1,offset:0})),this.paintVertexArray=new b}populatePaintArray(c,m,y,b,A,I,O,z){const q=this.paintVertexArray.length,X=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Si(0,{brightness:I,worldview:z}),m,{},A,b,O):this.expression.kind==="constant"&&this.expression.value,Q=X_(this.lutExpression,m,{},b,A,I,O,z);this.paintVertexArray.resize(c),this._setPaintValue(q,c,X,Q?null:this.context.lut)}updatePaintArray(c,m,y,b,A,I,O,z){const q=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:O,worldview:z},y,b,void 0,A):this.expression.kind==="constant"&&this.expression.value,X=X_(this.lutExpression,y,b,A,void 0,O,void 0,z);this._setPaintValue(c,m,q,X?null:this.context.lut)}_setPaintValue(c,m,y,b){if(this.type==="color"){const A=gT(y.toPremultipliedRenderColor(b));for(let I=c;I`u_${O}_t`),this.type=y,this.useIntegerZoom=b,this.context=A,this.maxValue=0,this.paintVertexAttributes=m.map(O=>({name:`a_${O}`,type:"Float32",components:y==="color"?4:2,offset:0})),this.paintVertexArray=new I}populatePaintArray(c,m,y,b,A,I,O,z){const q=this.expression.evaluate(new Si(this.context.zoom,{brightness:I,worldview:z}),m,{},A,b,O),X=this.expression.evaluate(new Si(this.context.zoom+1,{brightness:I,worldview:z}),m,{},A,b,O),Q=X_(this.lutExpression,m,{},b,A,I,O,z),se=this.paintVertexArray.length;this.paintVertexArray.resize(c),this._setPaintValue(se,c,q,X,Q?null:this.context.lut)}updatePaintArray(c,m,y,b,A,I,O,z){const q=this.expression.evaluate({zoom:this.context.zoom,brightness:O,worldview:z},y,b,void 0,A),X=this.expression.evaluate({zoom:this.context.zoom+1,brightness:O,worldview:z},y,b,void 0,A),Q=X_(this.lutExpression,y,b,A,void 0,O,void 0,z);this._setPaintValue(c,m,q,X,Q?null:this.context.lut)}_setPaintValue(c,m,y,b,A){if(this.type==="color"){const I=gT(y.toPremultipliedRenderColor(A)),O=gT(y.toPremultipliedRenderColor(A));for(let z=c;z!0){this.binders={},this._buffers=[],this.context=m;const b=[];for(const A in c.paint._values){const I=c.paint.get(A);if(A.endsWith("-use-theme")||!y(A)||!(I instanceof ly&&F_(I.property.specification)))continue;const O=bce(A,c.type),z=I.value,q=I.property.specification.type,X=!!I.property.useIntegerZoom,Q=A==="line-dasharray"||A.endsWith("pattern"),se=c.paint.get(`${A}-use-theme`),ae=A==="line-dasharray"&&c.layout.get("line-cap").value.kind!=="constant"||se&&se.value.kind!=="constant";if(z.kind!=="constant"||ae)if(z.kind==="source"||ae||Q){const le=xT(A,q,"source");this.binders[A]=Q?new Nf(z,O,q,le,c.id):new jf(z,O,q,le),b.push(`/a_${A}`)}else{const le=xT(A,q,"composite");this.binders[A]=new kf(z,O,q,X,m,le),b.push(`/z_${A}`)}else this.binders[A]=Q?new rv(z.value,O):new Q_(z.value,O,q,m),b.push(`/u_${A}`);se&&(this.binders[A].lutExpression=se.value)}this.cacheKey=b.sort().join("")}getMaxValue(c){const m=this.binders[c];return m instanceof jf||m instanceof kf?m.maxValue:0}populatePaintArrays(c,m,y,b,A,I,O,z){for(const q in this.binders){const X=this.binders[q];X.context=this.context,(X instanceof jf||X instanceof kf||X instanceof Nf)&&X.populatePaintArray(c,m,y,b,A,I,O,z)}}setConstantPatternPositions(c,m){for(const y in this.binders){const b=this.binders[y];b instanceof rv&&b.setConstantPatternPositions(c,m)}}getPatternTransitionVertexBuffer(c){const m=this.binders[c];return m instanceof Nf?m.paintTransitionVertexBuffer:null}updatePaintArrays(c,m,y,b,A,I,O,z,q,X){let Q=!1;const se=Object.keys(c),ae=se.length!==0&&!z,le=ae?se:m.uniqueIds;this.context.lut=A.lut;for(const xe in this.binders){const Me=this.binders[xe];if(Me.context=this.context,(Me instanceof jf||Me instanceof kf||Me instanceof Nf)&&Me.expression&&Me.expression.kind&&Me.expression.kind!=="constant"&&(Me.expression.isStateDependent===!0||Me.expression.isLightConstant===!1)){const Ce=A.paint.get(xe);Me.expression=Ce.value;for(const ze of le){const Ve=c[ze.toString()];m.eachPosition(ze,(Je,vt,mt)=>{const St=b.feature(Je);Me.updatePaintArray(vt,mt,St,Ve,I,O,q,X)})}if(!ae)for(const ze of y.uniqueIds){const Ve=c[ze.toString()];y.eachPosition(ze,(Je,vt,mt)=>{const St=b.feature(Je);Me.updatePaintArray(vt,mt,St,Ve,I,O,q,X)})}Q=!0}}return Q}defines(){const c=[];for(const m in this.binders){const y=this.binders[m];(y instanceof Q_||y instanceof rv)&&c.push(...y.uniformNames.map(b=>`#define HAS_UNIFORM_${b}`))}return c}getPaintVertexBuffers(){return this._buffers}getUniforms(c){const m=[];for(const y in this.binders){const b=this.binders[y];if(b instanceof Q_||b instanceof rv||b instanceof kf)for(const A of b.uniformNames)m.push({name:A,property:y,binding:b.getBinding(c,A)})}return m}setUniforms(c,m,y,b,A){for(const{name:I,property:O,binding:z}of y)this.binders[O].setUniform(c,z,A,b.get(O),I)}updatePaintBuffers(){this._buffers=[];for(const c in this.binders){const m=this.binders[c];(m instanceof jf||m instanceof kf||m instanceof Nf)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof Nf&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(c){for(const m in this.binders){const y=this.binders[m];(y instanceof jf||y instanceof kf||y instanceof Nf)&&y.upload(c)}this.updatePaintBuffers()}destroy(){for(const c in this.binders){const m=this.binders[c];(m instanceof jf||m instanceof kf||m instanceof Nf)&&m.destroy()}}}class Sm{constructor(c,m,y=()=>!0){this.programConfigurations={};for(const b of c)this.programConfigurations[b.id]=new Yg(b,m,y);this.needsUpload=!1,this._featureMap=new G_,this._featureMapWithoutIds=new G_,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(c,m,y,b,A,I,O,z,q){for(const X in this.programConfigurations)this.programConfigurations[X].populatePaintArrays(c,m,b,A,I,O,z,q);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,b,A,I,O,z){for(const q of y)this.needsUpload=this.programConfigurations[q.id].updatePaintArrays(c,this._featureMap,this._featureMapWithoutIds,m,q,b,A,I,O||0,z)||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 _ce={"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 bce(p,c){return _ce[p]||[p.replace(`${c}-`,"").replace(/-/g,"_")]}const wce={"line-pattern":{source:ou,composite:ou},"fill-pattern":{source:ou,composite:ou},"fill-extrusion-pattern":{source:ou,composite:ou},"line-dasharray":{source:my,composite:my}},jce={color:{source:_p,composite:Kg},number:{source:bf,composite:_p}};function xT(p,c,m){const y=wce[p];return y&&y[m]||jce[c][m]}xr(Q_,"ConstantBinder"),xr(rv,"PatternConstantBinder"),xr(jf,"SourceExpressionBinder"),xr(Nf,"PatternCompositeBinder"),xr(kf,"CompositeExpressionBinder"),xr(Yg,"ProgramConfiguration",{omit:["_buffers"]}),xr(Sm,"ProgramConfigurationSet");const ed=Hs/Math.PI/2,zh=5,GS=6,kce=16383,nv=64,yT=[nv,32,16],Bh=-ed,$h=ed;function fy(p,c,m,y=ed){return m=Or(m),[p*Math.sin(m)*y,-c*y,p*Math.cos(m)*y]}function av(p,c,m){return fy(Math.cos(Or(p)),Math.sin(Or(p)),c,m)}const N=63710088e-1,u=2*Math.PI*N;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(Qe(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,b=c.lat*m,A=Math.sin(y)*Math.sin(b)+Math.cos(y)*Math.cos(b)*Math.cos((c.lng-this.lng)*m);return N*Math.acos(Math.min(A,1))}toBounds(c=0){const m=360*c/40075017,y=m/Math.cos(Math.PI/180*this.lat);return new C({lng:this.lng-y,lat:this.lat-m},{lng:this.lng+y,lat:this.lat+m})}toEcef(c){return av(this.lat,this.lng,ed+c*ed/N)}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 C{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 b,A;if(c instanceof x)b=c,A=c;else{if(!(c instanceof C))return Array.isArray(c)?c.length===4||c.every(Array.isArray)?this.extend(C.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(b=c._sw,A=c._ne,!b||!A)return this}return m||y?(m.lng=Math.min(b.lng,m.lng),m.lat=Math.min(b.lat,m.lat),y.lng=Math.max(A.lng,y.lng),y.lat=Math.max(A.lat,y.lat)):(this._sw=new x(b.lng,b.lat),this._ne=new x(A.lng,A.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 b=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(b=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=y&&y<=this._ne.lat&&b}static convert(c){if(c)return c instanceof C?c:new C(c)}}const P=0,R=25.5;function F(p){return u*Math.cos(p*Math.PI/180)}function U(p){return(180+p)/360}function K(p){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+p*Math.PI/360)))/360}function te(p,c){return p/F(c)}function re(p){return 360*p-180}function pe(p){return 360/Math.PI*Math.atan(Math.exp((180-360*p)*Math.PI/180))-90}function me(p,c){return p*F(pe(c))}const fe=85.051129;function Ne(p){return Math.cos(Or(_e(p,-fe,fe)))}function we(p,c){const m=_e(c,P,R),y=Math.pow(2,m);return Ne(p)*u/(512*y)}function Re(p){return 1/Math.cos(p*Math.PI/180)}function Le(p,c=0){const m=Math.exp(Math.PI*(1-(p.y+c/Hs)/(1<=z?(nt(p,c,m,q,X,A,Q,O,z),nt(p,q,X,y,b,Q,I,O,z)):p.push(I)}function Xe(p,c,m){let y=p[0],b=y.x,A=y.y;c(y);const I=[y];for(let O=1;Op.x+1||yp.y+1)&&cr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),p}function At(p,c,m){const y=p.loadGeometry(),b=p.extent,A=Hs/b;if(c&&m&&m.projection.isReprojectedInTileSpace){const I=1<{const ae=re((c.x+se.x/b)/I),le=pe((c.y+se.y/b)/I),xe=X.project(ae,le);se.x=(xe.x*O-z)*b,se.y=(xe.y*O-q)*b};for(let se=0;se=b||le.y<0||le.y>=b||(Q(le),ae.push(le));y[se]=ae}}for(const I of y)for(const O of I)ht(O,A);return y}function Ut(p,c){return{type:p.type,id:p.id,properties:p.properties,geometry:c?At(p):[]}}class Bt{constructor(c,m,y,b,A){this.properties={},this.extent=y,this.type=0,this.id=void 0,this._pbf=c,this._geometry=-1,this._keys=b,this._values=A,c.readFields(ts,this,m)}loadGeometry(){const c=this._pbf;c.pos=this._geometry;const m=c.readVarint()+c.pos,y=[];let b,A=1,I=0,O=0,z=0;for(;c.pos>3}if(I--,A===1||A===2)O+=c.readSVarint(),z+=c.readSVarint(),A===1&&(b&&y.push(b),b=[]),b&&b.push(new cs(O,z));else{if(A!==7)throw new Error(`unknown command ${A}`);b&&b.push(b[0].clone())}}return b&&y.push(b),y}bbox(){const c=this._pbf;c.pos=this._geometry;const m=c.readVarint()+c.pos;let y=1,b=0,A=0,I=0,O=1/0,z=-1/0,q=1/0,X=-1/0;for(;c.pos>3}if(b--,y===1||y===2)A+=c.readSVarint(),I+=c.readSVarint(),Az&&(z=A),IX&&(X=I);else if(y!==7)throw new Error(`unknown command ${y}`)}return[O,q,z,X]}toGeoJSON(c,m,y){const b=this.extent*Math.pow(2,y),A=this.extent*c,I=this.extent*m,O=this.loadGeometry();function z(se){return[360*(se.x+A)/b-180,360/Math.PI*Math.atan(Math.exp((1-2*(se.y+I)/b)*Math.PI))-90]}function q(se){return se.map(z)}let X;if(this.type===1){const se=[];for(const le of O)se.push(le[0]);const ae=q(se);X=se.length===1?{type:"Point",coordinates:ae[0]}:{type:"MultiPoint",coordinates:ae}}else if(this.type===2){const se=O.map(q);X=se.length===1?{type:"LineString",coordinates:se[0]}:{type:"MultiLineString",coordinates:se}}else{if(this.type!==3)throw new Error("unknown feature type");{const se=function(le){const xe=le.length;if(xe<=1)return[le];const Me=[];let Ce,ze;for(let Ve=0;Ve=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 Bt(this._pbf,m,this.extent,this._keys,this._values)}}function Ds(p,c,m){p===15?c.version=m.readVarint():p===1?c.name=m.readString():p===5?c.extent=m.readVarint():p===2?c._features.push(m.pos):p===3?c._keys.push(m.readString()):p===4&&c._values.push(function(y){let b=null;const A=y.readVarint()+y.pos;for(;y.pos>3;b=I===1?y.readString():I===2?y.readFloat():I===3?y.readDouble():I===4?y.readVarint64():I===5?y.readVarint():I===6?y.readSVarint():I===7?y.readBoolean():null}if(b==null)throw new Error("unknown feature value");return b}(m))}class Yt{constructor(c,m){this.layers=c.readFields(Pt,{},m)}}function Pt(p,c,m){if(p===3){const y=new ms(m,m.readVarint()+m.pos);y.length&&(c[y.name]=y)}}const is="3d_elevation_id",es="level";class ks{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,b){const A=this.feature.properties.hasOwnProperty(c)?+this.feature.properties[c]:void 0;return this._valid&&A!==void 0&&!Number.isNaN(A)?y(b?b(A):A):m&&(this._valid=!1),this}}class Gs{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 dr=new Gs((p,c,m)=>p.reset(c).require(is,y=>{m.id=y}).optional("fixed_height_relative",y=>{m.constantHeight=y},Os.decodeRelativeHeight).geometry(y=>{m.bounds=y},ff).success(),(p,c,m)=>p.reset(c).require(is,y=>{m.id=y}).require("elevation_idx",y=>{m.idx=y}).require("extent",y=>{m.extent=y}).require("height_relative",y=>{m.height=y},Os.decodeRelativeHeight).geometry(y=>{m.position=y},Os.getPoint).success()),qs=new Gs((p,c,m)=>p.reset(c).require(is,y=>{m.id=y}).optional("fixed_height",y=>{m.constantHeight=y},Os.decodeMetricHeight).geometry(y=>{m.bounds=y},ff).success(),(p,c,m)=>p.reset(c).require(is,y=>{m.id=y}).require("elevation_idx",y=>{m.idx=y}).require("extent",y=>{m.extent=y}).require("height",y=>{m.height=y},Os.decodeMetricHeight).geometry(y=>{m.position=y},Os.getPoint).success());class Os{static getPoint(c){return yt(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"?qs:void 0:dr}static parse(c){const m=[],y=[],b=c.length,A=new ks;for(let I=0;I=0);if(A===0)return 0;A!==c.length&&(m=!1)}return m?2:1}function _n(p,c){for(const m of p.projections){const y=hr(c,p.points[0],m.axis);if(m.projection[1]y[1])return 0}return 1}function ia(p,c){let m=0;const y=[0,0,0,0];for(let I=0;I=0&&m++;var b,A;return m}class Oa{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=Nr.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 b=[0,-y[2],y[1]],A=[y[2],0,-y[0]];this.projections.push({axis:b,projection:hr(this.points,this.points[0],b)}),this.projections.push({axis:A,projection:hr(this.points,this.points[0],A)})}}static fromInvProjectionMatrix(c,m,y,b){const A=Math.pow(2,y),I=[[-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(q=>{const X=ut([],q,c),Q=1/X[3]/m*A;return(se=X)[0]=(ae=X)[0]*(le=[Q,Q,b?1/X[3]:Q,Q])[0],se[1]=ae[1]*le[1],se[2]=ae[2]*le[2],se[3]=ae[3]*le[3],se;var se,ae,le}),O=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(q=>{const X=De([],wt([],ke([],I[q[0]],I[q[1]]),ke([],I[q[2]],I[q[1]]))),Q=-Ge(X,I[q[1]]);return X.concat(Q)}),z=[];for(let q=0;qq[1]||q[0]>z[1])return 0}return 1}containsPoint(c){for(const m of this.planes){const y=m[3];if(Ge([m[0],m[1],m[2]],c)+y<0)return!1}return!0}}class Nr{static fromPoints(c){const m=[1/0,1/0,1/0],y=[-1/0,-1/0,-1/0];for(const b of c)ve(m,m,b),ye(y,y,b);return new Nr(m,y)}static fromTileIdAndHeight(c,m,y){const b=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])]}}xr(Nr,"Aabb");class Ca{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],b=-m[0],A=(c.extent+1)*this.metersToTile;return[new cs(Math.trunc(c.position[0]+y*A),Math.trunc(c.position[1]+b*A)),new cs(Math.trunc(c.position[0]-y*A),Math.trunc(c.position[1]-b*A))]}next(){this.index++}valid(){return this.index{return O.a0?Se(z,z,1/q):ue(z,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,b=0;const[A,I,O,z,q,X,Q]=this._tmpVec2;bs(Q,c.x,c.y);const se=new wr(Q,null);for(let ae=0;ae0?Ia(z,O)/Je:0,mt=_e(vt,0,1),St=Math.abs((vt-mt)*this.edgeProps[ae].len);Br(q,Q,Me),bs(X,xe[1],-xe[0]);const It=St+Math.abs(Ia(q,X));It=0;--I){const O=this.edges[I].a,z=this.edges[I].b,{position:q,height:X,extent:Q}=this.vertices[O],{position:se,height:ae,extent:le}=this.vertices[z],xe=this.vertexProps[O].dir,Me=this.vertexProps[z].dir;if(ue(m,q[0]/c,q[1]/c,X),ue(y,se[0]/c,se[1]/c,ae),ue(b,xe[1],-xe[0],0),Se(b,b,Q),ue(A,Me[1],-Me[0],0),Se(A,A,le),this.distSqLines(oe(m[0]+.5*b[0],m[1]+.5*b[1],m[2]+.5*b[2]),oe(y[0]-.5*A[0],y[1]-.5*A[1],y[2]-.5*A[2]),oe(m[0]-.5*b[0],m[1]-.5*b[1],m[2]-.5*b[2]),oe(y[0]+.5*A[0],y[1]+.5*A[1],y[2]+.5*A[2]))<=.0025000000000000005)continue;const Ce=this.vertices.length,ze=gr(fr(),q,se);this.vertices.push({position:na(ze,ze,.5),height:.5*(X+ae),extent:.5*(Q+le)});const Ve=gr(fr(),xe,Me);this.vertexProps.push({dir:go(Ve,Ve)}),this.edges.splice(I,1),this.edgeProps.splice(I,1),this.edges.push({a:O,b:Ce}),this.edges.push({a:Ce,b:z});const Je=Br(fr(),this.vertices[Ce].position,q),vt=za(Je),mt={vec:Je,dir:na(fr(),Je,1/vt),len:vt};this.edgeProps.push(mt),this.edgeProps.push(mt)}}distSqLines(c,m,y,b){const A=ge(ie(),m,c),I=ge(ie(),b,y),O=ge(ie(),c,y),z=Ge(A,A),q=Ge(A,I),X=Ge(A,O),Q=Ge(I,I),se=Ge(I,O),ae=z*Q-q*q;if(ae===0)return Ee(Ie(A,y,b,Ge(O,I)/Ge(I,I)),c);const le=(z*se-q*X)/ae;return Ee(Ie(A,c,m,(q*se-X*Q)/ae),Ie(I,y,b,le))}}class Ba{static parseFrom(c,m){const y=Os.parse(c);if(!y)return[];let{vertices:b,features:A}=y;const I=1/Le(m);A.sort((X,Q)=>X.id-Q.id),b.sort((X,Q)=>X.id-Q.id||X.idx-Q.idx),b=b.filter((X,Q,se)=>Q===se.findIndex(ae=>ae.id===X.id&&ae.idx===X.idx));const O=new Array;let z=0;const q=b.length;for(const X of A){if(X.constantHeight){O.push(new un(X.id,X.bounds,X.constantHeight));continue}for(;z!==q&&b[z].idb.id===y)}}class ii{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)*Hs,this.yOffset=(c.y*this.zScale-m.y)*Hs)}constantElevation(c,m){if(c.constantHeight!=null)return this.computeBiasedHeight(c.constantHeight,m)}pointElevation(c,m,y){const b=this.constantElevation(m,y);return b??(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*Pe(0,m,c>=0?c:Math.abs(.5*c))}}xr(un,"ElevationFeature");class Ja{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 Gg,this.indexArray=new ol,this.segments=new ro,this.programConfigurations=new Sm(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 bf),this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,b){}populate(c,m,y,b){const A=this.layers[0],I=[];let O=null;A.type==="circle"&&(O=A.layout.get("circle-sort-key"));for(const{feature:q,id:X,index:Q,sourceLayerIndex:se}of c){const ae=this.layers[0]._featureFilter.needGeometry,le=Ut(q,ae);if(!this.layers[0]._featureFilter.filter(new Si(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),le,y))continue;const xe=O?O.evaluate(le,{},y):void 0,Me={id:X,properties:q.properties,type:q.type,sourceLayerIndex:se,index:Q,geometry:ae?le.geometry:At(q,y,b),patterns:{},sortKey:xe};I.push(Me)}O&&I.sort((q,X)=>q.sortKey-X.sortKey);let z=null;b.projection.name==="globe"&&(this.globeExtVertexArray=new AS,z=b.projection);for(const q of I){const{geometry:X,index:Q,sourceLayerIndex:se}=q,ae=c[Q].feature;this.addFeature(q,X,Q,m.availableImages,y,z,m.brightness,m.elevationFeatures),m.featureIndex.insert(ae,X,Q,se,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(c,m,y,b,A,I,O){this.programConfigurations.updatePaintArrays(c,m,A,y,b,I,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,mD.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,pD.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,pce.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,b,A,I,O,z){let q;this.elevationMode!=="none"&&(q=Ba.getElevationFeature(c,z));for(const X of m)for(const Q of X){const se=Q.x,ae=Q.y;if(se<0||se>=Hs||ae<0||ae>=Hs)continue;if(I){const Me=I.projectTilePoint(se,ae,A),Ce=I.upVector(A,se,ae);this.addGlobeExtVertex(Me,Ce),this.addGlobeExtVertex(Me,Ce),this.addGlobeExtVertex(Me,Ce),this.addGlobeExtVertex(Me,Ce)}const le=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,c.sortKey),xe=le.vertexLength;if(this.addCircleVertex(se,ae,-1,-1),this.addCircleVertex(se,ae,1,-1),this.addCircleVertex(se,ae,1,1),this.addCircleVertex(se,ae,-1,1),this.elevationMode!=="none"){const Me=q?q.pointElevation(new cs(se,ae)):0;this.hasElevation=this.hasElevation||Me!==0;for(let Ce=0;Ce<4;Ce++)this.elevatedLayoutVertexArray.emplaceBack(Me)}this.indexArray.emplaceBack(xe,xe+1,xe+2),this.indexArray.emplaceBack(xe,xe+2,xe+3),le.vertexLength+=4,le.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,y,{},b,A,O,void 0,this.worldview)}addCircleVertex(c,m,y,b){this.layoutVertexArray.emplaceBack(2*c+(y+1)/2,2*m+(b+1)/2)}addGlobeExtVertex(c,m){this.globeExtVertexArray.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function Na(p,c){for(let m=0;m1){if($i(p,c))return!0;for(let y=0;y1?m:m.sub(c)._mult(b)._add(c))}function no(p,c){let m,y,b,A=!1;for(let I=0;Ic.y!=b.y>c.y&&c.x<(b.x-y.x)*(c.y-y.y)/(b.y-y.y)+y.x&&(A=!A)}return A}function pi(p,c){let m=!1;for(let y=0,b=p.length-1;yc.y!=I.y>c.y&&c.x<(I.x-A.x)*(c.y-A.y)/(I.y-A.y)+A.x&&(m=!m)}return m}function $d(p,c,m,y,b){for(const I of p)if(c<=I.x&&m<=I.y&&y>=I.x&&b>=I.y)return!0;const A=[new cs(c,m),new cs(c,b),new cs(y,b),new cs(y,m)];if(p.length>2){for(const I of A)if(pi(p,I))return!0}for(let I=0;Ib.x&&c.x>b.x||p.yb.y&&c.y>b.y)return!1;const A=jn(p,c,m[0]);return A!==jn(p,c,m[1])||A!==jn(p,c,m[2])||A!==jn(p,c,m[3])}function cl(p,c,m,y,b,A){let I=c.y-p.y,O=p.x-c.x;if(A=A||0){const z=I*I+O*O;if(z===0)return!0;const q=Math.sqrt(z);I/=q,O/=q}return!((m.x-p.x)*I+(m.y-p.y)*O-A<0||(y.x-p.x)*I+(y.y-p.y)*O-A<0||(b.x-p.x)*I+(b.y-p.y)*O-A<0)}function td(p,c,m,y,b,A,I){return!(cl(p,c,y,b,A,I)||cl(c,m,y,b,A,I)||cl(m,p,y,b,A,I)||cl(y,b,p,c,m,I)||cl(b,A,p,c,m,I)||cl(A,y,p,c,m,I))}function sd(p,c,m){const y=c.paint.get(p).value;return y.kind==="constant"?y.value:m.programConfigurations.get(c.id).getMaxValue(p)}function gc(p){return Math.sqrt(p[0]*p[0]+p[1]*p[1])}function nh(p,c,m,y,b){if(!c[0]&&!c[1])return p;const A=cs.convert(c)._mult(b);m==="viewport"&&A._rotate(-y);const I=[];for(let O=0;O>m&&c.y===this.y>>m}url(c,m){const y=function(A,I,O){var z=Mo(256*A,256*(I=Math.pow(2,O)-I-1),O),q=Mo(256*(A+1),256*(I+1),O);return z[0]+","+z[1]+","+q[0]+","+q[1]}(this.x,this.y,this.z),b=function(A,I,O){let z,q="";for(let X=A;X>0;X--)z=1<this.canonical.z?new uo(c,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new uo(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 ao(this.wrap*+m,c,this.canonical.z,this.canonical.x,this.canonical.y);{const y=this.canonical.z-c;return ao(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 uo(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,b=2*this.canonical.y;return[new uo(m,this.wrap,m,y,b),new uo(m,this.wrap,m,y+1,b),new uo(m,this.wrap,m,y,b+1),new uo(m,this.wrap,m,y+1,b+1)]}isLessThan(c){return this.wrapc.wrap)&&(this.overscaledZc.overscaledZ)&&(this.canonical.xc.canonical.x)&&this.canonical.y{let c=p.canonical.x-1,m=p.wrap;return c<0&&(c=(1<{let c=p.canonical.x+1,m=p.wrap;return c===1<new uo(p.overscaledZ,p.wrap,p.canonical.z,p.canonical.x,(p.canonical.y===0?1<new uo(p.overscaledZ,p.wrap,p.canonical.z,p.canonical.x,p.canonical.y===(1<1?null:function(y,b,A,I){const O=Math.sin(A);return y*(Math.sin((1-I)*A)/O)+b*(Math.sin(I*A)/O)}(p.a[c],p.b[c],p.angle,_e(m,0,1))+p.center[c]}function Mm(p){if(p.z<=1)return Sf[p.z+2*p.y+p.x];const c=Nce(fD(p));return Nr.fromPoints(c)}function Mf(p,c,m){return Se(p,p,1-m),Ke(p,p,c,m)}function Owe(p,c,m){for(const y of p)st(y,y,c),Se(y,y,m)}function Rwe(p,c,m,y){const b=c/p.worldSize,A=p.globeMatrix;if(m.z<=1){const Ot=Mm(m).getCorners();return Owe(Ot,A,b),Nr.fromPoints(Ot)}const I=fD(m,y),O=Nce(I,ed+wp(p._tileCoverLift));Owe(O,A,b);const z=Number.MAX_VALUE,q=[-z,-z,-z],X=[z,z,z];if(I.contains(p.center)){for(const qt of O)ve(X,X,qt),ye(q,q,qt);q[2]=0;const Ot=p.point,ns=[Ot.x*b,Ot.y*b,0];return ve(X,X,ns),ye(q,q,ns),new Nr(X,q)}if(p._tileCoverLift>0){for(const Ot of O)ve(X,X,Ot),ye(q,q,Ot);return new Nr(X,q)}const Q=[A[12]*b,A[13]*b,A[14]*b],se=I.getCenter(),ae=_e(p.center.lat,-fe,fe),le=_e(se.lat,-fe,fe),xe=U(p.center.lng),Me=K(ae);let Ce=xe-U(se.lng);const ze=Me-K(le);Ce>.5?Ce-=1:Ce<-.5&&(Ce+=1);let Ve=0;Math.abs(Ce)>Math.abs(ze)?Ve=Ce>=0?1:3:(Ve=ze>=0?0:2,Ke(Q,Q,[A[4]*b,A[5]*b,A[6]*b],-Math.sin(Or(ze>=0?I.getSouth():I.getNorth()))*ed));const Je=O[Ve],vt=O[(Ve+1)%4],mt=new Xg(Je,vt,Q),St=[Cf(mt,0)||Je[0],Cf(mt,1)||Je[1],Cf(mt,2)||Je[2]],It=lv(p.zoom);if(It>0){const Ot=function({x:qt,y:us,z:gs},xs,As,Is,Ns){const Ms=1/(1<.5?Rs=-1:Mr<-.5&&(Rs=1),ds=((ds+Rs)*xs-(Is*=xs))*As+Is,as=((as+Rs)*xs-Is)*As+Is,Ts=(Ts*xs-(Ns*=xs))*As+Ns,Ws=(Ws*xs-Ns)*As+Ns,[[ds,Ws,0],[as,Ws,0],[as,Ts,0],[ds,Ts,0]]}(m,c,p._pixelsPerMercatorPixel,xe,Me);for(let qt=0;qtMath.PI/2*1.01}const Uwe=Or(85),sQe=Math.cos(Uwe),rQe=Math.sin(Uwe),nQe=j(),qwe=p=>{const c=[];return p.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),p.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function Vwe(p,c,m,y,b,A,I,O,z){if(A&&p.queryGeometry.isAboveHorizon)return!1;A&&(z*=p.pixelToTileUnitsFactor);const q=p.tileID.canonical,X=m.projection.upVectorScale(q,m.center.lat,m.worldSize).metersToTile;for(const Q of c)for(const se of Q){const ae=se.add(O),le=b&&m.elevation?m.elevation.exaggeration()*b.getElevationAt(ae.x,ae.y,!0):0,xe=m.projection.projectTilePoint(ae.x,ae.y,q);if(le>0){const Ve=m.projection.upVector(q,ae.x,ae.y);xe.x+=Ve[0]*X*le,xe.y+=Ve[1]*X*le,xe.z+=Ve[2]*X*le}const Me=A?ae:aQe(xe.x,xe.y,xe.z,y),Ce=A?p.tilespaceRays.map(Ve=>oQe(Ve,le)):p.queryGeometry.screenGeometry,ze=ut([],[xe.x,xe.y,xe.z,1],y);if(!I&&A?z*=ze[3]/m.cameraToCenterDistance:I&&!A&&(z*=m.cameraToCenterDistance/ze[3]),A){const Ve=pe((se.y/Hs+q.y)/(1<p.width||b.height>p.height||m.x>p.width-b.width||m.y>p.height-b.height)throw new RangeError("out of range source coordinates for image copy");if(b.width>c.width||b.height>c.height||y.x>c.width-b.width||y.y>c.height-b.height)throw new RangeError("out of range destination coordinates for image copy");const z=p.data,q=c.data,X=A===4&&O;for(let Q=0;Q{c[p.evaluationKey]=z;const q=p.expression.evaluate(c),X=q?q.toNonPremultipliedRenderColor(null):null;X&&(b.data[I+O+0]=Math.floor(255*X.r),b.data[I+O+1]=Math.floor(255*X.g),b.data[I+O+2]=Math.floor(255*X.b),b.data[I+O+3]=Math.floor(255*X.a))};if(p.clips)for(let I=0,O=0;I80*m){O=p[0],z=p[1];let X=O,Q=z;for(let se=m;seX&&(X=ae),le>Q&&(Q=le)}q=Math.max(X-O,Q-z),q=q!==0?32767/q:0}return bT(A,I,m,O,z,q,0),I}function e2e(p,c,m,y,b){let A;if(b===function(I,O,z,q){let X=0;for(let Q=O,se=z-q;Q0)for(let I=c;I=c;I-=y)A=n2e(I/y|0,p[I],p[I+1],A);return A&&ZS(A,A.next)&&(kT(A),A=A.next),A}function tb(p,c){if(!p)return p;c||(c=p);let m,y=p;do if(m=!1,y.steiner||!ZS(y,y.next)&&Ql(y.prev,y,y.next)!==0)y=y.next;else{if(kT(y),y=c=y.prev,y===y.next)break;m=!0}while(m||y!==c);return c}function bT(p,c,m,y,b,A,I){if(!p)return;!I&&A&&function(z,q,X,Q){let se=z;do se.z===0&&(se.z=Ace(se.x,se.y,q,X,Q)),se.prevZ=se.prev,se.nextZ=se.next,se=se.next;while(se!==z);se.prevZ.nextZ=null,se.prevZ=null,function(ae){let le,xe=1;do{let Me,Ce=ae;ae=null;let ze=null;for(le=0;Ce;){le++;let Ve=Ce,Je=0;for(let mt=0;mt0||vt>0&&Ve;)Je!==0&&(vt===0||!Ve||Ce.z<=Ve.z)?(Me=Ce,Ce=Ce.nextZ,Je--):(Me=Ve,Ve=Ve.nextZ,vt--),ze?ze.nextZ=Me:ae=Me,Me.prevZ=ze,ze=Me;Ce=Ve}ze.nextZ=null,xe*=2}while(le>1)}(se)}(p,y,b,A);let O=p;for(;p.prev!==p.next;){const z=p.prev,q=p.next;if(A?mQe(p,y,b,A):hQe(p))c.push(z.i,p.i,q.i),kT(p),p=q.next,O=q.next;else if((p=q)===O){I?I===1?bT(p=pQe(tb(p),c),c,m,y,b,A,2):I===2&&fQe(p,c,m,y,b,A):bT(tb(p),c,m,y,b,A,1);break}}}function hQe(p){const c=p.prev,m=p,y=p.next;if(Ql(c,m,y)>=0)return!1;const b=c.x,A=m.x,I=y.x,O=c.y,z=m.y,q=y.y,X=Math.min(b,A,I),Q=Math.min(O,z,q),se=Math.max(b,A,I),ae=Math.max(O,z,q);let le=y.next;for(;le!==c;){if(le.x>=X&&le.x<=se&&le.y>=Q&&le.y<=ae&&wT(b,O,A,z,I,q,le.x,le.y)&&Ql(le.prev,le,le.next)>=0)return!1;le=le.next}return!0}function mQe(p,c,m,y){const b=p.prev,A=p,I=p.next;if(Ql(b,A,I)>=0)return!1;const O=b.x,z=A.x,q=I.x,X=b.y,Q=A.y,se=I.y,ae=Math.min(O,z,q),le=Math.min(X,Q,se),xe=Math.max(O,z,q),Me=Math.max(X,Q,se),Ce=Ace(ae,le,c,m,y),ze=Ace(xe,Me,c,m,y);let Ve=p.prevZ,Je=p.nextZ;for(;Ve&&Ve.z>=Ce&&Je&&Je.z<=ze;){if(Ve.x>=ae&&Ve.x<=xe&&Ve.y>=le&&Ve.y<=Me&&Ve!==b&&Ve!==I&&wT(O,X,z,Q,q,se,Ve.x,Ve.y)&&Ql(Ve.prev,Ve,Ve.next)>=0||(Ve=Ve.prevZ,Je.x>=ae&&Je.x<=xe&&Je.y>=le&&Je.y<=Me&&Je!==b&&Je!==I&&wT(O,X,z,Q,q,se,Je.x,Je.y)&&Ql(Je.prev,Je,Je.next)>=0))return!1;Je=Je.nextZ}for(;Ve&&Ve.z>=Ce;){if(Ve.x>=ae&&Ve.x<=xe&&Ve.y>=le&&Ve.y<=Me&&Ve!==b&&Ve!==I&&wT(O,X,z,Q,q,se,Ve.x,Ve.y)&&Ql(Ve.prev,Ve,Ve.next)>=0)return!1;Ve=Ve.prevZ}for(;Je&&Je.z<=ze;){if(Je.x>=ae&&Je.x<=xe&&Je.y>=le&&Je.y<=Me&&Je!==b&&Je!==I&&wT(O,X,z,Q,q,se,Je.x,Je.y)&&Ql(Je.prev,Je,Je.next)>=0)return!1;Je=Je.nextZ}return!0}function pQe(p,c){let m=p;do{const y=m.prev,b=m.next.next;!ZS(y,b)&&s2e(y,m,m.next,b)&&jT(y,b)&&jT(b,y)&&(c.push(y.i,m.i,b.i),kT(m),kT(m.next),m=p=b),m=m.next}while(m!==p);return tb(m)}function fQe(p,c,m,y,b,A){let I=p;do{let O=I.next.next;for(;O!==I.prev;){if(I.i!==O.i&&_Qe(I,O)){let z=r2e(I,O);return I=tb(I,I.next),z=tb(z,z.next),bT(I,c,m,y,b,A,0),void bT(z,c,m,y,b,A,0)}O=O.next}I=I.next}while(I!==p)}function gQe(p,c){let m=p.x-c.x;return m===0&&(m=p.y-c.y,m===0)&&(m=(p.next.y-p.y)/(p.next.x-p.x)-(c.next.y-c.y)/(c.next.x-c.x)),m}function xQe(p,c){const m=function(b,A){let I=A;const O=b.x,z=b.y;let q,X=-1/0;if(ZS(b,I))return I;do{if(ZS(b,I.next))return I.next;if(z<=I.y&&z>=I.next.y&&I.next.y!==I.y){const xe=I.x+(z-I.y)*(I.next.x-I.x)/(I.next.y-I.y);if(xe<=O&&xe>X&&(X=xe,q=I.x=I.x&&I.x>=se&&O!==I.x&&t2e(zq.x||I.x===q.x&&yQe(q,I)))&&(q=I,le=xe)}I=I.next}while(I!==Q);return q}(p,c);if(!m)return c;const y=r2e(m,p);return tb(y,y.next),tb(m,m.next)}function yQe(p,c){return Ql(p.prev,p,c.prev)<0&&Ql(c.next,p,p.next)<0}function Ace(p,c,m,y,b){return(p=1431655765&((p=858993459&((p=252645135&((p=16711935&((p=(p-m)*b|0)|p<<8))|p<<4))|p<<2))|p<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-y)*b|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function vQe(p){let c=p,m=p;do(c.x=(p-I)*(A-O)&&(p-I)*(y-O)>=(m-I)*(c-O)&&(m-I)*(A-O)>=(b-I)*(y-O)}function wT(p,c,m,y,b,A,I,O){return!(p===I&&c===O)&&t2e(p,c,m,y,b,A,I,O)}function _Qe(p,c){return p.next.i!==c.i&&p.prev.i!==c.i&&!function(m,y){let b=m;do{if(b.i!==m.i&&b.next.i!==m.i&&b.i!==y.i&&b.next.i!==y.i&&s2e(b,b.next,m,y))return!0;b=b.next}while(b!==m);return!1}(p,c)&&(jT(p,c)&&jT(c,p)&&function(m,y){let b=m,A=!1;const I=(m.x+y.x)/2,O=(m.y+y.y)/2;do b.y>O!=b.next.y>O&&b.next.y!==b.y&&I<(b.next.x-b.x)*(O-b.y)/(b.next.y-b.y)+b.x&&(A=!A),b=b.next;while(b!==m);return A}(p,c)&&(Ql(p.prev,p,c.prev)||Ql(p,c.prev,c))||ZS(p,c)&&Ql(p.prev,p,p.next)>0&&Ql(c.prev,c,c.next)>0)}function Ql(p,c,m){return(c.y-p.y)*(m.x-c.x)-(c.x-p.x)*(m.y-c.y)}function ZS(p,c){return p.x===c.x&&p.y===c.y}function s2e(p,c,m,y){const b=vD(Ql(p,c,m)),A=vD(Ql(p,c,y)),I=vD(Ql(m,y,p)),O=vD(Ql(m,y,c));return b!==A&&I!==O||!(b!==0||!yD(p,m,c))||!(A!==0||!yD(p,y,c))||!(I!==0||!yD(m,p,y))||!(O!==0||!yD(m,c,y))}function yD(p,c,m){return c.x<=Math.max(p.x,m.x)&&c.x>=Math.min(p.x,m.x)&&c.y<=Math.max(p.y,m.y)&&c.y>=Math.min(p.y,m.y)}function vD(p){return p>0?1:p<0?-1:0}function jT(p,c){return Ql(p.prev,p,p.next)<0?Ql(p,c,p.next)>=0&&Ql(p,p.prev,c)>=0:Ql(p,c,p.prev)<0||Ql(p,p.next,c)<0}function r2e(p,c){const m=Ece(p.i,p.x,p.y),y=Ece(c.i,c.x,c.y),b=p.next,A=c.prev;return p.next=c,c.prev=p,m.next=b,b.prev=m,y.next=m,m.prev=y,A.next=y,y.prev=A,y}function n2e(p,c,m,y){const b=Ece(p,c,m);return y?(b.next=y.next,b.prev=y,y.next.prev=b,y.next=b):(b.prev=b,b.next=b),b}function kT(p){p.next.prev=p.prev,p.prev.next=p.next,p.prevZ&&(p.prevZ.nextZ=p.nextZ),p.nextZ&&(p.nextZ.prevZ=p.prevZ)}function Ece(p,c,m){return{i:p,x:c,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function NT(p,c){const m=p.length;if(m<=1)return[p];const y=[];let b,A;for(let I=0;I1)for(let I=0;I=Hs&&m>=Hs}static evaluate(c){if(c.length===0)return new gy;let m=[];for(const z of c)m.push(...z.portals);if(m.length===0)return new gy;for(const z of m){const q=z.va,X=z.vb;(gy.isOnBorder(q.x,X.x)||gy.isOnBorder(q.y,X.y))&&(z.type="border")}const y=m.filter(z=>z.type!=="unevaluated"),b=m.filter(z=>z.type==="unevaluated");if(b.length===0)return new gy;b.sort((z,q)=>z.hash===q.hash?z.isTunnel===q.isTunnel?0:z.isTunnel?-1:1:z.hashz.hashA!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new Sm(m,{zoom:y,lut:b},A=>A!=="fill-bridge-guard-rail-color")}addVertices(c,m){const y=this.unevalVertices.length;for(let b=0;b=A.min.x&&Q.x<=A.max.x&&Q.y>=A.min.y&&Q.y<=A.max.y||se.x>=A.min.x&&se.x<=A.max.x&&se.y>=A.min.y&&se.y<=A.max.y||$c(Q,se,O))||this.isOnBorder(Q.x,se.x)||this.isOnBorder(Q.y,se.y))continue;const ae=ah.computeEdgeHash(this.unevalVertices[q],this.unevalVertices[X]);let le,xe=this.vertexHashLookup.get(ah.computePosHash(Q));xe!=null?le=xe.next:(xe=this.vertexHashLookup.get(ah.computePosHash(se)),le=xe!=null?xe.prev:ae),this.unevalEdges.push({polygonIdx:c,a:q,b:X,hash:ae,portalHash:le,isTunnel:b,type:"unevaluated",featureInfo:I})}}addPortalCandidates(c,m,y,b,A){if(m.length===0)return;this.portalPolygons.add(c,{geometry:m,zLevel:A});const I=m[0];this.vertexHashLookup.clear();let O=ah.computeEdgeHash(I[I.length-2],I[I.length-1]);for(let z=0;z({vertexOffset:0,primitiveOffset:this.indexArray.length}),y=se=>{se.primitiveLength=this.indexArray.length-se.primitiveOffset},b=new wQe(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const A=m(),I=m(),O=m(),z=(se,ae)=>{se.sort((xe,Me)=>xe.type===ae&&Me.type!==ae?-1:xe.type!==ae&&Me.type===ae?1:0);const le=se.findIndex(xe=>xe.type!==ae);return le>=0?le:se.length};let q=0;this.unevalEdges.length>0&&(q=z(this.unevalEdges,"none"),this.constructBridgeStructures(b,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:q},this.tileToMeters)),y(O);const X=m(),Q=m();if(this.unevalEdges.length>0){const se=this.unevalEdges.splice(q),ae=z(se,"tunnel")+q;this.unevalEdges.push(...se),this.constructTunnelStructures(b,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:q},{min:q,max:ae})}y(X),b.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),y(Q),b.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),y(I),b.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),y(A),this.maskSegments=ro.simpleSegment(0,Q.primitiveOffset,0,Q.primitiveLength),this.depthSegments=ro.simpleSegment(0,I.primitiveOffset,0,I.primitiveLength),this.renderableBridgeSegments=ro.simpleSegment(0,O.primitiveOffset,0,O.primitiveLength),this.renderableTunnelSegments=ro.simpleSegment(0,X.primitiveOffset,0,X.primitiveLength),this.shadowCasterSegments=ro.simpleSegment(0,A.primitiveOffset,0,A.primitiveLength)}update(c,m,y,b,A,I,O,z){this.bridgeProgramConfigurations.updatePaintArrays(c,m,A,y,b,I,O,z),this.tunnelProgramConfigurations.updatePaintArrays(c,m,A,y,b,I,O,z)}upload(c){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=c.createVertexBuffer(this.vertexPositions,dQe.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,uQe.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,b,A){const I=(O,z)=>{for(let q=0;que(As,m[Is].x,m[Is].y,y[Is]*z),Q=ie(),se=ie(),ae=ie(),le=ie(),xe=ie(),Me=(As,Is)=>{const Ns=O.get(ah.computePosHash(m[Is])),Ms=Ns.from,ds=Ns.to;if(!Ms||!ds)return;X(Q,Ms),X(se,Is),X(ae,ds),et(le),Ye(Q,se)||(ke(xe,se,Q),De(le,xe)),Ye(ae,se)||(ke(xe,ae,se),ce(le,le,De(xe,xe)));const as=Fe(le);return as>0?Se(As,le,1/as):void 0};let Ce=Number.POSITIVE_INFINITY;this.sortSubarray(b,A.min,A.max,(As,Is)=>As.featureInfo.featureIndex-Is.featureInfo.featureIndex);const ze=ie(),Ve=ie(),Je=ie(),vt=ie(),mt=ie(),St=ie(),It=ie(),Ot=ie(),ns=ie(),qt=[ie(),ie(),ie(),ie()],us=[ie(),ie(),ie(),ie()],gs=[{coord:new cs(0,0),height:0},{coord:new cs(0,0),height:0}],xs=(As,Is)=>As>Is;for(let As=A.min;AsCe.featureInfo.featureIndex-ze.featureInfo.featureIndex;this.sortSubarray(b,A.min,A.max,z),this.sortSubarray(b,I.min,I.max,z);const q=Ce=>De(Ce,Ce),X=[{coord:new cs(0,0),height:0},{coord:new cs(0,0),height:0}],Q=(Ce,ze)=>CeO.hash===z.hash?z.polygonIdx-O.polygonIdx:z.hash>O.hash?1:-1);let y=0,b=0,A=0,I=m[y].polygonIdx;do b++,(b===m.length||m[y].hash!==m[b].hash)&&((b-y==1||m[b-1].polygonIdx!==I)&&(Aq.portalHashX.hash?O++:X.hash>q.portalHash?z++:(q.type=X.type,O++)}}}isOnBorder(c,m){return c<=0&&m<=0||c>=Hs&&m>=Hs}addFeatureSection(c,m,y,b){return c!==m&&(m=c,y.push({featureIndex:c,vertexStart:b.getVertexCount()}),b.clearVertexLookup()),m}sortSubarray(c,m,y,b){const A=c.slice(m,y);A.sort(b),c.splice(m,A.length,...A)}static computeEdgeHash(c,m){return(c.y===m.y&&c.x>m.x||c.y>m.y)&&([c,m]=[m,c]),BigInt(ah.computePosHash(c))<<32n|BigInt(ah.computePosHash(m))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}var o2e,l2e={exports:{}},c2e=(o2e||(o2e=1,function(p){function c(pt,bt){return pt>bt?1:pt0){var Ar=Es+Math.floor(rr/2),Lr={key:bt[Ar],data:hs[Ar],parent:pt};return Lr.left=b(Lr,bt,hs,Es,Ar),Lr.right=b(Lr,bt,hs,Ar+1,sr),Lr}return null}function A(pt,bt,hs,Es,sr){if(!(hs>=Es)){for(var rr=pt[hs+Es>>1],Ar=hs-1,Lr=Es+1;;){do Ar++;while(sr(pt[Ar],rr)<0);do Lr--;while(sr(pt[Lr],rr)>0);if(Ar>=Lr)break;var wn=pt[Ar];pt[Ar]=pt[Lr],pt[Lr]=wn,wn=bt[Ar],bt[Ar]=bt[Lr],bt[Lr]=wn}A(pt,bt,hs,Lr,sr),A(pt,bt,Lr+1,Es,sr)}}m.prototype.rotateLeft=function(pt){var bt=pt.right;bt&&(pt.right=bt.left,bt.left&&(bt.left.parent=pt),bt.parent=pt.parent),pt.parent?pt===pt.parent.left?pt.parent.left=bt:pt.parent.right=bt:this._root=bt,bt&&(bt.left=pt),pt.parent=bt},m.prototype.rotateRight=function(pt){var bt=pt.left;bt&&(pt.left=bt.right,bt.right&&(bt.right.parent=pt),bt.parent=pt.parent),pt.parent?pt===pt.parent.left?pt.parent.left=bt:pt.parent.right=bt:this._root=bt,bt&&(bt.right=pt),pt.parent=bt},m.prototype._splay=function(pt){for(;pt.parent;){var bt=pt.parent;bt.parent?bt.left===pt&&bt.parent.left===bt?(this.rotateRight(bt.parent),this.rotateRight(bt)):bt.right===pt&&bt.parent.right===bt?(this.rotateLeft(bt.parent),this.rotateLeft(bt)):bt.left===pt&&bt.parent.right===bt?(this.rotateRight(bt),this.rotateLeft(bt)):(this.rotateLeft(bt),this.rotateRight(bt)):bt.left===pt?this.rotateRight(bt):this.rotateLeft(bt)}},m.prototype.splay=function(pt){for(var bt,hs,Es,sr,rr;pt.parent;)(hs=(bt=pt.parent).parent)&&hs.parent?((Es=hs.parent).left===hs?Es.left=pt:Es.right=pt,pt.parent=Es):(pt.parent=null,this._root=pt),sr=pt.left,rr=pt.right,pt===bt.left?(hs&&(hs.left===bt?(bt.right?(hs.left=bt.right,hs.left.parent=hs):hs.left=null,bt.right=hs,hs.parent=bt):(sr?(hs.right=sr,sr.parent=hs):hs.right=null,pt.left=hs,hs.parent=pt)),rr?(bt.left=rr,rr.parent=bt):bt.left=null,pt.right=bt,bt.parent=pt):(hs&&(hs.right===bt?(bt.left?(hs.right=bt.left,hs.right.parent=hs):hs.right=null,bt.left=hs,hs.parent=bt):(rr?(hs.left=rr,rr.parent=hs):hs.left=null,pt.right=hs,hs.parent=pt)),sr?(bt.right=sr,sr.parent=bt):bt.right=null,pt.left=bt,bt.parent=pt)},m.prototype.replace=function(pt,bt){pt.parent?pt===pt.parent.left?pt.parent.left=bt:pt.parent.right=bt:this._root=bt,bt&&(bt.parent=pt.parent)},m.prototype.minNode=function(pt){if(pt===void 0&&(pt=this._root),pt)for(;pt.left;)pt=pt.left;return pt},m.prototype.maxNode=function(pt){if(pt===void 0&&(pt=this._root),pt)for(;pt.right;)pt=pt.right;return pt},m.prototype.insert=function(pt,bt){var hs=this._root,Es=null,sr=this._compare;if(this._noDuplicates)for(;hs;){if(Es=hs,sr(hs.key,pt)===0)return;hs=sr(hs.key,pt)<0?hs.right:hs.left}else for(;hs;)Es=hs,hs=sr(hs.key,pt)<0?hs.right:hs.left;return hs={key:pt,data:bt,left:null,right:null,parent:Es},Es?sr(Es.key,hs.key)<0?Es.right=hs:Es.left=hs:this._root=hs,this.splay(hs),this._size++,hs},m.prototype.find=function(pt){for(var bt=this._root,hs=this._compare;bt;){var Es=hs(bt.key,pt);if(Es<0)bt=bt.right;else{if(!(Es>0))return bt;bt=bt.left}}return null},m.prototype.contains=function(pt){for(var bt=this._root,hs=this._compare;bt;){var Es=hs(pt,bt.key);if(Es===0)return!0;bt=Es<0?bt.left:bt.right}return!1},m.prototype.remove=function(pt){var bt=this.find(pt);if(!bt)return!1;if(this.splay(bt),bt.left)if(bt.right){var hs=this.minNode(bt.right);hs.parent!==bt&&(this.replace(hs,hs.right),hs.right=bt.right,hs.right.parent=hs),this.replace(bt,hs),hs.left=bt.left,hs.left.parent=hs}else this.replace(bt,bt.left);else this.replace(bt,bt.right);return this._size--,!0},m.prototype.removeNode=function(pt){if(!pt)return!1;if(this.splay(pt),pt.left)if(pt.right){var bt=this.minNode(pt.right);bt.parent!==pt&&(this.replace(bt,bt.right),bt.right=pt.right,bt.right.parent=bt),this.replace(pt,bt),bt.left=pt.left,bt.left.parent=bt}else this.replace(pt,pt.left);else this.replace(pt,pt.right);return this._size--,!0},m.prototype.erase=function(pt){var bt=this.find(pt);if(bt){this.splay(bt);var hs=bt.left,Es=bt.right,sr=null;hs&&(hs.parent=null,sr=this.maxNode(hs),this.splay(sr),this._root=sr),Es&&(hs?sr.right=Es:this._root=Es,Es.parent=sr),this._size--}},m.prototype.pop=function(){var pt=this._root,bt=null;if(pt){for(;pt.left;)pt=pt.left;bt={key:pt.key,data:pt.data},this.remove(pt.key)}return bt},m.prototype.next=function(pt){var bt=pt;if(bt)if(bt.right)for(bt=bt.right;bt&&bt.left;)bt=bt.left;else for(bt=pt.parent;bt&&bt.right===pt;)pt=bt,bt=bt.parent;return bt},m.prototype.prev=function(pt){var bt=pt;if(bt)if(bt.left)for(bt=bt.left;bt&&bt.right;)bt=bt.right;else for(bt=pt.parent;bt&&bt.left===pt;)pt=bt,bt=bt.parent;return bt},m.prototype.forEach=function(pt){for(var bt=this._root,hs=[],Es=!1,sr=0;!Es;)bt?(hs.push(bt),bt=bt.left):hs.length>0?(pt(bt=hs.pop(),sr++),bt=bt.right):Es=!0;return this},m.prototype.range=function(pt,bt,hs,Es){for(var sr=[],rr=this._compare,Ar=this._root;sr.length!==0||Ar;)if(Ar)sr.push(Ar),Ar=Ar.left;else{if(rr((Ar=sr.pop()).key,bt)>0)break;if(rr(Ar.key,pt)>=0&&hs.call(Es,Ar))return this;Ar=Ar.right}return this},m.prototype.keys=function(){for(var pt=this._root,bt=[],hs=[],Es=!1;!Es;)pt?(bt.push(pt),pt=pt.left):bt.length>0?(pt=bt.pop(),hs.push(pt.key),pt=pt.right):Es=!0;return hs},m.prototype.values=function(){for(var pt=this._root,bt=[],hs=[],Es=!1;!Es;)pt?(bt.push(pt),pt=pt.left):bt.length>0?(pt=bt.pop(),hs.push(pt.data),pt=pt.right):Es=!0;return hs},m.prototype.at=function(pt){for(var bt=this._root,hs=[],Es=!1,sr=0;!Es;)if(bt)hs.push(bt),bt=bt.left;else if(hs.length>0){if(bt=hs.pop(),sr===pt)return bt;sr++,bt=bt.right}else Es=!0;return null},m.prototype.load=function(pt,bt,hs){if(pt===void 0&&(pt=[]),bt===void 0&&(bt=[]),hs===void 0&&(hs=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var Es=pt.length;return hs&&A(pt,bt,0,Es-1,this._compare),this._root=b(null,pt,bt,0,Es),this._size=Es,this},m.prototype.min=function(){var pt=this.minNode(this._root);return pt?pt.key:null},m.prototype.max=function(){var pt=this.maxNode(this._root);return pt?pt.key:null},m.prototype.isEmpty=function(){return this._root===null},y.size.get=function(){return this._size},m.createTree=function(pt,bt,hs,Es,sr){return new m(hs,sr).load(pt,bt,Es)},Object.defineProperties(m.prototype,y);var I=0,O=1,z=2,q=3,X=0,Q=1,se=2,ae=3;function le(pt,bt,hs){bt===null?(pt.inOut=!1,pt.otherInOut=!0):(pt.isSubject===bt.isSubject?(pt.inOut=!bt.inOut,pt.otherInOut=bt.otherInOut):(pt.inOut=!bt.otherInOut,pt.otherInOut=bt.isVertical()?!bt.inOut:bt.inOut),bt&&(pt.prevInResult=!xe(bt,hs)||bt.isVertical()?bt.prevInResult:bt));var Es=xe(pt,hs);pt.resultTransition=Es?function(sr,rr){var Ar,Lr=!sr.inOut,wn=!sr.otherInOut;switch(rr){case X:Ar=Lr&&wn;break;case Q:Ar=Lr||wn;break;case ae:Ar=Lr^wn;break;case se:Ar=sr.isSubject?Lr&&!wn:wn&&!Lr}return Ar?1:-1}(pt,hs):0}function xe(pt,bt){switch(pt.type){case I:switch(bt){case X:return!pt.otherInOut;case Q:return pt.otherInOut;case se:return pt.isSubject&&pt.otherInOut||!pt.isSubject&&!pt.otherInOut;case ae:return!0}break;case z:return bt===X||bt===Q;case q:return bt===se;case O:return!1}return!1}var Me=function(pt,bt,hs,Es,sr){this.left=bt,this.point=pt,this.otherEvent=hs,this.isSubject=Es,this.type=sr||I,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},Ce={inResult:{configurable:!0}};function ze(pt,bt){return pt[0]===bt[0]&&pt[1]===bt[1]}Me.prototype.isBelow=function(pt){var bt=this.point,hs=this.otherEvent.point;return this.left?(bt[0]-pt[0])*(hs[1]-pt[1])-(hs[0]-pt[0])*(bt[1]-pt[1])>0:(hs[0]-pt[0])*(bt[1]-pt[1])-(bt[0]-pt[0])*(hs[1]-pt[1])>0},Me.prototype.isAbove=function(pt){return!this.isBelow(pt)},Me.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Ce.inResult.get=function(){return this.resultTransition!==0},Me.prototype.clone=function(){var pt=new Me(this.point,this.left,this.otherEvent,this.isSubject,this.type);return pt.contourId=this.contourId,pt.resultTransition=this.resultTransition,pt.prevInResult=this.prevInResult,pt.isExteriorRing=this.isExteriorRing,pt.inOut=this.inOut,pt.otherInOut=this.otherInOut,pt},Object.defineProperties(Me.prototype,Ce);var Ve=11102230246251565e-32,Je=134217729,vt=(3+8*Ve)*Ve;function mt(pt,bt,hs,Es,sr){var rr,Ar,Lr,wn,An=bt[0],Ln=Es[0],ta=0,Gr=0;Ln>An==Ln>-An?(rr=An,An=bt[++ta]):(rr=Ln,Ln=Es[++Gr]);var rn=0;if(taAn==Ln>-An?(Lr=rr-((Ar=An+rr)-An),An=bt[++ta]):(Lr=rr-((Ar=Ln+rr)-Ln),Ln=Es[++Gr]),rr=Ar,Lr!==0&&(sr[rn++]=Lr);taAn==Ln>-An?(Lr=rr-((Ar=rr+An)-(wn=Ar-rr))+(An-wn),An=bt[++ta]):(Lr=rr-((Ar=rr+Ln)-(wn=Ar-rr))+(Ln-wn),Ln=Es[++Gr]),rr=Ar,Lr!==0&&(sr[rn++]=Lr);for(;ta0!=ta>0)return Gr;var rn=Math.abs(Ln+ta);return Math.abs(Gr)>=It*rn?Gr:-function(wa,Ma,Ta,ei,gi,ui,Ra){var Ua,En,ua,Qi,Hr,sa,mi,_i,Ci,To,ki,Wr,io,ti,Ui,dl,Rl,Zo,Yo=wa-gi,Sl=Ta-gi,du=Ma-ui,Ni=ei-ui;qt[0]=(Ui=(_i=Yo-(mi=(sa=Je*Yo)-(sa-Yo)))*(To=Ni-(Ci=(sa=Je*Ni)-(sa-Ni)))-((ti=Yo*Ni)-mi*Ci-_i*Ci-mi*To))-((ki=Ui-(Rl=(_i=du-(mi=(sa=Je*du)-(sa-du)))*(To=Sl-(Ci=(sa=Je*Sl)-(sa-Sl)))-((dl=du*Sl)-mi*Ci-_i*Ci-mi*To)))+(Hr=Ui-ki))+(Hr-Rl),qt[1]=(io=ti-((Wr=ti+ki)-(Hr=Wr-ti))+(ki-Hr))-((ki=io-dl)+(Hr=io-ki))+(Hr-dl),qt[2]=Wr-((Zo=Wr+ki)-(Hr=Zo-Wr))+(ki-Hr),qt[3]=Zo;var ko=function(ex,Uc){for(var Ud=Uc[0],oh=1;oh<4;oh++)Ud+=Uc[oh];return Ud}(0,qt),Ao=Ot*Ra;if(ko>=Ao||-ko>=Ao||(Ua=wa-(Yo+(Hr=wa-Yo))+(Hr-gi),ua=Ta-(Sl+(Hr=Ta-Sl))+(Hr-gi),En=Ma-(du+(Hr=Ma-du))+(Hr-ui),Qi=ei-(Ni+(Hr=ei-Ni))+(Hr-ui),Ua===0&&En===0&&ua===0&&Qi===0)||(Ao=ns*Ra+vt*Math.abs(ko),(ko+=Yo*Qi+Ni*Ua-(du*ua+Sl*En))>=Ao||-ko>=Ao))return ko;As[0]=(Ui=(_i=Ua-(mi=(sa=Je*Ua)-(sa-Ua)))*(To=Ni-(Ci=(sa=Je*Ni)-(sa-Ni)))-((ti=Ua*Ni)-mi*Ci-_i*Ci-mi*To))-((ki=Ui-(Rl=(_i=En-(mi=(sa=Je*En)-(sa-En)))*(To=Sl-(Ci=(sa=Je*Sl)-(sa-Sl)))-((dl=En*Sl)-mi*Ci-_i*Ci-mi*To)))+(Hr=Ui-ki))+(Hr-Rl),As[1]=(io=ti-((Wr=ti+ki)-(Hr=Wr-ti))+(ki-Hr))-((ki=io-dl)+(Hr=io-ki))+(Hr-dl),As[2]=Wr-((Zo=Wr+ki)-(Hr=Zo-Wr))+(ki-Hr),As[3]=Zo;var Cu=mt(4,qt,4,As,us);As[0]=(Ui=(_i=Yo-(mi=(sa=Je*Yo)-(sa-Yo)))*(To=Qi-(Ci=(sa=Je*Qi)-(sa-Qi)))-((ti=Yo*Qi)-mi*Ci-_i*Ci-mi*To))-((ki=Ui-(Rl=(_i=du-(mi=(sa=Je*du)-(sa-du)))*(To=ua-(Ci=(sa=Je*ua)-(sa-ua)))-((dl=du*ua)-mi*Ci-_i*Ci-mi*To)))+(Hr=Ui-ki))+(Hr-Rl),As[1]=(io=ti-((Wr=ti+ki)-(Hr=Wr-ti))+(ki-Hr))-((ki=io-dl)+(Hr=io-ki))+(Hr-dl),As[2]=Wr-((Zo=Wr+ki)-(Hr=Zo-Wr))+(ki-Hr),As[3]=Zo;var ul=mt(Cu,us,4,As,gs);As[0]=(Ui=(_i=Ua-(mi=(sa=Je*Ua)-(sa-Ua)))*(To=Qi-(Ci=(sa=Je*Qi)-(sa-Qi)))-((ti=Ua*Qi)-mi*Ci-_i*Ci-mi*To))-((ki=Ui-(Rl=(_i=En-(mi=(sa=Je*En)-(sa-En)))*(To=ua-(Ci=(sa=Je*ua)-(sa-ua)))-((dl=En*ua)-mi*Ci-_i*Ci-mi*To)))+(Hr=Ui-ki))+(Hr-Rl),As[1]=(io=ti-((Wr=ti+ki)-(Hr=Wr-ti))+(ki-Hr))-((ki=io-dl)+(Hr=io-ki))+(Hr-dl),As[2]=Wr-((Zo=Wr+ki)-(Hr=Zo-Wr))+(ki-Hr),As[3]=Zo;var kp=mt(ul,gs,4,As,xs);return xs[kp-1]}(sr,rr,Ar,Lr,wn,An,rn)}(pt[0],pt[1],bt[0],bt[1],hs[0],hs[1]);return Es>0?-1:Es<0?1:0}function Ns(pt,bt){var hs=pt.point,Es=bt.point;return hs[0]>Es[0]?1:hs[0]Es[1]?1:-1:function(sr,rr,Ar,Lr){return sr.left!==rr.left?sr.left?1:-1:Is(Ar,sr.otherEvent.point,rr.otherEvent.point)!==0?sr.isBelow(rr.otherEvent.point)?-1:1:!sr.isSubject&&rr.isSubject?1:-1}(pt,bt,hs)}function Ms(pt,bt,hs){var Es=new Me(bt,!1,pt,pt.isSubject),sr=new Me(bt,!0,pt.otherEvent,pt.isSubject);return ze(pt.point,pt.otherEvent.point)&&console.warn("what is that, a collapsed segment?",pt),Es.contourId=sr.contourId=pt.contourId,Ns(sr,pt.otherEvent)>0&&(pt.otherEvent.left=!0,sr.left=!1),pt.otherEvent.otherEvent=sr,pt.otherEvent=Es,hs.push(sr),hs.push(Es),hs}function ds(pt,bt){return pt[0]*bt[1]-pt[1]*bt[0]}function as(pt,bt){return pt[0]*bt[0]+pt[1]*bt[1]}function Ts(pt,bt,hs){var Es=function(wn,An,Ln,ta,Gr){var rn=[An[0]-wn[0],An[1]-wn[1]],wa=[ta[0]-Ln[0],ta[1]-Ln[1]];function Ma(sa,mi,_i){return[sa[0]+mi*_i[0],sa[1]+mi*_i[1]]}var Ta=[Ln[0]-wn[0],Ln[1]-wn[1]],ei=ds(rn,wa),gi=ei*ei,ui=as(rn,rn);if(gi>0){var Ra=ds(Ta,wa)/ei;if(Ra<0||Ra>1)return null;var Ua=ds(Ta,rn)/ei;return Ua<0||Ua>1?null:Ra===0||Ra===1?[Ma(wn,Ra,rn)]:Ua===0||Ua===1?[Ma(Ln,Ua,wa)]:[Ma(wn,Ra,rn)]}if((gi=(ei=ds(Ta,rn))*ei)>0)return null;var En=as(rn,Ta)/ui,ua=En+as(rn,wa)/ui,Qi=Math.min(En,ua),Hr=Math.max(En,ua);return Qi<=1&&Hr>=0?Qi===1?[Ma(wn,Qi>0?Qi:0,rn)]:Hr===0?[Ma(wn,Hr<1?Hr:1,rn)]:[Ma(wn,Qi>0?Qi:0,rn),Ma(wn,Hr<1?Hr:1,rn)]:null}(pt.point,pt.otherEvent.point,bt.point,bt.otherEvent.point),sr=Es?Es.length:0;if(sr===0||sr===1&&(ze(pt.point,bt.point)||ze(pt.otherEvent.point,bt.otherEvent.point))||sr===2&&pt.isSubject===bt.isSubject)return 0;if(sr===1)return ze(pt.point,Es[0])||ze(pt.otherEvent.point,Es[0])||Ms(pt,Es[0],hs),ze(bt.point,Es[0])||ze(bt.otherEvent.point,Es[0])||Ms(bt,Es[0],hs),1;var rr=[],Ar=!1,Lr=!1;return ze(pt.point,bt.point)?Ar=!0:Ns(pt,bt)===1?rr.push(bt,pt):rr.push(pt,bt),ze(pt.otherEvent.point,bt.otherEvent.point)?Lr=!0:Ns(pt.otherEvent,bt.otherEvent)===1?rr.push(bt.otherEvent,pt.otherEvent):rr.push(pt.otherEvent,bt.otherEvent),Ar&&Lr||Ar?(bt.type=O,pt.type=bt.inOut===pt.inOut?z:q,Ar&&!Lr&&Ms(rr[1].otherEvent,rr[0].point,hs),2):Lr?(Ms(rr[0],rr[1].point,hs),3):rr[0]!==rr[3].otherEvent?(Ms(rr[0],rr[1].point,hs),Ms(rr[1],rr[2].point,hs),3):(Ms(rr[0],rr[1].point,hs),Ms(rr[3].otherEvent,rr[2].point,hs),3)}function Ws(pt,bt){if(pt===bt)return 0;if(Is(pt.point,pt.otherEvent.point,bt.point)!==0||Is(pt.point,pt.otherEvent.point,bt.otherEvent.point)!==0)return ze(pt.point,bt.point)?pt.isBelow(bt.otherEvent.point)?-1:1:pt.point[0]===bt.point[0]?pt.point[1]bt.contourId?1:-1:Ns(pt,bt)===1?1:-1}var Rs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function Mr(pt,bt,hs,Es){var sr,rr=pt+1,Ar=bt[pt].point,Lr=bt.length;for(rrEs;)rr--;return rr}Rs.prototype.isExterior=function(){return this.holeOf==null};var or=vr,mr=vr;function vr(pt,bt){if(!(this instanceof vr))return new vr(pt,bt);if(this.data=pt||[],this.length=this.data.length,this.compare=bt||Dn,this.length>0)for(var hs=(this.length>>1)-1;hs>=0;hs--)this._down(hs)}function Dn(pt,bt){return ptbt?1:0}vr.prototype={push:function(pt){this.data.push(pt),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var pt=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),pt}},peek:function(){return this.data[0]},_up:function(pt){for(var bt=this.data,hs=this.compare,Es=bt[pt];pt>0;){var sr=pt-1>>1,rr=bt[sr];if(hs(Es,rr)>=0)break;bt[pt]=rr,pt=sr}bt[pt]=Es},_down:function(pt){for(var bt=this.data,hs=this.compare,Es=this.length>>1,sr=bt[pt];pt=0)break;bt[pt]=Lr,pt=rr}bt[pt]=sr}},or.default=mr;var zs=Math.max,_r=Math.min,an=0;function oa(pt,bt,hs,Es,sr,rr){var Ar,Lr,wn,An,Ln,ta;for(Ar=0,Lr=pt.length-1;Ar0?ta.left=!0:Ln.left=!0;var Gr=wn[0],rn=wn[1];sr[0]=_r(sr[0],Gr),sr[1]=_r(sr[1],rn),sr[2]=zs(sr[2],Gr),sr[3]=zs(sr[3],rn),Es.push(Ln),Es.push(ta)}}var ha=[];function Nn(pt,bt,hs){typeof pt[0][0][0]=="number"&&(pt=[pt]),typeof bt[0][0][0]=="number"&&(bt=[bt]);var Es=function(rn,wa,Ma){var Ta=null;return rn.length*wa.length==0&&(Ma===X?Ta=ha:Ma===se?Ta=rn:Ma!==Q&&Ma!==ae||(Ta=rn.length===0?wa:rn)),Ta}(pt,bt,hs);if(Es)return Es===ha?null:Es;var sr=[1/0,1/0,-1/0,-1/0],rr=[1/0,1/0,-1/0,-1/0],Ar=function(rn,wa,Ma,Ta,ei){var gi,ui,Ra,Ua,En,ua,Qi=new or(null,Ns);for(Ra=0,Ua=rn.length;RaTa[2]||Ta[0]>Ma[2]||Ma[1]>Ta[3]||Ta[1]>Ma[3])&&(ei===X?gi=ha:ei===se?gi=rn:ei!==Q&&ei!==ae||(gi=rn.concat(wa))),gi}(pt,bt,sr,rr,hs))return Es===ha?null:Es;for(var Lr=function(rn){var wa,Ma,Ta=function(Ra){var Ua,En,ua,Qi,Hr=[];for(En=0,ua=Ra.length;En0){var ki=sa[To];if(ki.holeOf!=null){var Wr=ki.holeOf;sa[Wr].holeIds.push(mi),_i.holeOf=Wr,_i.depth=sa[To].depth}else sa[To].holeIds.push(mi),_i.holeOf=To,_i.depth=sa[To].depth+1}else _i.holeOf=null,_i.depth=sa[To].depth}else _i.holeOf=null,_i.depth=0;return _i}(Ta[wa],gi,Ra),En=function(Hr){ei[Hr]=!0,Hr=Ta.length)&&Ta[ua];);gi.push(Ua)}};for(wa=0,Ma=Ta.length;waQi||gi===se&&Hr.point[0]>Ta[2])break;if(Hr.left){Ra=ui=En.insert(Hr),ui=ui!==(Ua=En.minNode())?En.prev(ui):null,Ra=En.next(Ra);var sa=ui?ui.key:null;if(le(Hr,sa,gi),Ra&&Ts(Hr,Ra.key,rn)===2&&(le(Hr,sa,gi),le(Ra.key,Hr,gi)),ui&&Ts(ui.key,Hr,rn)===2){var mi=ui;le(sa,(mi=mi!==Ua?En.prev(mi):null)?mi.key:null,gi),le(Hr,sa,gi)}}else Ra=ui=En.find(Hr=Hr.otherEvent),ui&&Ra&&(ui=ui!==Ua?En.prev(ui):null,Ra=En.next(Ra),En.remove(Hr),Ra&&ui&&Ts(ui.key,Ra.key,rn))}return ua}(Ar,0,0,sr,rr,hs)),wn=[],An=0;An * @license MIT * @preserve */function _D(p,c,m,y){const b=[],A=y===0?(I,O,z,q,X,Q)=>{I.push(new cs(Q,z+(Q-O)/(q-O)*(X-z)))}:(I,O,z,q,X,Q)=>{I.push(new cs(O+(Q-z)/(X-z)*(q-O),Q))};for(const I of p){const O=[];for(const z of I){if(z.length<=2)continue;const q=[];for(let se=0;sec&&A(q,ae,le,xe,Me,c):Ce>m?ze=c&&A(q,ae,le,xe,Me,c),ze>m&&Ce<=m&&A(q,ae,le,xe,Me,m)}let X=z[z.length-1];const Q=y===0?X.x:X.y;Q>=c&&Q<=m&&q.push(X),q.length&&(X=q[q.length-1],q[0].x===X.x&&q[0].y===X.y||q.push(q[0]),O.push(q))}O.length&&b.push(O)}return b}function jQe(p,c){const m=Lce(p),y=Lce([c]),b=c2e.intersection(m,y);return b==null?[]:d2e(b)}function kQe(p,c){let y=Lce(p,65536);const b=[];for(;c.valid();c.next()){const[A,I]=c.get(),O=A.x*65536,z=A.y*65536,q=I.x*65536,X=I.y*65536,Q=q-O,se=X-z,ae=Math.hypot(Q,se);if(ae===0)continue;const le=Math.trunc(se/ae*3),xe=-Math.trunc(Q/ae*3);b.push([[[O,z],[q,X],[q+le,X+xe],[O+le,z+xe],[O,z]]])}return b.length>0&&(y=c2e.diff(y,b)),d2e(y,1/65536)}function Lce(p,c=1){return[p.map(m=>m.map(y=>[y.x*c,y.y*c]))]}function d2e(p,c=1){return p.map(m=>m.map((y,b)=>{const A=y.map(I=>new cs(I[0]*c,I[1]*c).round());return b>0&&A.reverse(),A}))}class Dce{constructor(c,m){this.layoutVertexArray=new Gg,this.indexArray=new ol,this.lineIndexArray=new rh,this.triangleSegments=new ro,this.lineSegments=new ro,this.programConfigurations=new Sm(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new bf)}update(c,m,y,b,A,I,O,z){this.programConfigurations.updatePaintArrays(c,m,A,y,b,I,O,z)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,lQe.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,cQe.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,b,A,I,O){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,m,y,b,A,I,void 0,O)}}class Oce{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 Dce(c,!1),this.elevationBufferData=new Dce(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,b){}populate(c,m,y,b){this.hasPattern=Ice("fill",this.layers,this.pixelRatio,m);const A=this.layers[0].layout.get("fill-sort-key"),I=[];for(const{feature:O,id:z,index:q,sourceLayerIndex:X}of c){const Q=this.layers[0]._featureFilter.needGeometry,se=Ut(O,Q);if(!this.layers[0]._featureFilter.filter(new Si(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,y))continue;const ae=A?A.evaluate(se,{},y,m.availableImages):void 0,le={id:z,properties:O.properties,type:O.type,sourceLayerIndex:X,index:q,geometry:Q?se.geometry:At(O,y,b),patterns:{},sortKey:ae};I.push(le)}A&&I.sort((O,z)=>O.sortKey-z.sortKey);for(const O of I){const{geometry:z,index:q,sourceLayerIndex:X}=O;if(this.hasPattern){const Q=Pce("fill",this.layers,O,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Q)}else this.addFeature(O,z,q,y,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(c[q].feature,z,q,X,this.index)}}update(c,m,y,b,A,I,O){this.bufferData.update(c,m,y,b,A,I,O,this.worldview),this.elevationBufferData.update(c,m,y,b,A,I,O,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(c,m,y,b,A,I,O,this.worldview)}addFeatures(c,m,y,b,A,I){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,y,b,I,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,b,A,I=[],O,z){const q=NT(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(c,q,b,y,z):this.addGeometry(q,this.bufferData),this.bufferData.populatePaintArrays(c,y,A,I,b,O,this.worldview),this.elevationBufferData.populatePaintArrays(c,y,A,I,b,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,b,A){this.elevatedStructures&&(this.elevatedStructures.construct(c),this.elevatedStructures.populatePaintArrays(m,y,b,A,this.worldview))}addElevatedRoadFeature(c,m,y,b,A){const I=new Array,O=Ba.getElevationFeature(c,A);if(!O)return void this.addGeometry(m,this.bufferData);{const q=this.clipPolygonsToTile(m,1);q.length>0&&I.push({polygons:q,elevationFeature:O,elevationTileID:y})}const z={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(c,{},y),featureIndex:b};for(const q of I)if(q.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new ah(q.elevationTileID,this.layers,this.zoom,this.lut));const Q=q.elevationFeature.isTunnel();let se=0;c.properties.hasOwnProperty(es)&&(se=+c.properties[es]);for(const ae of q.polygons)this.elevatedStructures.addPortalCandidates(q.elevationFeature.id,ae,Q,q.elevationFeature,se)}q.elevationFeature.constantHeight==null&&(q.polygons=this.prepareElevatedPolygons(q.polygons,q.elevationFeature,q.elevationTileID));const X=new ii(y,q.elevationTileID);this.addElevatedGeometry(q.polygons,X,q.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,b,z)}}addElevatedGeometry(c,m,y,b,A,I){const O={elevation:y,elevationSampler:m,bias:b,index:A,featureInfo:I},[z,q]=this.addGeometry(c,this.elevationBufferData,O);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:z,max:q}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,z),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,q))}addGeometry(c,m,y){let b=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,I=null;y&&(I=y.elevationSampler.constantElevation(y.elevation,y.bias),I!=null&&(b=I,A=I));const O=(z,q,X)=>{if(y!=null)if(q.push(z),I!=null)m.elevatedLayoutVertexArray.emplaceBack(I),X.push(I);else{const Q=y.elevationSampler.pointElevation(z,y.elevation,y.bias);m.elevatedLayoutVertexArray.emplaceBack(Q),X.push(Q),b=Math.min(b,Q),A=Math.max(A,Q)}};for(const z of c){let q=0;for(const Ve of z)q+=Ve.length;const X=m.triangleSegments.prepareSegment(q,m.layoutVertexArray,m.indexArray),Q=X.vertexLength,se=[],ae=[],le=[],xe=[],Me=[],Ce=m.layoutVertexArray.length;for(const Ve of z){if(Ve.length===0)continue;Ve!==z[0]&&ae.push(se.length/2);const Je=m.lineSegments.prepareSegment(Ve.length,m.layoutVertexArray,m.lineIndexArray),vt=Je.vertexLength;y&&Me.push(m.layoutVertexArray.length-Ce),O(Ve[0],le,xe),m.layoutVertexArray.emplaceBack(Ve[0].x,Ve[0].y),m.lineIndexArray.emplaceBack(vt+Ve.length-1,vt),se.push(Ve[0].x),se.push(Ve[0].y);for(let mt=1;mt0&&y&&this.elevationMode==="hd-road-base"){const Ve=y.elevation.isTunnel(),Je=y.elevation.safeArea,vt=this.elevatedStructures.addVertices(le,xe);this.elevatedStructures.addTriangles(ze,vt,Ve);const mt=Me.length;if(mt>0){for(let St=0;St=y&&ae.max.x<=A&&ae.min.y>=b&&ae.max.y<=I?z:q).push(se)}if(z.length===c.length)return c;const X=[new cs(y,b),new cs(A,b),new cs(A,I),new cs(y,I),new cs(y,b)],Q=z;for(const se of q)Q.push(...jQe(se,X));return Q}}let u2e,h2e,m2e,p2e;xr(Oce,"FillBucket",{omit:["layers","patternFeatures"]}),xr(Dce,"FillBufferData"),xr(ah,"ElevatedStructures");class bD{constructor(c,m,y,b){if(this.triangleCount=m.length/3,this.min=new cs(0,0),this.max=new cs(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[A,I]=[c[0].clone(),c[0].clone()];for(let Q=1;QQ.cellIdx-se.cellIdx||Q.triIdx-se.triIdx);let X=0;for(;Xthis.max.x||this.min.x>c.x||c.y>this.max.y||this.min.y>c.y)return;const y=Qg(c.x-this.min.x,this.xScale,this.cellsX),b=Qg(c.y-this.min.y,this.yScale,this.cellsY),A=this.cells[b*this.cellsX+y];if(A){this._lazyInitLookup();for(let I=0;Ithis.max.x||this.min.x>m.x||c.y>this.max.y||this.min.y>m.y)return;this._lazyInitLookup();const b=Qg(c.x-this.min.x,this.xScale,this.cellsX),A=Qg(m.x-this.min.x,this.xScale,this.cellsX),I=Qg(c.y-this.min.y,this.yScale,this.cellsY),O=Qg(m.y-this.min.y,this.yScale,this.cellsY);for(let z=I;z<=O;z++)for(let q=b;q<=A;q++){const X=this.cells[z*this.cellsX+q];if(X)for(let Q=0;Qm.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,b){}populate(c,m,y,b){const A=[];for(const{feature:I,id:O,index:z,sourceLayerIndex:q}of c){const X=this.layers[0]._featureFilter.needGeometry,Q=Ut(I,X);if(!this.layers[0]._featureFilter.filter(new Si(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Q,y))continue;const se={id:O,properties:I.properties,type:I.type,sourceLayerIndex:q,index:z,geometry:X?Q.geometry:At(I,y,b),patterns:{}};A.push(se)}for(const I of A){const{geometry:O,index:z,sourceLayerIndex:q}=I;this.addFeature(I,O,z,y,{},m.availableImages,m.brightness),m.featureIndex.insert(c[z].feature,O,z,q,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(c){}update(c,m,y,b,A,I,O){}destroy(){}addFeature(c,m,y,b,A,I=[],O){for(const z of NT(m,2)){const q=[],X=[],Q=[],se=new cs(1/0,1/0),ae=new cs(-1/0,-1/0);for(const Me of z)if(Me.length!==0){Me!==z[0]&&Q.push(X.length/2);for(let Ce=0;CeI===b)===void 0}(y,p.clipScope)}function wD(p,c){return p.x-c.x||p.y-c.y}function y2e(p,c){return wD(p.min,c.min)===0&&wD(p.max,c.max)===0}function Rce(p,c){return!(p.min.x>c.max.x||p.max.xc.max.y||p.max.ynew cs((z.x+A.x*Hs)*O-I.x*Hs,(z.y+A.y*Hs)*O-I.y*Hs))}return Fce(m,b,p.indices,0,p.indices.length,0,0)}function b2e(p,c,m,y){const b=Math.pow(2,y.z-m.z);return new cs((p+m.x*Hs)*b-y.x*Hs,(c+m.y*Hs)*b-y.y*Hs)}function w2e(p,c){const m=[];c.grid.queryPoint(p,m);const y=c.indices,b=c.vertices;for(let A=0;A0&&(y.length>1&&m.push(y),y=[])}return y.length>1&&m.push(y),m}const Bce=Bt.types,LQe=["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"],DQe=["fill-extrusion-flood-light-ground-radius"],OQe=Math.pow(2,13),RQe=Math.pow(2,15)-1,k2e=new cs(0,1),xy=2147483648,N2e=7,S2e=450;function CT(p,c,m,y,b,A,I,O){p.emplaceBack((c<<1)+I,(m<<1)+A,(Math.floor(y*OQe)<<1)+b,Math.round(O))}function MT(p,c,m){p.emplaceBack(c.x*Hs,c.y*Hs,m?1:0)}function kD(p,c,m,y,b,A){p.emplaceBack(c.x,c.y,(m.x<<1)+y,(m.y<<1)+b,A)}function TT(p,c,m){p.emplaceBack(c.x,c.y,c.z,m[0]*16384,m[1]*16384,m[2]*16384)}class C2e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class M2e{constructor(){this.centroidXY=new cs(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 cs(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new cs(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new cs(this.max.x-this.min.x,this.max.y-this.min.y)}}class T2e{constructor(){this.acc=new cs(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 b=!!this.borders;m.xc.max.x&&(c.max.x=m.x,b=!0),m.yc.max.y&&(c.max.y=m.y,b=!0),((m.x===0||m.x===Hs)&&m.x===y.x)!=((m.y===0||m.y===Hs)&&m.y===y.y)&&this.processBorderOverlap(m,y),b&&this.checkBorderIntersection(m,y)}checkBorderIntersection(c,m){m.x<0!=c.x<0&&this.addBorderIntersection(0,Jr(m.y,c.y,(0-m.x)/(c.x-m.x))),m.x>Hs!=c.x>Hs&&this.addBorderIntersection(1,Jr(m.y,c.y,(Hs-m.x)/(c.x-m.x))),m.y<0!=c.y<0&&this.addBorderIntersection(2,Jr(m.x,c.x,(0-m.y)/(c.y-m.y))),m.y>Hs!=c.y>Hs&&this.addBorderIntersection(3,Jr(m.x,c.x,(Hs-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 cs(0,0):new cs(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 A2e(p,c){const m=p.add(c)._unit(),y=_e(p.x*m.x+p.y*m.y,-1,1);var b,A,I;return b=Math.acos(y),Math.min(4,Math.max(-4,Math.tan(b)))/4*RQe*((A=p).x*(I=c).y-A.y*I.x<0?-1:1)}const FQe=[p=>p.x<0,p=>p.x>Hs,p=>p.y<0,p=>p.y>Hs];function zQe(p,c,m,y){const b=[4];if(y===0)return b;m._mult(y);const A=p.sub(m),I=c.sub(m),O=[p,c,A,I];for(let z=0;z<4;z++)for(const q of O)if(FQe[z](q)){b.push(z);break}return b}class $ce{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new tT,this.indexArray=new ol,this.programConfigurations=new Sm(c.layers,{zoom:c.zoom,lut:c.lut},m=>DQe.includes(m)),this._segments=new ro,this.hiddenByLandmarkVertexArray=new OS,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new ro}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(c,m,y,b=!1){const A=c.length;if(A>2){let I=Math.max(0,this._segments.get().length-1);const O=this._segments._prepareSegment(4*A,this.vertexArray.length,2*this._segmentToGroundQuads[I].length);let z;I!==this._segments.get().length-1&&(I++,this._segmentToGroundQuads[I]=[],this._segmentToRegionTriCounts[I]=[0,0,0,0,0]);{const q=c[0],X=c[1];z=A2e(q.sub(c[A-1])._perp()._unit(),X.sub(q)._perp()._unit())}for(let q=0;qb.region-A.region);for(let y=0;yz+q,0);let O=0;for(let z=0;z<=4;z++){const q=I[z];if(q!==0){let X=this.regionSegments[z];X||(X=this.regionSegments[z]=new ro);const Q={vertexOffset:A.vertexOffset,primitiveOffset:A.primitiveOffset+O,vertexLength:A.vertexLength,primitiveLength:q};X.get().push(Q)}O+=q}for(let z=0;z0?this.hiddenByLandmarkVertexBuffer=c.createVertexBuffer(this.hiddenByLandmarkVertexArray,AQe.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 ND{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 ol,this.footprintVertices=new Gg,this.footprintSegments=[],this.layoutVertexArray=new ev,this.centroidVertexArray=new hD,this.wallVertexArray=new W_,this.indexArray=new ol,this.programConfigurations=new Sm(c.layers,{zoom:c.zoom,lut:c.lut},m=>LQe.includes(m)),this.segments=new ro,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new $ce(c),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,b){}populate(c,m,y,b){this.features=[],this.hasPattern=Ice("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=Le(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:A,id:I,index:O,sourceLayerIndex:z}of c){const q=this.layers[0]._featureFilter.needGeometry,X=Ut(A,q);if(!this.layers[0]._featureFilter.filter(new Si(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),X,y))continue;const Q={id:I,sourceLayerIndex:z,index:O,geometry:q?X.geometry:At(A,y,b),properties:A.properties,type:A.type,patterns:{}},se=this.layoutVertexArray.length,ae=Bce[Q.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:A.id,feature:Pce("fill-extrusion",this.layers,Q,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const le of Q.geometry)for(const xe of j2e(le,ae))this.addFeature(A.id,Q,[xe],O,y,{},m.availableImages,b,m.brightness);else this.addFeature(A.id,Q,Q.geometry,O,y,{},m.availableImages,b,m.brightness);m.featureIndex.insert(A,Q.geometry,O,z,this.index,se)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(c,m,y,b,A,I){for(const{featureId:O,feature:z}of this.features){const q=Bce[z.type]==="Polygon",{geometry:X}=z;if(this.wallMode)for(const Q of X)for(const se of j2e(Q,q))this.addFeature(O,z,[se],z.index,m,y,b,A,I);else this.addFeature(O,z,X,z.index,m,y,b,A,I)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(c,m,y,b,A,I,O){this.programConfigurations.updatePaintArrays(c,m,A,y,b,I,O,this.worldview),this.groundEffect.update(c,m,A,y,b,I,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,IQe),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,TQe.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,EQe.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,MQe.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,b,A,I,O,z,q){const X=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,Q=[new cs(0,0),new cs(Hs,Hs)],se=z.projection,ae=se.name==="globe",le=this.wallMode||Bce[m.type]==="Polygon",xe=new T2e;xe.centroidDataIndex=this.centroidData.length;const Me=new M2e;Me.buildingId=c,m.properties&&m.properties.hasOwnProperty("building_id")&&(Me.buildingId=m.properties.building_id);const Ce=this.layers[0].paint.get("fill-extrusion-base").evaluate(m,{},A)<=0,ze=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},A);let Ve;if(Me.height=ze,Me.vertexArrayOffset=this.layoutVertexArray.length,Me.groundVertexArrayOffset=this.groundEffect.vertexArray.length,ae&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new AS),this.wallMode){if(ae)return void cr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(y.length!==1)return;Ve=function(qt){const us=qt[0].x===qt[qt.length-1].x&&qt[0].y===qt[qt.length-1].y;(function(mr){let vr=0;const Dn=mr.length;for(let zs=0;zs=0})(qt)||(qt=qt.reverse());const xs={geometry:[],joinNormals:[],indices:[]},As=[],Is=[],Ns=[];let Ms=qt.length;for(;Ms>=2&&qt[Ms-1].equals(qt[Ms-2]);)Ms--;if(Ms<(us?3:2))return xs;let ds,as,Ts,Ws,Rs,Mr=0;for(;Mr0;let an="miter";const oa=2;an==="miter"&&zs>oa&&(an="bevel"),an==="bevel"&&(zs>100&&(an="flipbevel"),zs{const hs=new cs(Nn.x,Nn.y),Es=new cs(Nn.x,Nn.y);hs.x+=di.x*bt,hs.y+=di.y*bt,Es.x-=di.x*Math.max(pt,1),Es.y-=di.y*Math.max(pt,1),Ns.push(di),As.push(hs),Is.push(Es)};if(an==="miter")vr._mult(zs),ha(ds,vr,0,0);else if(an==="flipbevel")vr=Rs.mult(-1),ha(ds,vr,0,0),ha(ds,vr.mult(-1),0,0);else{const Nn=-Math.sqrt(zs*zs-1),di=_r?Nn:0,pt=_r?0:Nn;as&&ha(ds,Ws,di,pt),Ts&&ha(ds,Rs,di,pt)}}xs.geometry=[...As,...Is.reverse(),As[0]],xs.joinNormals=[...Ns,...Ns.reverse(),Ns[Ns.length-1]];const or=xs.geometry.length-1;for(let mr=0;mrqt<(us.length-1)/2||qt===us.length-1,vt=this.wallMode?[y]:NT(y,500);for(let qt=vt.length-1;qt>=0;qt--){const us=vt[qt];(us.length===0||(mt=us[0]).every(gs=>gs.x<=0)||mt.every(gs=>gs.x>=Hs)||mt.every(gs=>gs.y<=0)||mt.every(gs=>gs.y>=Hs))&&vt.splice(qt,1)}var mt;let St;if(ae)St=R2e(vt,Q,A);else{St=[];for(const qt of vt)St.push({polygon:qt,bounds:Q})}const It=le?this.edgeRadius:0,Ot=It>0&&this.zoom<17,ns=(qt,us)=>{if(qt.length===0)return!1;const gs=qt[qt.length-1];return us.x===gs.x&&us.y===gs.y};for(const{polygon:qt,bounds:us}of St){let gs=0,xs=0;for(const Ms of qt)le&&!Ms[0].equals(Ms[Ms.length-1])&&Ms.push(Ms[0]),xs+=le?Ms.length-1:Ms.length;const As=this.segments.prepareSegment((le?5:4)*xs,this.layoutVertexArray,this.indexArray);Me.footprintSegIdx<0&&(Me.footprintSegIdx=this.footprintSegments.length),Me.polygonSegIdx<0&&(Me.polygonSegIdx=this.polygonSegments.length);const Is={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ns=new C2e;if(Ns.vertexOffset=this.footprintVertices.length,Ns.indexOffset=3*this.footprintIndices.length,Ns.ringIndices=[],le){const Ms=[],ds=[];gs=As.vertexLength;for(let Ts=0;Ts4&&L2e(ds[ds.length-2],ds[0],ds[1]),Ts=It?BQe(ds[ds.length-2],ds[0],ds[1],It):0;const Ws=[];let Rs,Mr,or;Mr=ds[1].sub(ds[0])._perp()._unit();let mr=!0;for(let vr=1,Dn=0;vr0?1:0,di=zs.dist(_r);if(Dn+di>32768&&(Dn=0),It){or=an.sub(_r)._perp()._unit();let Es=I2e(zs,_r,an,E2e(Mr,or),It);isNaN(Es)&&(Es=0);const sr=_r.sub(zs)._unit();zs=zs.add(sr.mult(Ts))._round(),_r=_r.add(sr.mult(-Es))._round(),Ts=Es,Mr=or,Ce&&this.zoom>=17&&(ns(Ws,zs)||Ws.push(zs),ns(Ws,_r)||Ws.push(_r))}const pt=As.vertexLength,bt=ds.length>4&&L2e(zs,_r,an);let hs=D2e(Dn,as,mr);if(CT(this.layoutVertexArray,zs.x,zs.y,ha,Nn,0,0,hs),CT(this.layoutVertexArray,zs.x,zs.y,ha,Nn,0,1,hs),this.wallMode){const Es=Je(vr-1,ds),sr=Ve.joinNormals[vr-1];MT(this.wallVertexArray,sr,Es),MT(this.wallVertexArray,sr,Es)}if(Dn+=di,hs=D2e(Dn,bt,!mr),as=bt,CT(this.layoutVertexArray,_r.x,_r.y,ha,Nn,0,0,hs),CT(this.layoutVertexArray,_r.x,_r.y,ha,Nn,0,1,hs),this.wallMode){const Es=Je(vr,ds),sr=Ve.joinNormals[vr];MT(this.wallVertexArray,sr,Es),MT(this.wallVertexArray,sr,Es)}if(As.vertexLength+=4,this.indexArray.emplaceBack(pt+0,pt+1,pt+2),this.indexArray.emplaceBack(pt+1,pt+3,pt+2),As.primitiveLength+=2,It){const Es=gs+(vr===1?ds.length-2:vr-2),sr=vr===1?gs:Es+1;if(this.indexArray.emplaceBack(pt+1,Es,pt+3),this.indexArray.emplaceBack(Es,sr,pt+3),As.primitiveLength+=2,Rs===void 0&&(Rs=pt),!Uce(an,ds[vr],us)){const rr=vr===ds.length-1?Rs:As.vertexLength;this.indexArray.emplaceBack(pt+2,pt+3,rr),this.indexArray.emplaceBack(pt+3,rr+1,rr),this.indexArray.emplaceBack(pt+3,sr,rr+1),As.primitiveLength+=3}mr=!mr}if(ae){const Es=this.layoutVertexExtArray,sr=se.projectTilePoint(zs.x,zs.y,A),rr=se.projectTilePoint(_r.x,_r.y,A),Ar=se.upVector(A,zs.x,zs.y),Lr=se.upVector(A,_r.x,_r.y);TT(Es,sr,Ar),TT(Es,sr,Ar),TT(Es,rr,Lr),TT(Es,rr,Lr)}}le&&(gs+=ds.length-1),Ce&&It&&this.zoom>=17&&(Ws.length!==0&&ns(Ws,Ws[0])&&Ws.pop(),this.groundEffect.addData(Ws,us,X,It>0))}this.footprintSegments.push(Ns),Is.triangleCount=this.indexArray.length-Is.triangleArrayOffset,this.polygonSegments.push(Is),++Me.footprintSegLen,++Me.polygonSegLen}if(Me.vertexCount=this.layoutVertexArray.length-Me.vertexArrayOffset,Me.groundVertexCount=this.groundEffect.vertexArray.length-Me.groundVertexArrayOffset,Me.vertexCount!==0){if(Me.centroidXY=xe.borders?k2e:this.encodeCentroid(xe,Me),this.centroidData.push(Me),xe.borders){this.featuresOnBorder.push(xe);const qt=this.featuresOnBorder.length-1;for(let us=0;usthis.featuresOnBorder[m].borders[c][0]-this.featuresOnBorder[y].borders[c][0])}splitToSubtiles(){const c=[];for(let O=0;OHs),X=2*q+(+(z.min.x+z.max.x>Hs)^q);for(let Q=0;QO.triangleSegmentIdx===z.triangleSegmentIdx?O.subtile-z.subtile:O.triangleSegmentIdx-z.triangleSegmentIdx);let y=0,b=0,A=0;for(const O of c){if(O.triangleSegmentIdx!==y)break;A++}const I=c.length;for(;b!==c.length;){y=c[b].triangleSegmentIdx;let O=0,z=b,q=b;for(let X=z;X0&&this.triangleSubSegments.push({segment:ae,min:Q,max:se}),z=q;for(let le=z;le[xe[0]*(1-Ce[0])+Me[0]*Ce[0],xe[1]*(1-Ce[1])+Me[1]*Ce[1]],ae=[],le=[];for(const xe of this.triangleSubSegments){ae[0]=xe.min.x/Hs,ae[1]=xe.min.y/Hs,le[0]=xe.max.x/Hs,le[1]=xe.max.y/Hs;const Me=se(X,Q,ae),Ce=se(X,Q,le);if(new Nr([Me[0],Me[1],A],[Ce[0],Ce[1],I]).intersectsPrecise(y)===0){q&&(b.segments.push(q),q=void 0);continue}const ze=xe.segment;q&&q.vertexOffset!==ze.vertexOffset&&(b.segments.push(q),q=void 0),q?(q.vertexLength+=ze.vertexLength,q.primitiveLength+=ze.primitiveLength):q={vertexOffset:ze.vertexOffset,primitiveLength:ze.primitiveLength,vertexLength:ze.vertexLength,primitiveOffset:ze.primitiveOffset,sortKey:void 0,vaos:{}}}return q&&b.segments.push(q),b}encodeCentroid(c,m){const y=c.centroid(),b=m.span(),A=Math.min(7,Math.round(b.x*this.tileToMeter/10)),I=Math.min(7,Math.round(b.y*this.tileToMeter/10));return new cs(_e(y.x,1,Hs-1)<<3|A,_e(y.y,1,Hs-1)<<3|I)}encodeBorderCentroid(c){if(!c.borders)return new cs(0,0);const m=c.borders,y=Number.MAX_VALUE;if(m[0][0]!==y||m[1][0]!==y){const b=m[0][0]!==y?0:1;return new cs(6|(m[0][0]!==y?0:65528),(m[b][0]+m[b][1])/2<<3|6)}{const b=m[2][0]!==y?2:3;return new cs((m[b][0]+m[b][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,b=c.flags&xy?k2e:c.centroidXY,A=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==b.y||A!==b.x){for(let I=m;Iz.max.x||z.min.x>I.max.x||I.min.y>z.max.y||z.min.y>I.max.y||I.footprint.buildingIds.has(z.buildingId)&&(z.flags|=xy);else for(const z of this.centroidData)if(!(z.flags&xy||I.min.x>z.max.x||z.min.x>I.max.x||I.min.y>z.max.y||z.min.y>I.max.y))for(let q=0;qm!=ae>m&&c<(this.footprintVertices.int16[2*(X+I.vertexOffset)+0]-Q)*(m-se)/(ae-se)+Q&&(b=!b)}O=z}}return b}getHeightAtTileCoord(c,m){let y=Number.NEGATIVE_INFINITY,b=!0;const A=4*(c+Hs)*Hs+(m+Hs);if(this.partLookup.hasOwnProperty(A)){const I=this.partLookup[A];return I?{height:I.height,hidden:!!(I.flags&xy)}:void 0}for(const I of this.centroidData)c>I.max.x||I.min.x>c||m>I.max.y||I.min.y>m||I.height<=y||this.footprintContainsPoint(c,m,I)&&(y=I.height,this.partLookup[A]=I,b=!!(I.flags&xy));if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:b};this.partLookup[A]=void 0}}function E2e(p,c){const m=p.add(c)._unit();return p.x*m.x+p.y*m.y}function BQe(p,c,m,y){const b=c.sub(p)._perp()._unit(),A=m.sub(c)._perp()._unit();return I2e(p,c,m,E2e(b,A),y)}function I2e(p,c,m,y,b){const A=Math.sqrt(1-y*y);return Math.min(p.dist(c)/3,c.dist(m)/3,b*A/y)}function Uce(p,c,m){return p.xm[1].x&&c.x>m[1].x||p.ym[1].y&&c.y>m[1].y}function P2e(p,c){return p.xc[1].x||p.yc[1].y}function L2e(p,c,m){if(p.x<0||p.x>=Hs||c.x<0||c.x>=Hs||m.x<0||m.x>=Hs)return!1;const y=m.sub(c),b=y.perp(),A=p.sub(c);return(y.x*A.x+y.y*A.y)/Math.sqrt((y.x*y.x+y.y*y.y)*(A.x*A.x+A.y*A.y))>-.866&&b.x*A.x+b.y*A.y<0}function D2e(p,c,m){const y=c?2|p:-3&p;return m?1|y:-2&y}function O2e(){const p=Math.PI/32,c=Math.tan(p),m=N;return m*Math.sqrt(1+2*c*c)-m}function R2e(p,c,m){const y=1<{for(const It of mt)le.push({polygon:It,bounds:St})},Me=Math.ceil(Math.log2(X)),Ce=Math.ceil(Math.log2(Q)),ze=Me-Ce,Ve=[];for(let mt=0;mt0?0:1);for(let mt=0;mtSt+1?vt.push({polygons:xs,bounds:Is,depth:St+1}):xe(xs,Is)}if(As.length){const Is=[new cs(It===0?gs:Ot.x,It===1?gs:Ot.y),ns];Ve.length>St+1?vt.push({polygons:As,bounds:Is,depth:St+1}):xe(As,Is)}}return le}(p,c,Math.ceil((A-b)/11.25),Math.ceil((I-O)/11.25),1,(z,q,X)=>{if(z===0)return .5*(q+X);{const Q=pe((m.y+q/Hs)/y);return(K(.5*(pe((m.y+X/Hs)/y)+Q))*y-m.y)*Hs}})}function $Qe(p,c,m,y,b,A){const I=Math.pow(2,y.z-b.z);for(let O=0;O=z[I]&&(O=c,z=p),O[I]b&&$2e(O,z,I,b),O[I]A&&$2e(z,O,I,A)}}function SD(p,c,m,y,b,A){const I=[];for(let O=0;O=y&&le.x>=y||(ae.x>=y?ae=new cs(y,ae.y+(y-ae.x)/(le.x-ae.x)*(le.y-ae.y))._round():le.x>=y&&(le=new cs(y,ae.y+(y-ae.x)/(le.x-ae.x)*(le.y-ae.y))._round()),ae.y>=b&&le.y>=b||(ae.y>=b?ae=new cs(ae.x+(b-ae.y)/(le.y-ae.y)*(le.x-ae.x),b)._round():le.y>=b&&(le=new cs(ae.x+(b-ae.y)/(le.y-ae.y)*(le.x-ae.x),b)._round()),q&&ae.equals(q[q.length-1])||(q=[ae],I.push(q),A&&A.push({progress:{min:Me+q2e(Ce,ze,ae)*xe,max:1},parentIndex:O,prevPoint:Ce,nextPoint:ze})),q.push(le),A&&(A[A.length-1].progress.max=Me+q2e(Ce,ze,le)*xe,A[A.length-1].nextPoint=ze)))))}if(A&&Q>0)for(let se=X;seq.t-X.t);let I=0,O=0,z=[];for(y.push(z);I!==p.length;){if(O===A.length){for(;I!==p.length;)z.length!==0&&z[z.length-1].equals(p[I])||z.push(p[I]),I++;break}A[O].t<=I?(z.length!==0&&z[z.length-1].equals(A[O].point)||z.push(A[O].point),Math.trunc(A[O].t),O++):(z.length!==0&&z[z.length-1].equals(p[I])||z.push(p[I]),I++)}}function q2e(p,c,m){return p.x!==c.x?(m.x-p.x)/(c.x-p.x):p.y!==c.y?(m.y-p.y)/(c.y-p.y):0}function AT(p,c){return p.x*c.x+p.y*c.y}function V2e(p,c){if(p.length===1){let m=0;const y=c[m++];let b;for(;!b||y.equals(b);)if(b=c[m++],!b)return 1/0;for(;m{gs[0]=xs,gs[1]=As,gs[2]=Is,gs[3]=1},us=O2e();ae>0&&(ae+=us),le+=us;for(const gs of se){const xs=[],As=[];for(const Is of gs){const Ns=Is.x+xe.x,Ms=Is.y+xe.y,ds=Q.projection.projectTilePoint(Ns,Ms,vt),as=Q.projection.upVector(vt,Is.x,Is.y);let Ts=ae,Ws=le;if(Ce){const Rs=G2e(Ns,Ms,ae,le,Ce,ze,Ve,Je);Ts+=Rs.base,Ws+=Rs.top}ae!==0?qt(Ot,ds.x+as[0]*It*Ts,ds.y+as[1]*It*Ts,ds.z+as[2]*It*Ts):qt(Ot,ds.x,ds.y,ds.z),qt(ns,ds.x+as[0]*It*Ws,ds.y+as[1]*It*Ws,ds.z+as[2]*It*Ws),st(Ot,Ot,Me),st(ns,ns,Me),xs.push(new sb(Ot[0],Ot[1],Ot[2])),As.push(new sb(ns[0],ns[1],ns[2]))}mt.push(xs),St.push(As)}return[mt,St]}(p,c,m,y,b,A,I,O,z,q,X):I?function(Q,se,ae,le,xe,Me,Ce,ze,Ve){const Je=[],vt=[],mt=[0,0,0,1];for(const St of Q){const It=[],Ot=[];for(const ns of St){const qt=ns.x+le.x,us=ns.y+le.y,gs=G2e(qt,us,se,ae,Me,Ce,ze,Ve);mt[0]=qt,mt[1]=us,mt[2]=gs.base,mt[3]=1,ut(mt,mt,xe),mt[3]=Math.max(mt[3],1e-5);const xs=new sb(mt[0]/mt[3],mt[1]/mt[3],mt[2]/mt[3]);mt[0]=qt,mt[1]=us,mt[2]=gs.top,mt[3]=1,ut(mt,mt,xe),mt[3]=Math.max(mt[3],1e-5);const As=new sb(mt[0]/mt[3],mt[1]/mt[3],mt[2]/mt[3]);It.push(xs),Ot.push(As)}Je.push(It),vt.push(Ot)}return[Je,vt]}(c,m,y,b,A,I,O,z,q):function(Q,se,ae,le,xe){const Me=[],Ce=[],ze=xe[8]*se,Ve=xe[9]*se,Je=xe[10]*se,vt=xe[11]*se,mt=xe[8]*ae,St=xe[9]*ae,It=xe[10]*ae,Ot=xe[11]*ae;for(const ns of Q){const qt=[],us=[];for(const gs of ns){const xs=gs.x+le.x,As=gs.y+le.y,Is=xe[0]*xs+xe[4]*As+xe[12],Ns=xe[1]*xs+xe[5]*As+xe[13],Ms=xe[2]*xs+xe[6]*As+xe[14],ds=xe[3]*xs+xe[7]*As+xe[15],as=Is+ze,Ts=Ns+Ve,Ws=Ms+Je,Rs=Math.max(ds+vt,1e-5),Mr=Is+mt,or=Ns+St,mr=Ms+It,vr=Math.max(ds+Ot,1e-5);qt.push(new sb(as/Rs,Ts/Rs,Ws/Rs)),us.push(new sb(Mr/vr,or/vr,mr/vr))}Me.push(qt),Ce.push(us)}return[Me,Ce]}(c,m,y,b,A)}function G2e(p,c,m,y,b,A,I,O){const z=I*b.getElevationAt(p,c,!0,!0),q=A[0]!==0,X=q?A[1]===0?I*(A[0]/N2e-S2e):I*function(Q,se,ae){const le=Math.floor(se[0]/8),xe=Math.floor(se[1]/8),Me=10*(se[0]-8*le),Ce=10*(se[1]-8*xe),ze=Q.getElevationAt(le,xe,!0,!0),Ve=Q.getMeterToDEM(ae),Je=Math.floor(.5*(Me*Ve-1)),vt=Math.floor(.5*(Ce*Ve-1)),mt=Q.tileCoordToPixel(le,xe),St=2*Je+1,It=2*vt+1,Ot=function(As,Is,Ns,Ms,ds){return[As.getElevationAtPixel(Is,Ns,!0),As.getElevationAtPixel(Is+ds,Ns,!0),As.getElevationAtPixel(Is,Ns+ds,!0),As.getElevationAtPixel(Is+Ms,Ns+ds,!0)]}(Q,mt.x-Je,mt.y-vt,St,It),ns=Math.abs(Ot[0]-Ot[1]),qt=Math.abs(Ot[2]-Ot[3]),us=Math.abs(Ot[0]-Ot[2])+Math.abs(Ot[1]-Ot[3]),gs=Math.min(.25,.5*Ve*(ns+qt)/St),xs=Math.min(.25,.5*Ve*us/It);return ze+Math.max(gs*Me,xs*Ce)}(b,A,O):z;return{base:z+(m===0?-1:m),top:q?Math.max(X+y,z+m+2):z+y}}class qQe{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 VQe{constructor(){this.tasks={},this.taskQueue=[],Ft(["process"],this),this.invoker=new qQe(this.process),this.nextId=0}add(c,m){const y=this.nextId++,b=function({type:A,isSymbolTile:I,zoom:O}){return O=O||0,A==="message"?0:A!=="maybePrepare"||I?A!=="parseTile"||I?A==="parseTile"&&I?300-O:A==="maybePrepare"&&I?400-O:500:200-O:100-O}(m);if(b===0){try{c()}finally{}return null}return this.tasks[y]={fn:c,metadata:m,priority:b,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 b=0;b{y&&delete this.callbacks[O],this.target.postMessage({id:O,type:"",targetMapId:b,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 b=this.cancelCallbacks[y];delete this.cancelCallbacks[y],b&&b.cancel()}else if(m.mustQueue||aa(self)){const b=this.callbacks[y],A=this.scheduler.add(()=>this.processTask(y,m),b&&b.metadata||{type:"message"});A&&(this.cancelCallbacks[y]=A)}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(Wg(m.error)):y(null,Wg(m.data)))}else{const y=new Set,b=m.hasCallback?(I,O)=>{this.target.postMessage({id:c,type:"",sourceMapId:this.mapId,error:I?xf(I):null,data:xf(O,y)},y)}:()=>{},A=Wg(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,A,b);else if(this.parent.getWorkerSource){const I=m.type.split("."),{source:O,scope:z}=A;this.parent.getWorkerSource(m.sourceMapId,I[0],O,z)[I[1]](A,b)}else b(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var ET={workerUrl:"",workerClass:null,workerParams:void 0};const qce="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[qce]}numActive(){return Object.keys(this.active).length}}rb.workerCount=2;class YS{constructor(c,m,y="Worker",b=rb.workerCount){this.workerPool=c,this.actors=[],this.currentActor=0,this.id=Dt();const A=this.workerPool.acquire(this.id,b);for(let I=0;I{this.ready=!0})}broadcast(c,m,y){Tt(this.actors,(b,A)=>{b.send(c,m,A)},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 IT,Vce;function CD(){return IT||(IT=new rb),IT}YS.Actor=K2e;const Hce=4096;class HQe{constructor(c){this.module=c,this.memoryStack=this.module.malloc(Hce),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Hce?-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>Hce?-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 z=this.createIntArray(O.ringIndices),q=this.createFloatArray(O.coordinates);if(z===-1||q===-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,q,z,O.ringIndices.length-1)}for(const O of m){let z;z=O.entrances?JSON.parse(O.entrances):[];const q=this.createFloatArray(z),X=this.createFloatArray(O.coordinates);if(q===-1||X===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(O.sourceId,O.crossPerc,O.distanceToRoad,q,z.length,X,O.coordinates.length)}if(!this.module.generateMesh()){const O=this.module.getLastError();return this.readStringBuffer(O)}const y=this.module.getMeshCount(),b=new Array(y);for(let O=0;Ob.arrayBuffer()).then(b=>{c.buffers[m]=b})}function sje(p,c){const m=p.json.bufferViews[c];return new Uint8Array(p.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function XQe(p,c,m,y){if(p.uri){const b=tje(p.uri,y);return fetch(b).then(A=>A.blob()).then(A=>createImageBitmap(A)).then(A=>{c.images[m]=A})}if(p.bufferView!==void 0){const b=sje(c,p.bufferView),A=new Blob([b],{type:p.mimeType});return createImageBitmap(A).then(I=>{c.images[m]=I})}}function rje(p,c=0,m){const y={json:null,images:[],buffers:[]};if(new Uint32Array(p,c,1)[0]===J2e){const X=new Uint32Array(p,c);let Q=2;const se=(X[Q++]>>2)-3,ae=X[Q++]>>2;if(Q++,y.json=JSON.parse(eje.decode(X.subarray(Q,Q+ae))),Q+=ae,Q{const X=[],Q=O&&O.includes(Kce),se=O&&O.includes(AD);if(Q&&X.push(function(){if(!Tf)return PT??(PT=function(ae){let le,xe=null;function Me(){le=new Uint8Array(xe.buffer)}function Ce(){throw new Error("Unexpected Draco error.")}const ze={a:{a:Ce,d:function(Ve,Je,vt){return le.copyWithin(Ve,Je,Je+vt)},c:function(Ve){const Je=le.length,vt=Math.max(Ve>>>0,Math.ceil(1.2*Je)),mt=Math.ceil((vt-Je)/65536);try{return xe.grow(mt),Me(),!0}catch{return!1}},b:Ce}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(ae,ze):ae.then(Ve=>Ve.arrayBuffer()).then(Ve=>WebAssembly.instantiate(Ve,ze))).then(Ve=>{const{Rb:Je,Qb:vt,P:mt,T:St,X:It,Ja:Ot,La:ns,Qa:qt,Va:us,Wa:gs,eb:xs,jb:As,f:Is,e:Ns,yb:Ms,zb:ds,Ab:as,Bb:Ts,Db:Ws,Gb:Rs}=Ve.instance.exports;xe=Ns;const Mr=(()=>{let or=0,mr=0,vr=0,Dn=0;return zs=>{vr&&(Je(Dn),Je(or),mr+=vr,vr=or=0),or||(mr+=128,or=vt(mr));const _r=zs.length+7&-8;let an=or;_r>=mr&&(vr=_r,an=Dn=vt(_r));for(let oa=0;oa{Tf=ae,PT=void 0}))}()),se&&X.push(function(){if(Gce)return;const ae=function(le){let xe;const Me=WebAssembly.instantiateStreaming(le,{}).then(Ve=>{xe=Ve.instance,xe.exports.__wasm_call_ctors()}),Ce={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},ze={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Me,supported:!0,decodeGltfBuffer(Ve,Je,vt,mt,St,It){(function(Ot,ns,qt,us,gs,xs,As){const Is=Ot.exports.sbrk,Ns=us+3&-4,Ms=Is(Ns*gs),ds=Is(xs.length),as=new Uint8Array(Ot.exports.memory.buffer);as.set(xs,ds);const Ts=ns(Ms,us,gs,ds,xs.length);if(Ts===0&&As&&As(Ms,Ns,gs),qt.set(as.subarray(Ms,Ms+us*gs)),Is(Ms-Is(0)),Ts!==0)throw new Error(`Malformed buffer data: ${Ts}`)})(xe,xe.exports[ze[St]],Ve,Je,vt,mt,xe.exports[Ce[It]])}}}(fetch(X2e()));return ae.ready.then(()=>{Gce=ae})}()),A)for(let ae=0;ae{if(Q&&I)for(const{primitives:ae}of I)for(const le of ae)KQe(le,y);if(se&&I&&z)for(const ae of z)ZQe(ae,y);return y})})}function nje(p){return fetch(p).then(c=>c.arrayBuffer()).then(c=>rje(c,0,p))}function Zce(p){switch(p){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 Yce(p){switch(p){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 Xce{constructor(c,m,y,b){this.context=c,this.format=y,this.useMipmap=b&&b.useMipmap,this.texture=c.gl.createTexture(),this.update(m,{premultiply:b&&b.premultiply})}update(c,m){const y=c&&c instanceof HTMLVideoElement&&c.width===0?c.videoWidth:c.width,b=c&&c instanceof HTMLVideoElement&&c.height===0?c.videoHeight:c.height,{context:A}=this,{gl:I}=A,{x:O,y:z}=m&&m.position?m.position:{x:0,y:0},q=O+y,X=z+b;!this.size||this.size[0]===q&&this.size[1]===X||(I.bindTexture(I.TEXTURE_2D,null),I.deleteTexture(this.texture),this.texture=I.createTexture(),this.size=null),I.bindTexture(I.TEXTURE_2D,this.texture),A.pixelStoreUnpackFlipY.set(!1),A.pixelStoreUnpack.set(1),A.pixelStoreUnpackPremultiplyAlpha.set(this.format===I.RGBA8&&(!m||m.premultiply!==!1));const Q=c instanceof HTMLImageElement||c instanceof HTMLCanvasElement||c instanceof HTMLVideoElement||c instanceof ImageData||ImageBitmap&&c instanceof ImageBitmap;if(!this.size&&q>0&&X>0){const se=this.useMipmap?Math.floor(Math.log2(Math.max(q,X)))+1:1;I.texStorage2D(I.TEXTURE_2D,se,this.format,q,X),this.size=[q,X]}this.size&&(Q?I.texSubImage2D(I.TEXTURE_2D,0,O,z,Zce(this.format),Yce(this.format),c):"data"in c&&c.data&&I.texSubImage2D(I.TEXTURE_2D,0,O,z,y,b,Zce(this.format),Yce(this.format),c.data)),this.useMipmap&&I.generateMipmap(I.TEXTURE_2D)}bind(c,m,y=!1){const{context:b}=this,{gl:A}=b;A.bindTexture(A.TEXTURE_2D,this.texture),c!==this.minFilter&&(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MAG_FILTER,c),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MIN_FILTER,this.useMipmap&&!y?c===A.NEAREST?A.NEAREST_MIPMAP_NEAREST:A.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),m!==this.wrapS&&(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_S,m),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_T,m),this.wrapS=m)}bindExtraParam(c,m,y,b,A){const{context:I}=this,{gl:O}=I;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),b!==this.wrapT&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,b),this.wrapT=b),A!==this.compareMode&&(A?(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_MODE,O.COMPARE_REF_TO_TEXTURE),O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_FUNC,A)):O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_MODE,O.NONE),this.compareMode=A)}destroy(){const{gl:c}=this.context;c.deleteTexture(this.texture),this.texture=null}}class DT{constructor(c,m){this.context=c,this.texture=m}bind(c,m){const{context:y}=this,{gl:b}=y;b.bindTexture(b.TEXTURE_2D,this.texture),c!==this.minFilter&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,c),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,c),this.minFilter=c),m!==this.wrapS&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,m),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,m),this.wrapS=m)}}const QQe=ea([{name:"a_pos_3f",components:3,type:"Float32"}]),JQe=ea([{name:"a_color_3f",components:3,type:"Float32"}]),eJe=ea([{name:"a_color_4f",components:4,type:"Float32"}]),tJe=ea([{name:"a_uv_2f",components:2,type:"Float32"}]),sJe=ea([{name:"a_normal_3f",components:3,type:"Float32"}]),rJe=ea([{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"}]),nJe=ea([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function aje(p,c){const m=ED(p.projection,p.zoom,p.width,p.height),y=function(A,I,O,z,q){const X=new x(O.lng-180*dv,O.lat),Q=new x(O.lng+180*dv,O.lat),se=A.project(X.lng,X.lat),ae=A.project(Q.lng,Q.lat),le=-Math.atan2(ae.y-se.y,ae.x-se.x),xe=Ze.fromLngLat(O);xe.y=_e(xe.y,-1+dv,1-dv);const Me=xe.toLngLat(),Ce=A.project(Me.lng,Me.lat),ze=Ze.fromLngLat(Me);ze.x+=dv;const Ve=ze.toLngLat(),Je=A.project(Ve.lng,Ve.lat),vt=oje(Je.x-Ce.x,Je.y-Ce.y,le),mt=Ze.fromLngLat(Me);mt.y+=dv;const St=mt.toLngLat(),It=A.project(St.lng,St.lat),Ot=oje(It.x-Ce.x,It.y-Ce.y,le),ns=Math.abs(vt.x)/Math.abs(Ot.y),qt=k([]);$(qt,qt,-le*(1-(q?0:z)));const us=k([]);return D(us,us,[1,1-(1-ns)*z,1]),us[4]=-Ot.x/Ot.y*z,$(us,us,le),S(us,qt,us),us}(p.projection,0,p.center,m,c),b=ije(p);return D(y,y,[b,b,1]),y}function ije(p){const c=p.projection,m=ED(p.projection,p.zoom,p.width,p.height),y=Qce(c,p.center),b=Qce(c,x.convert(c.center));return Math.pow(2,y*m+(1-m)*b)}function ED(p,c,m,y,b=1/0){const A=p.range;if(!A)return 0;const I=Math.min(b,Math.max(m,y)),O=Math.log2(I/1024);return Pe(A[0]+O,A[1]+O,c)}const dv=1/4e4;function Qce(p,c){const m=_e(c.lat,-fe,fe),y=new x(c.lng-180*dv,m),b=new x(c.lng+180*dv,m),A=p.project(y.lng,m),I=p.project(b.lng,m),O=Ze.fromLngLat(y),z=Ze.fromLngLat(b),q=I.x-A.x,X=I.y-A.y,Q=z.x-O.x,se=z.y-O.y,ae=Math.sqrt((Q*Q+se*se)/(q*q+X*X));return Math.log2(ae)}function oje(p,c,m){const y=Math.cos(m),b=Math.sin(m);return{x:p*y-c*b,y:p*b+c*y}}function lje(p,c,m){k(p),$(p,p,Or(c[2])),L(p,p,Or(c[0])),B(p,p,Or(c[1])),D(p,p,m),S(p,p,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function ID(p,c,m,y,b,A,I,O){const z=[m[0]-c[0],m[1]-c[1],0],q=[y[0]-c[0],y[1]-c[1],0];if(de(z)<1e-12||de(q)<1e-12)return _t(p);const X=wt([],z,q);De(X,X),ge(q,y,c),z[2]=(A-b)*O,q[2]=(I-b)*O;const Q=z;return wt(Q,z,q),De(Q,Q),fs(p,X,Q)}function PD(p,c,m=!1){const y=lv(c.zoom),b=function(A,I,O){const z=I.worldSize,q=[A[12],A[13],A[14]],X=pe(q[1]/z),Q=re(q[0]/z),se=k([]),ae=te(1,X)*z,le=te(1,0)*z*we(X,I.zoom),xe=1/Cce(z);let Me=le*xe;if(O){const Je=ED(I.projection,I.zoom,I.width,I.height,1024);Me=xe*I.projection.pixelSpaceConversion(I.center.lat,z,Je)}const Ce=av(X,Q);ce(Ce,Ce,Se([],De([],Ce),ae*Me*q[2]));const ze=function(Je){const vt=[Je[0],Je[1],Je[2]];let mt=[0,1,0];const St=wt([],mt,vt);return wt(mt,vt,St),He(mt)===0&&(mt=[0,1,0],wt(St,vt,mt)),De(St,St),De(mt,mt),De(vt,vt),[St[0],St[1],St[2],0,mt[0],mt[1],mt[2],0,vt[0],vt[1],vt[2],0,Je[0],Je[1],Je[2],1]}(Ce);D(se,se,[Me,Me,Me*ae]),E(se,se,[-q[0],-q[1],-q[2]]);const Ve=S([],I.globeMatrix,ze);return S(Ve,Ve,se),S(Ve,Ve,A),Ve}(p,c,m);if(y>0){const A=function(I,O){const z=O.worldSize,q=te(1,0)*z*we(O.center.lat,O.zoom)/Cce(z),X=te(1,O.center.lat)*z,Q=k([]);B(Q,Q,Or(O.center.lng)),L(Q,Q,Or(O.center.lat)),E(Q,Q,[0,0,ed]),D(Q,Q,[q,q,q*X]);const se=O.point;return E(Q,Q,[-se.x,-se.y,0]),S(Q,Q,I),S(Q,O.globeMatrix,Q)}(p,c);return function(I,O,z){const q=(le,xe,Me)=>{const Ce=de(le),ze=de(xe),Ve=Mf(le,xe,Me);return Se(Ve,Ve,1/de(Ve)*Jr(Ce,ze,Me))},X=q([I[0],I[1],I[2]],[O[0],O[1],O[2]],z),Q=q([I[4],I[5],I[6]],[O[4],O[5],O[6]],z),se=q([I[8],I[9],I[10]],[O[8],O[9],O[10]],z),ae=Mf([I[12],I[13],I[14]],[O[12],O[13],O[14]],z);return[X[0],X[1],X[2],0,Q[0],Q[1],Q[2],0,se[0],se[1],se[2],0,ae[0],ae[1],ae[2],1]}(b,A,y)}return b}function Jce(p,c,m,y){const b=Nr.projectAabbCorners(y,m);let A=Number.MAX_VALUE;for(let O=0;O0||Me===0&&le[0]*xe[0]+le[1]*xe[1]>=0&&le[0]*le[0]+le[1]*le[1]>xe[0]*xe[0]+xe[1]*xe[1])&&(X=ae)}Q=X}while(Q!==q);return z.length>0&&z.push(z[0]),z}(b);if(Na(p,I))return A}const nb=64,eC={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function LD(p,c,m,y,b,A,I,O,z,q=!1){const X=m.zoom,Q=m.project(y),se=we(y.lat,X),ae=1/se;k(p),E(p,p,[Q.x+I[0]*ae,Q.y+I[1]*ae,I[2]]);let le=1,xe=1;const Me=m.worldSize;if(q){if(m.projection.name==="mercator"){let Je=0;m.elevation&&(Je=m.elevation.getAtPointOrZero(new Ze(Q.x/Me,Q.y/Me),0));const vt=ut([],[Q.x,Q.y,Je,1],m.projMatrix)[3]/m.cameraToCenterDistance;le=vt,xe=vt*we(m.center.lat,X)}else if(m.projection.name==="globe"){const Je=PD(p,m),vt=[0,0,0,1];ut(vt,vt,S([],m.projMatrix,Je));const mt=vt[3]/m.cameraToCenterDistance,St=lv(X),It=m.projection.pixelsPerMeter(y.lat,Me)*we(y.lat,X),Ot=m.projection.pixelsPerMeter(m.center.lat,Me)*we(m.center.lat,X);le=mt/Jr(It,Ne(m.center.lat),St),xe=mt*se/It,le*=Ot,xe*=Ot}}else le=ae;D(p,p,[le,le,xe]);const Ce=[...p],ze=c.orientation,Ve=[];if(lje(Ve,[ze[0]+(b?b[0]:0),ze[1]+(b?b[1]:0),ze[2]+(b?b[2]:0)],A),S(p,Ce,Ve),O&&m.elevation){let Je=0;const vt=[];if(z&&m.elevation){Je=function(St,It,Ot,ns,qt){const us=It.elevation;if(!us)return 0;const gs=Nr.projectAabbCorners(Ot,ns),xs=te(1,qt.lat)*It.worldSize,As=function(mr,vr){const Dn=[0,0,1],zs=[{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 _r of zs){const an=mr[_r.corners[0]],oa=mr[_r.corners[1]],ha=mr[_r.corners[2]],Nn=[oa[0]-an[0],oa[1]-an[1],vr*(oa[2]-an[2])],di=wt(Nn,Nn,[ha[0]-an[0],ha[1]-an[1],vr*(ha[2]-an[2])]);De(di,di),_r.dotProductWithUp=Ge(di,Dn)}return zs.sort((_r,an)=>_r.dotProductWithUp-an.dotProductWithUp),zs[0].corners}(gs,xs),Is=gs[As[0]],Ns=gs[As[1]],Ms=gs[As[2]],ds=gs[As[3]],as=us.getAtPointOrZero(new Ze(Is[0]/It.worldSize,Is[1]/It.worldSize),0),Ts=us.getAtPointOrZero(new Ze(Ns[0]/It.worldSize,Ns[1]/It.worldSize),0),Ws=us.getAtPointOrZero(new Ze(Ms[0]/It.worldSize,Ms[1]/It.worldSize),0),Rs=us.getAtPointOrZero(new Ze(ds[0]/It.worldSize,ds[1]/It.worldSize),0),Mr=(as+Rs)/2,or=(Ts+Ws)/2;return Mr>or?Ts=c.gl.NEAREST_MIPMAP_NEAREST}),p.uploaded=!0,p.image=null)}function aJe(p,c,m){p.indexBuffer=c.createIndexBuffer(p.indexArray,!1,!0),p.vertexBuffer=c.createVertexBuffer(p.vertexArray,QQe.members,!1,!0),p.normalArray&&(p.normalBuffer=c.createVertexBuffer(p.normalArray,sJe.members,!1,!0)),p.texcoordArray&&(p.texcoordBuffer=c.createVertexBuffer(p.texcoordArray,tJe.members,!1,!0)),p.colorArray&&(p.colorBuffer=c.createVertexBuffer(p.colorArray,(p.colorArray.bytesPerElement===12?JQe:eJe).members,!1,!0)),p.featureArray&&(p.pbrBuffer=c.createVertexBuffer(p.featureArray,nJe.members,!0)),p.segments=ro.simpleSegment(0,0,p.vertexArray.length,p.indexArray.length);const y=p.material;y.pbrMetallicRoughness.baseColorTexture&&OT(y.pbrMetallicRoughness.baseColorTexture,c),y.pbrMetallicRoughness.metallicRoughnessTexture&&OT(y.pbrMetallicRoughness.metallicRoughnessTexture,c),y.normalTexture&&OT(y.normalTexture,c),y.occlusionTexture&&OT(y.occlusionTexture,c,m),y.emissionTexture&&OT(y.emissionTexture,c)}function ede(p,c,m){if(p.meshes)for(const y of p.meshes)aJe(y,c,m);if(p.children)for(const y of p.children)ede(y,c,m)}function DD(p){if(p.meshes)for(const c of p.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(p.children)for(const c of p.children)DD(c)}function tde(p){if(p.meshes)for(const m of p.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(p.children)for(const m of p.children)tde(m)}function ab(p,c){const m=p.json.bufferViews[c.bufferView],y=TD[c.componentType];return new y(p.buffers[m.buffer],(c.byteOffset||0)+(m.byteOffset||0),c.count*(m.byteStride&&m.byteStride!==LT[c.type]*y.BYTES_PER_ELEMENT?m.byteStride/y.BYTES_PER_ELEMENT:LT[c.type]))}function sde(p,c,m,y){const b=TD[c.componentType],A=function(X){switch(X){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(b),I=p.json.bufferViews[c.bufferView],O=I.byteStride?I.byteStride/b.BYTES_PER_ELEMENT:LT[c.type],z=m.float32,q=z.length/m.capacity;for(let X=0,Q=0;X0){for(let Me=0;Me0){A.texcoordArray=new _p;const se=c.json.accessors[b.TEXCOORD_0];A.texcoordArray.resize(se.count);const ae=ab(c,se);sde(c,se,A.texcoordArray,ae)}if(b._FEATURE_ID_RGBA4444!==void 0){const se=c.json.accessors[b._FEATURE_ID_RGBA4444];c.json.extensionsUsed&&c.json.extensionsUsed.includes("EXT_meshopt_compression")&&(A.featureData=ab(c,se))}b._FEATURE_RGBA4444!==void 0&&(A.featureData=new Uint32Array(ab(c,c.json.accessors[b._FEATURE_RGBA4444]).buffer));const Q=p.material;return A.material=function(se,ae){const{emissiveFactor:le=[0,0,0],alphaMode:xe="OPAQUE",alphaCutoff:Me=.5,normalTexture:Ce,occlusionTexture:ze,emissiveTexture:Ve,doubleSided:Je,name:vt}=se,{baseColorFactor:mt=[1,1,1,1],metallicFactor:St=1,roughnessFactor:It=1,baseColorTexture:Ot,metallicRoughnessTexture:ns}=se.pbrMetallicRoughness||{},qt=ze?ae[ze.index]:void 0;if(ze&&ze.extensions&&ze.extensions.KHR_texture_transform&&qt){const us=ze.extensions.KHR_texture_transform;qt.offsetScale=[us.offset[0],us.offset[1],us.scale[0],us.scale[1]]}return{name:vt,pbrMetallicRoughness:{baseColorFactor:new Da(...mt),metallicFactor:St,roughnessFactor:It,baseColorTexture:Ot?ae[Ot.index]:void 0,metallicRoughnessTexture:ns?ae[ns.index]:void 0},doubleSided:Je,emissiveFactor:new Da(...le),alphaMode:xe,alphaCutoff:Me,normalTexture:Ce?ae[Ce.index]:void 0,occlusionTexture:qt,emissionTexture:Ve?ae[Ve.index]:void 0,defined:se.defined===void 0}}(Q!==void 0?c.json.materials[Q]:{defined:!1},m),A}function dje(p,c,m){const{matrix:y,rotation:b,translation:A,scale:I,mesh:O,extras:z,children:q,name:X}=p,Q={};if(Q.name=X,Q.localMatrix=y||function(se,ae,le,xe){var Me=ae[0],Ce=ae[1],ze=ae[2],Ve=ae[3],Je=Me+Me,vt=Ce+Ce,mt=ze+ze,St=Me*Je,It=Me*vt,Ot=Me*mt,ns=Ce*vt,qt=Ce*mt,us=ze*mt,gs=Ve*Je,xs=Ve*vt,As=Ve*mt,Is=xe[0],Ns=xe[1],Ms=xe[2];return se[0]=(1-(ns+us))*Is,se[1]=(It+As)*Is,se[2]=(Ot-xs)*Is,se[3]=0,se[4]=(It-As)*Ns,se[5]=(1-(St+us))*Ns,se[6]=(qt+gs)*Ns,se[7]=0,se[8]=(Ot+xs)*Ms,se[9]=(qt-gs)*Ms,se[10]=(1-(St+ns))*Ms,se[11]=0,se[12]=le[0],se[13]=le[1],se[14]=le[2],se[15]=1,se}([],b||[0,0,0,1],A||[0,0,0],I||[1,1,1]),Q.globalMatrix=w(Q.localMatrix),O!==void 0){Q.meshes=m[O];const se=Q.anchor=[0,0];for(const ae of Q.meshes){const{min:le,max:xe}=ae.aabb;se[0]+=le[0]+xe[0],se[1]+=le[1]+xe[1]}se[0]=Math.floor(se[0]/Q.meshes.length/2),se[1]=Math.floor(se[1]/Q.meshes.length/2)}if(z&&(z.id&&(Q.id=z.id),z.lights&&(Q.lights=function(se){if(!se.length)return[];const ae=function(ze){const Ve=atob(ze),Je=new Uint8Array(Ve.length);for(let vt=0;vt1&&y[y.length-1].equals(y[0])&&y.pop();let b=0;for(let I=0;I0&&y.reverse();const A=KS(y.flatMap(I=>[I.x,I.y]),[]);return A.length===0?null:{vertices:y,indices:A}}function cJe(p,c){const m=[],y=[];let b=0;const A=[];for(const I of p){b=m.length;const O=I.vertexArray.float32,z=I.indexArray.uint16;for(let q=0;q0&&([y[I+1],y[I+2]]=[y[I+2],y[I+1]])}return{vertices:m,indices:y}}function rde(p){const c=function(z,q){const X=[],Q=WebGL2RenderingContext;if(z.json.textures)for(const se of z.json.textures){const ae={magFilter:Q.LINEAR,minFilter:Q.NEAREST,wrapS:Q.REPEAT,wrapT:Q.REPEAT};se.sampler!==void 0&&Object.assign(ae,z.json.samplers[se.sampler]),X.push({image:q[se.source],sampler:ae,uploaded:!1})}return X}(p,p.images),m=function(z,q){const X=[];for(const Q of z.json.meshes){const se=[];for(const ae of Q.primitives)se.push(iJe(ae,z,q));X.push(se)}return X}(p,c),{scenes:y,scene:b,nodes:A}=p.json,I=y?y[b||0].nodes:[...A.keys()],O=[];for(const z of I)O.push(dje(A[z],p,m));return function(z,q,X){const Q={},se=new Set;for(let ae=0;ae0){const ae=Array.from(se.values()).sort((le,xe)=>le-xe);for(let le=ae.length-1;le>=0;le--)z.splice(ae[le],1)}}(O,I,p.json.nodes),O}function dJe(p){p.heightmap=new Float32Array(4096),p.heightmap.fill(-1);const c=p.vertexArray.float32,m=p.aabb.min[0]-1,y=p.aabb.min[1]-1,b=nb/(p.aabb.max[0]-m+2),A=nb/(p.aabb.max[1]-y+2);for(let I=0;Ip.heightmap[q*nb+z]&&(p.heightmap[q*nb+z]=O)}}function uje(p,c,m,y,b){m.reserve(m.length+4*p.length),y.reserve(y.length+10*p.length),b.reserve(b.length+10*p.length);let A=y.length;for(const I of p){const O=Math.min(10,Math.max(4,1.3*I.height))*c,z=[-I.normal[1],I.normal[0],0],q=Math.min(.29,.1*I.width/I.depth),X=I.width-2*I.depth*c*(q+.01),Q=Ke([],I.pos,z,X/2),se=Ke([],I.pos,z,-X/2),ae=[Q[0],Q[1],Q[2]+I.height],le=[se[0],se[1],se[2]+I.height],xe=Ke([],I.normal,z,q);Se(xe,xe,O);const Me=Ke([],I.normal,z,-q);Se(Me,Me,O),ce(xe,Q,xe),ce(Me,se,Me),Q[2]+=.1,se[2]+=.1,y.emplaceBack(xe[0],xe[1],xe[2]),y.emplaceBack(Me[0],Me[1],Me[2]),y.emplaceBack(Q[0],Q[1],Q[2]),y.emplaceBack(se[0],se[1],se[2]),y.emplaceBack(ae[0],ae[1],ae[2]),y.emplaceBack(le[0],le[1],le[2]),y.emplaceBack(Q[0],Q[1],Q[2]),y.emplaceBack(se[0],se[1],se[2]),y.emplaceBack(xe[0],xe[1],xe[2]),y.emplaceBack(Me[0],Me[1],Me[2]);const Ce=X/O/2;b.emplaceBack(-Ce-q,-1,Ce,.8),b.emplaceBack(Ce+q,-1,Ce,.8),b.emplaceBack(-Ce,0,Ce,1.3),b.emplaceBack(Ce,0,Ce,1.3),b.emplaceBack(Ce+q,-.8,Ce,.7),b.emplaceBack(Ce+q,-.8,Ce,.7),b.emplaceBack(0,0,Ce,1.3),b.emplaceBack(0,0,Ce,1.3),b.emplaceBack(Ce+q,-1.2,Ce,.8),b.emplaceBack(Ce+q,-1.2,Ce,.8),m.emplaceBack(6+A,4+A,8+A),m.emplaceBack(7+A,9+A,5+A),m.emplaceBack(0+A,1+A,2+A),m.emplaceBack(1+A,3+A,2+A),A+=10}}function uJe(p,c){const m={};m.indexArray=new ol,m.vertexArray=new sh,m.colorArray=new Kg,uje(p,c,m.indexArray,m.vertexArray,m.colorArray);const y={defined:!0};y.emissiveFactor=Da.black;const b={};return b.baseColorFactor=Da.white,y.pbrMetallicRoughness=b,m.material=y,m.aabb=new Nr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const hje=ea([{name:"a_pos_3f",components:3,type:"Float32"}]),hJe=ea([{name:"a_normal_3",components:3,type:"Int16"}]),mJe=ea([{name:"a_centroid_3",components:3,type:"Int16"}]),mje=ea([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),pJe=ea([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),fJe=ea([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),gJe=ea([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),xJe=ea([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),yJe=ea([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),pje=Bt.types,OD=32767;function vJe(p,c){const m=Hs+c;for(const y of p)for(const b of y)if(b.x<-c||b.x>m||b.y<-c||b.y>m)return!1;return!0}function _Je(p){switch(p){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: ${p}`)}}class nde{constructor(){this.layoutVertexArray=new sh,this.layoutAttenuationArray=new Kg,this.layoutColorArray=new rh,this.indexArray=new ol,this.indexArrayForConflation=new ol,this.segmentsBucket=new ro}}class ade{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new ro,this.entranceBloom=new nde;const m=66560;this.layoutVertexArray=new sh,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new J0,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new J0,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new rh,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new Zg,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new OS,this.layoutAOArray.reserve(m),this.indexArray=new ol,this.indexArray.reserve(66560),this.indexArrayForConflation=new ol,this.segmentsBucket=new ro,this.entranceBloom=new nde,c&&(this.layoutFacadePaintArray=new rh,this.layoutFacadeDataArray=new my,this.layoutFacadeVerticalRangeArray=new rh)}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 fje{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new _p,this.footprintsIndices=new Zg,this.footprintsMin=new cs(1/0,1/0),this.footprintsMax=new cs(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new ade(!1),this.buildingWithFacade=new ade(!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 Sm(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 $ce(c),this.groundEffect.groundRadiusArray=new bf,this.hasAppearances=null}updateFootprints(c,m){const y=new bD([],[],1),b={vertices:[],indices:new Uint32Array(0),grid:y,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:b,id:c})}updateAppearances(c,m,y,b){}prepare(){return function(){if(MD!=null||Z2e!=null)return null;if(JS!=null)return JS;const c=fetch(Xn.BUILDING_GEN_URL);return JS=function(m){let y,b,A,I,O;function z(){y=new Uint8Array(O.buffer),b=new Int16Array(O.buffer),A=new Int32Array(O.buffer),I=new Float32Array(O.buffer)}function q(){throw new Error("Unexpected BuildingGen error.")}const X=()=>{},Q={a:{a:q,f:function(se){const ae=y.length,le=Math.max(se>>>0,Math.ceil(1.2*ae)),xe=Math.ceil((le-ae)/65536);try{return O.grow(xe),z(),!0}catch{return!1}},g:q,b:X,c:X,d:X,e:X}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(m,Q):m.then(se=>se.arrayBuffer()).then(se=>WebAssembly.instantiate(se,Q))).then(se=>{const ae=se.instance.exports;return(0,ae.g)(),O=ae.f,z(),new HQe({setStyle:ae.h,setAOOptions:ae.i,setMetricOptions:ae.j,setStructuralOptions:ae.k,setFacadeOptions:ae.l,setFauxFacadeOptions:ae.m,setFacadeClassifierOptions:ae.n,addFeature:ae.o,addFacade:ae.p,generateMesh:ae.q,getLastError:ae.r,getOuterRingLength:ae.s,getMeshCount:ae.t,getPositionsPtr:ae.u,getPositionsLength:ae.v,getNormalsPtr:ae.w,getNormalsLength:ae.x,getAOPtr:ae.y,getAOLength:ae.z,getUVPtr:ae.A,getUVLength:ae.B,getFauxFacadePtr:ae.C,getFauxFacadeLength:ae.D,getIndicesPtr:ae.E,getIndicesLength:ae.F,getBuildingPart:ae.G,getRingCount:ae.H,getRingPtr:ae.I,getRingLength:ae.J,malloc:ae.K,free:ae.L,heapU8:y,heap16:b,heap32:A,heapF32:I})})}(c).then(m=>(JS=null,MD=m,MD)).catch(m=>{cr("Could not load building-gen"),JS=null,Z2e=m}),JS}()}populate(c,m,y,b){const A=WQe();if(!A)return;const I=Le(y);this.tileToMeter=I,this.brightness=m.brightness,A.setStyle({normalScale:[1,-1,I],tileToMeters:I}),A.setAOOptions(!1,.3),A.setMetricOptions(!1,16),A.setStructuralOptions(!0),A.setFacadeClassifierOptions(3);const O=new Map,z=new Map;let q=0;for(const{feature:Ce}of c){if(pje[Ce.type]!=="LineString"){O.set(Ce.id,Ce.properties.source_id);continue}const ze=this.layers[0]._featureFilter.needGeometry;if(ze&&!this.layers[0]._featureFilter.filter(new Si(this.zoom),Ce,y))continue;const Ve=Ut(Ce,ze);if(!ze&&!this.layers[0]._featureFilter.filter(new Si(this.zoom),Ve,y))continue;const Je=ze?Ve.geometry:At(Ce,y,b),vt=[];for(const Ot of Je)for(const ns of Ot)vt.push(ns.x),vt.push(ns.y);const mt={coordinates:vt,crossPerc:Ce.properties.cross_perc,distanceToRoad:Ce.properties.distance_to_road,entrances:Ce.properties.entrances,sourceId:0},St=Ce.properties.source_id;let It=z.get(St);It||(It=[],z.set(St,It)),It.push(mt),++q}this.maxHeight=0;const X=new Array,Q=new Set,se=Ce=>{Ce!=null&&Q.add(Ce)},ae=(Ce,ze)=>{Ce!=null&&X.push({buildingId:Ce,footprintIndex:ze})},le=64*(c.length-q),xe=le/2;this.buildingWithFacade.reserve(le,xe,!0),this.buildingWithoutFacade.reserve(2*le,2*xe,!1),this.footprintsIndices.reserve(16*(c.length-q)),this.footprintsVertices.reserve(8*(c.length-q));for(const{feature:Ce,id:ze,index:Ve,sourceLayerIndex:Je}of c){if(pje[Ce.type]==="LineString")continue;const vt=this.layers[0]._featureFilter.needGeometry;if(vt&&!this.layers[0]._featureFilter.filter(new Si(this.zoom),Ce,y))continue;let mt=null;if(Ce.properties&&Ce.properties.hasOwnProperty("building_id")&&(mt=Ce.properties.building_id,Q.has(mt)))continue;const St=Ut(Ce,vt);if(!vt&&!this.layers[0]._featureFilter.filter(new Si(this.zoom),St,y))continue;const It=vt?St.geometry:At(Ce,y,b),Ot=NT(It,500);let ns=!1;for(const Wr of Ot)if(Wr.length!==1){ns=!0;break}if(ns){se(mt);continue}if(!vJe(It,163)){se(mt);continue}const qt=this.layers[0],us=_Je(qt.layout.get("building-roof-shape").evaluate(Ce,{},y)),gs=qt.layout.get("building-base").evaluate(Ce,{},y),xs=qt.layout.get("building-height").evaluate(Ce,{},y),As=qt.layout.get("building-flood-light-ground-radius").evaluate(Ce,{},y),Is=qt.paint.get("building-ambient-occlusion-intensity"),Ns=As/this.tileToMeter;Ce.properties["building-part"]="roof";const Ms=qt.paint.get("building-color").evaluate(Ce,{},this.canonical).toPremultipliedRenderColor(this.lut),ds=qt.paint.get("building-emissive-strength").evaluate(Ce,{},this.canonical);Ce.properties["building-part"]="wall";const as=qt.paint.get("building-color").evaluate(Ce,{},this.canonical).toPremultipliedRenderColor(this.lut),Ts=qt.paint.get("building-emissive-strength").evaluate(Ce,{},this.canonical);Ce.properties["building-part"]="window";const Ws=qt.paint.get("building-color").evaluate(Ce,{},this.canonical).toPremultipliedRenderColor(this.lut),Rs=qt.paint.get("building-emissive-strength").evaluate(Ce,{},this.canonical);Ce.properties["building-part"]="door";const Mr=qt.paint.get("building-color").evaluate(Ce,{},this.canonical).toPremultipliedRenderColor(this.lut),or=qt.paint.get("building-emissive-strength").evaluate(Ce,{},this.canonical);let mr=qt.layout.get("building-flood-light-wall-radius").evaluate(Ce,{},y);mr=_e(mr,0,2048);const vr=mr/2048*OD,Dn=O.get(ze),zs=z.get(Dn)||[],_r=zs.length!==0&&qt.layout.get("building-facade").evaluate(Ce,{},y);A.setFacadeOptions(4,!0),A.setFauxFacadeOptions(_r,!1,1);let an=0,oa=0,ha=0,Nn=0,di=0,pt=0,bt=0,hs=0,Es=0,sr=0,rr=0;if(_r){let Wr=Math.round(qt.layout.get("building-facade-floors").evaluate(Ce,{},y));if(gs===0){Wr=Math.max(1,Wr-(zs.length>0?1:0));let ti=4;if(xs>100){const Ui=[10,13,15];ti=Ui[Ce.id?Ce.id%Ui.length:0]}else xs<=10&&(ti=3);A.setFacadeOptions(ti,!0),di=(xs<15?1.3:1.61803)*ti/I}else di=gs/I;pt=xs/I,di=Math.min(di,pt),ha=qt.layout.get("building-facade-unit-width").evaluate(Ce,{},y)/I,Nn=(pt-di)/Wr,A.setFauxFacadeOptions(!0,!0,ha);const io=qt.layout.get("building-facade-window").evaluate(Ce,{},y);an=io[0],oa=io[1],bt=Math.floor(65535*Math.min(1,di/Hs)),hs=Math.floor(65535*Math.min(1,pt/Hs)),Es=Math.floor(255*an)<<8|Math.floor(255*oa),sr=Math.floor(65535*Math.min(1,ha/Hs)),rr=Math.floor(65535*Math.min(1,Nn/Hs))}const Ar=Array(Ot.length),Lr={x:1/0,y:1/0},wn={x:-1/0,y:-1/0},An={x:0,y:0};let Ln=0;for(let Wr=0;Wr0){const ti=[],Ui=Array(io.length+1);Ui[0]=0;for(let dl=0;dlHs||Lr.y<0||wn.y>Hs)&&this.featuresOnBorder.push({featureId:Ce.id,footprintIndex:this.footprints.length});{const Wr=KS(mi,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Wr.length),this.footprintsIndices.uint16.set(Wr,Hr),this.buildingIds.add(mt??Ce.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,_i.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,_i.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Ci.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Ci.y);const io={footprintVertexOffset:sa,footprintVertexLength:this.footprintsVertices.length-sa,footprintIndexOffset:Hr,footprintIndexLength:this.footprintsIndices.length-Hr,min:_i,max:Ci,hiddenFlags:0,indicesOffset:Ua,indicesLength:Qi,bloomIndicesOffset:ei,bloomIndicesLength:gi,groundEffectVertexOffset:To,groundEffectVertexLength:ki,hasFauxFacade:_r,height:En,promoteId:ze,feature:St,parts:Ma,buildingBloom:Ta},ti=this.footprints.length;Ce.id!==void 0&&this.featureFootprintLookup.set(Ce.id,ti),ae(mt,ti),this.footprints.push(io)}this.programConfigurations.populatePaintArrays(Gr.layoutVertexArray.length,Ce,Ve,{},m.availableImages,y,m.brightness),this.groundEffect.addPaintPropertiesData(Ce,Ve,{},m.availableImages,y,m.brightness),m.featureIndex.insert(Ce,It,Ve,Je,this.index,ui)}X.forEach(({buildingId:Ce,footprintIndex:ze})=>{Q.has(Ce)&&(this.footprints[ze].hiddenFlags|=4)});const Me=new Set;this.buildingIds.forEach((Ce,ze,Ve)=>{Q.has(Ce)||Me.add(Ce)}),this.buildingIds=Me,this.groundEffect.prepareBorderSegments()}update(c,m,y,b,A,I,O){this.programConfigurations.updatePaintArrays(c,m,A,y,b,I,O),this.groundEffect.update(c,m,A,y,b,I,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,hje.members),y.layoutNormalBuffer=c.createVertexBuffer(y.layoutNormalArray,hJe.members),y.layoutCentroidBuffer=c.createVertexBuffer(y.layoutCentroidArray,mJe.members),y.layoutFloodLightDataBuffer=c.createVertexBuffer(y.layoutFloodLightDataArray,yJe.members),y.layoutFacadeDataArray&&y.layoutFacadeDataArray.length&&(y.layoutFacadeDataBuffer=c.createVertexBuffer(y.layoutFacadeDataArray,fJe.members)),y.layoutFacadeVerticalRangeArray&&y.layoutFacadeVerticalRangeArray.length&&(y.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(y.layoutFacadeVerticalRangeArray,gJe.members)),y.entranceBloom.layoutVertexArray.length&&(y.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(y.entranceBloom.layoutVertexArray,hje.members),y.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(y.entranceBloom.layoutAttenuationArray,xJe.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 b=!1;const A=y?m:0,I=0|(y?-1:~m);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const O of c){const z=this.footprints[O],q=z.hiddenFlags&I|A;z.hiddenFlags!==q&&(z.hiddenFlags=q,b=!0,this.groundEffect.updateHiddenByLandmarkRange(z.groundEffectVertexOffset,z.groundEffectVertexLength,z.hiddenFlags!==0))}return b&&(this.indexArrayForConflationUploaded=!1),b}uploadUpdatedIndexBuffer(c){if(this.groundEffect.uploadHiddenByLandmark(c),this.indexArrayForConflationUploaded)return;const m=b=>{b.indexArray.length!==0&&(b.indexArrayForConflation.resize(b.indexArray.length),b.indexArrayForConflation.uint16.set(b.indexArray.uint16),b.entranceBloom.indexArrayForConflation.resize(b.entranceBloom.indexArray.length),b.entranceBloom.indexArrayForConflation.uint16.set(b.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const b of this.footprints){const A=b.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,I=b.indicesOffset+b.indicesLength;if(b.hiddenFlags!==0){for(let z=b.indicesOffset;z{b.indexArray.length!==0&&(b.indexBuffer?b.indexBuffer.updateData(b.indexArrayForConflation):b.indexBuffer=c.createIndexBuffer(b.indexArrayForConflation,!0),b.entranceBloom.indexBuffer?b.entranceBloom.indexBuffer.updateData(b.entranceBloom.indexArrayForConflation):b.entranceBloom.indexBuffer=c.createIndexBuffer(b.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,mje.members,!0),y.layoutFacadePaintArray&&(y.layoutFacadePaintBuffer?y.layoutFacadePaintBuffer.updateData(y.layoutFacadePaintArray):y.layoutFacadePaintBuffer=c.createVertexBuffer(y.layoutFacadePaintArray,pJe.members,!0)),y.entranceBloom.layoutColorBuffer?y.entranceBloom.layoutColorBuffer.updateData(y.entranceBloom.layoutColorArray):y.entranceBloom.layoutColorBuffer=c.createVertexBuffer(y.entranceBloom.layoutColorArray,mje.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 b of this.footprints){if(4&b.hiddenFlags)continue;const A=m[b.promoteId],I=b.feature;I.properties["building-part"]="roof";const O=c.paint.get("building-color").evaluate(I,A,this.canonical).toPremultipliedRenderColor(this.lut),z=c.paint.get("building-emissive-strength").evaluate(I,A,this.canonical);I.properties["building-part"]="wall";const q=c.paint.get("building-color").evaluate(I,A,this.canonical).toPremultipliedRenderColor(this.lut),X=c.paint.get("building-emissive-strength").evaluate(I,A,this.canonical);I.properties["building-part"]="window";const Q=c.paint.get("building-color").evaluate(I,A,this.canonical).toPremultipliedRenderColor(this.lut),se=c.paint.get("building-emissive-strength").evaluate(I,A,this.canonical);I.properties["building-part"]="door";const ae=c.paint.get("building-color").evaluate(I,A,this.canonical).toPremultipliedRenderColor(this.lut),le=c.paint.get("building-emissive-strength").evaluate(I,A,this.canonical),xe=b.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ce of b.parts){let ze,Ve=O;Ce.part===1?(Ve=O,ze=z):Ce.part===0?(Ve=q,ze=X):Ce.part===2?(Ve=Q,ze=se):Ce.part===3&&(Ve=ae,ze=le),ze=_e(ze,0,1);for(let Je=0;JeI.max.x||z.max.xI.max.y||z.max.yO.max.x||O.min.x>c||m>O.max.y||O.min.y>m||O.height<=y||bJe(I,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[A]=O,b=O.hiddenFlags!==0);if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:b};this.footprintLookup[A]=void 0}}function bJe(p,c,m){for(let y=0;y1&&(z=c[++O]);const X=Math.abs(q-z.left),Q=Math.abs(q-z.right),se=Math.min(X,Q);let ae;const le=A/y*(b+1);if(z.isDash){const xe=b-Math.abs(le);ae=Math.sqrt(se*se+xe*xe)}else ae=b-Math.sqrt(se*se+le*le);this.image.data[I+q]=Math.max(0,Math.min(255,ae+128))}}}addRegularDash(c,m){for(let z=c.length-1;z>=0;--z){const q=c[z],X=c[z+1];q.zeroLength?c.splice(z,1):X&&X.isDash===q.isDash&&(X.left=q.left,c.splice(z,1))}const y=c[0],b=c[c.length-1];y.isDash===b.isDash&&(y.left=b.left-this.width,b.right=y.right+this.width);const A=this.width*this.nextRow;let I=0,O=c[I];for(let z=0;z1&&(O=c[++I]);const q=Math.abs(z-O.left),X=Math.abs(z-O.right),Q=Math.min(q,X);this.image.data[A+z]=Math.max(0,Math.min(255,(O.isDash?Q:-Q)+m+128))}}addDash(c,m){const y=this.getKey(c,m);if(this.positions[y])return this.positions[y];const b=m==="round",A=b?7:0,I=2*A+1;if(this.nextRow+I>this.height)return cr("LineAtlas out of space"),null;c.length===0&&c.push(1);let O=0;for(let X=0;Xm.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 TS,this.layoutVertexArray2=new sh,this.patternVertexArray=new sh,this.indexArray=new ol,this.programConfigurations=new Sm(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new ro,this.maxLineLength=0,this.zOffsetVertexArray=new sh,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=c.tessellationStep?c.tessellationStep:Hs/64,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,m){}updateAppearances(c,m,y,b){}populate(c,m,y,b){this.hasPattern=Ice("line",this.layers,this.pixelRatio,m);const A=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Le(y);const I=this.layers[0].layout.get("line-elevation-reference");if(I==="hd-road-markup")this.elevationType="road";else{const se=this.layers[0].layout.get("line-z-offset"),ae=se.isConstant()&&!se.constantOr(0);this.elevationType=I!=="sea"&&I!=="ground"&&ae?"none":"offset",this.elevationType==="offset"&&I==="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 z=[];for(const{feature:se,id:ae,index:le,sourceLayerIndex:xe}of c){const Me=this.layers[0]._featureFilter.needGeometry,Ce=Ut(se,Me);if(!this.layers[0]._featureFilter.filter(new Si(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Ce,y))continue;const ze=A?A.evaluate(Ce,{},y):void 0,Ve={id:ae,properties:se.properties,type:se.type,sourceLayerIndex:xe,index:le,geometry:Me?Ce.geometry:At(se,y,b),patterns:{},sortKey:ze};z.push(Ve)}A&&z.sort((se,ae)=>se.sortKey-ae.sortKey);const{lineAtlas:q,featureIndex:X}=m,Q=this.addConstantDashes(q);for(const se of z){const{geometry:ae,index:le,sourceLayerIndex:xe}=se;if(Q&&this.addFeatureDashes(se,q),this.hasPattern){const Me=Pce("line",this.layers,se,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Me)}else this.addFeature(se,ae,le,y,q.positions,m.availableImages,m.brightness,m.elevationFeatures);X.insert(c[le].feature,ae,le,xe,this.index)}}addConstantDashes(c){let m=!1;for(const y of this.layers){const b=y.paint.get("line-dasharray").value,A=y.layout.get("line-cap").value;if(b.kind!=="constant"||A.kind!=="constant")m=!0;else{const I=A.value,O=b.value;if(!O)continue;c.addDash(O,I)}}return m}addFeatureDashes(c,m){const y=this.zoom;for(const b of this.layers){const A=b.paint.get("line-dasharray").value,I=b.layout.get("line-cap").value;if(A.kind==="constant"&&I.kind==="constant")continue;let O,z;if(A.kind==="constant"){if(O=A.value,!O)continue}else O=A.evaluate({zoom:y},c);z=I.kind==="constant"?I.value:I.evaluate({zoom:y},c),m.addDash(O,z),c.patterns[b.id]=[m.getKey(O,z)]}}update(c,m,y,b,A,I,O,z){this.programConfigurations.updatePaintArrays(c,m,A,y,b,I,O,z)}addFeatures(c,m,y,b,A,I){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,y,b,I,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,CJe)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,TJe)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,kJe.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,NJe),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,b;if(m&&m>0?(y=`mapbox_clip_start_${m}`,b=`mapbox_clip_end_${m}`):(y="mapbox_clip_start",b="mapbox_clip_end"),c.properties&&c.properties.hasOwnProperty(y)&&c.properties.hasOwnProperty(b))return{start:+c.properties[y],end:+c.properties[b]}}addFeature(c,m,y,b,A,I,O,z){const q=this.layers[0].layout,X=q.get("line-join").evaluate(c,{}),Q=q.get("line-cap").evaluate(c,{}),se=q.get("line-miter-limit"),ae=q.get("line-round-limit");this.lineClips=this.lineFeatureClips(c),this.lineFeature=c;const le=!(!c.properties||!c.properties.hasOwnProperty("mapbox_line_metrics"))&&c.properties.mapbox_line_metrics;this.zOffsetValue=q.get("line-z-offset").value;const xe=this.layers[0].paint.get("line-width").value;if(xe.kind!=="constant"&&xe.isLineProgressConstant===!1&&(this.variableWidthValue=xe),this.elevationType==="road"){const Me=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(c,m,b,z,X,Q,se,ae)){const[Ce,ze]=this.clipRuntimeLinesToTile(m,1);for(let Ve=0;Ve0?vt.parentIndex:null)}this.fillNonElevatedRoadSegment(Me)}}else for(let Me=0;Me0?Me:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,y,A,I,b,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 SD(c,-m,-m,Hs+m,Hs+m)}clipRuntimeLinesToTile(c,m){const y=[];return[SD(c,-m,-m,Hs+m,Hs+m,y),y]}addElevatedRoadFeature(c,m,y,b,A,I,O,z){const q=[],X=Ba.getElevationFeature(c,b);if(X){const Q=this.clipLinesToTile(m,1),se=this.prepareElevatedLines(Q,X,y);for(const ae of se)q.push({geometry:ae,elevation:X,elevationTileID:y,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(q.length===0)return!1;for(const Q of q){const se=this.layoutVertexArray.length;this.addLine(Q.geometry,c,y,A,I,O,z);const ae=new ii(y,Q.elevationTileID);if(Q.elevation)for(let le=se;le>1,this.layoutVertexArray.int16[6*le+1]>>1),Me=ae.pointElevation(xe,Q.elevation,.05);this.updateHeightRange(Me),this.zOffsetVertexArray.emplaceBack(Me,0,0)}else this.fillNonElevatedRoadSegment(se)}return!0}prepareElevatedLines(c,m,y){if(m.constantHeight!=null)return c;const b=[],A=1/Le(y);for(const I of c)UQe(I,new Ca(m,A),0,b);return b}fillNonElevatedRoadSegment(c){for(let m=c;m0,se=z&&z.progress.max<1;if(this.lineClips){let Ot={min:this.lineClips.start,max:this.lineClips.end},ns=1;if(z){const gs=this.lineClips.end-this.lineClips.start;Ot=function(xs,As,Is){return{min:ci(xs.min,As,Is),max:ci(xs.max,As,Is)}}(z.progress,{min:0,max:1},Ot),gs>0&&(ns=(Ot.max-Ot.min)/gs)}const qt=+m.properties.mapbox_clip_feature_len,us=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(qt)||Number.isNaN(us)){for(let xs=0;xs=2&&c[le-1].equals(c[le-2]);)le--;let xe=0;for(;xe0,ds=this.overscaling<=16?15*Hs/(512*this.overscaling):0;if(ns&&qt==="round"){if(AsI&&(qt="bevel"),qt==="bevel"&&(As>2&&(qt="flipbevel"),As2*ds){const Ws=Ce.sub(Ce.sub(ze)._mult(ds/as)._round());this.updateDistance(ze,Ws),this.addCurrentVertex(Ws,Je,0,0,Me,It),ze=Ws}this.updateDistance(ze,Ce),gs._mult(As),this.addCurrentVertex(Ce,gs,0,0,Me,It);const Ts=Ce.dist(Ve);if(Ts>2*ds){const Ws=Ce.add(Ve.sub(Ce)._mult(ds/Ts)._round());this.updateDistance(Ce,Ws),this.addCurrentVertex(Ws,vt,0,0,Me,It),Ce=Ws}}else gs._mult(As),this.addCurrentVertex(Ce,gs,0,0,Me,It);else if(qt==="flipbevel"){if(As>100)gs=vt.mult(-1);else{const as=As*Je.add(vt).mag()/Je.sub(vt).mag();gs._perp()._mult(as*(Ms?-1:1))}this.addCurrentVertex(Ce,gs,0,0,Me,It),this.addCurrentVertex(Ce,gs.mult(-1),0,0,Me,It)}else if(qt==="bevel"||qt==="fakeround"){It!=null&&ze&&this.addCurrentVertex(Ce,St||Je,-1,-1,Me,It);const as=Ce.dist(ze)<=2*ds&&qt!=="bevel",Ts=gs.mult(Ms?1:-1);Ts._mult(As);const Ws=vt.mult(Ms?-1:1),Rs=Je.mult(Ms?-1:1),Mr=this.evaluateLineProgressFeatures(this.distance);if(It==null&&(this.addHalfVertex(Ce,Ts.x,Ts.y,!1,!Ms,0,Me,Mr),as||this.addHalfVertex(Ce,Ts.x+2*Rs.x,Ts.y+2*Rs.y,!1,Ms,0,Me,Mr)),qt==="fakeround"){const or=Math.round(180*Is/Math.PI/20);this.addHalfVertex(Ce,Rs.x,Rs.y,!1,Ms,0,Me,Mr);for(let mr=0;mr1){this.lineSoFar=c.w;const xe=(m.x-c.x)/Q,Me=(m.y-c.y)/Q,Ce=(m.z-c.z)/Q,ze=(m.w-c.w)/Q;for(let Ve=1;Ve=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,X),z.primitiveLength++),I?this.e2=X:this.e1=X,q!=null&&this.zOffsetVertexArray.emplaceBack(q.zOffset,q.variableWidth,q.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 ode(p,c,m){return p.xm||p.ym}let vje,_je;function bje(p,c,m){return c*(Hs/(p.tileSize*Math.pow(2,m-p.tileID.overscaledZ)))}xr(ide,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const wje=(p,c,m)=>(1-m)*p+m*c;function jje(p,c){return 1/bje(p,1,c.tileZoom)}function kje(p,c,m,y){return p.translatePosMatrix(y||c.tileID.projMatrix,c,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const Nje=p=>{const c=[];Sje(p)&&c.push("RENDER_LINE_DASH"),p.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT");const m=p.paint.get("line-trim-offset");m[0]===0&&m[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),p.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const y=p.layout.get("line-join").constantOr("miter")==="none",b=!!p.paint.get("line-pattern").constantOr(1);return y&&b&&c.push("LINE_JOIN_NONE"),c};function Sje(p){const c=p.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let lde;const Cje=()=>lde||(lde={layout:vje||(vje=new xo({"line-cap":new Xs(Vt.layout_line["line-cap"]),"line-join":new Xs(Vt.layout_line["line-join"]),"line-miter-limit":new $s(Vt.layout_line["line-miter-limit"]),"line-round-limit":new $s(Vt.layout_line["line-round-limit"]),"line-sort-key":new Xs(Vt.layout_line["line-sort-key"]),"line-z-offset":new Xs(Vt.layout_line["line-z-offset"]),"line-elevation-reference":new $s(Vt.layout_line["line-elevation-reference"]),"line-cross-slope":new $s(Vt.layout_line["line-cross-slope"]),visibility:new $s(Vt.layout_line.visibility),"line-width-unit":new $s(Vt.layout_line["line-width-unit"])})),paint:_je||(_je=new xo({"line-opacity":new Xs(Vt.paint_line["line-opacity"]),"line-color":new Xs(Vt.paint_line["line-color"]),"line-translate":new $s(Vt.paint_line["line-translate"]),"line-translate-anchor":new $s(Vt.paint_line["line-translate-anchor"]),"line-width":new Xs(Vt.paint_line["line-width"]),"line-gap-width":new Xs(Vt.paint_line["line-gap-width"]),"line-offset":new Xs(Vt.paint_line["line-offset"]),"line-blur":new Xs(Vt.paint_line["line-blur"]),"line-dasharray":new Xs(Vt.paint_line["line-dasharray"]),"line-pattern":new Xs(Vt.paint_line["line-pattern"]),"line-pattern-cross-fade":new $s(Vt.paint_line["line-pattern-cross-fade"]),"line-gradient":new dy(Vt.paint_line["line-gradient"]),"line-trim-offset":new $s(Vt.paint_line["line-trim-offset"]),"line-trim-fade-range":new $s(Vt.paint_line["line-trim-fade-range"]),"line-trim-color":new $s(Vt.paint_line["line-trim-color"]),"line-emissive-strength":new Xs(Vt.paint_line["line-emissive-strength"]),"line-border-width":new Xs(Vt.paint_line["line-border-width"]),"line-border-color":new Xs(Vt.paint_line["line-border-color"]),"line-occlusion-opacity":new $s(Vt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"})}))},lde);class PJe extends Xs{possiblyEvaluate(c,m){return m=new Si(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(c,m)}evaluate(c,m,y,b){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(c,m,y,b)}}let RT;function Mje(p,c){return c>0?c+2*p:p}const LJe=ea([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),DJe=ea([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),OJe=ea([{name:"a_projected_pos",components:4,type:"Float32"}],4);ea([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const RJe=ea([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),FJe=ea([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),zJe=ea([{name:"a_texb",components:2,type:"Uint16"}]),BJe=ea([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),$Je=ea([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ea([{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 Tje=ea([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),UJe=ea([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ea([{name:"triangle",components:3,type:"Uint16"}]),ea([{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"}]),ea([{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"}]),ea([{type:"Float32",name:"offsetX"}]),ea([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ol=24;function qJe(p,c,m){return p.sections.forEach(y=>{y.text=function(b,A,I){const O=A.layout.get("text-transform").evaluate(I,{});return O==="uppercase"?b=b.toLocaleUpperCase():O==="lowercase"&&(b=b.toLocaleLowerCase()),_f.applyArabicShaping&&(b=_f.applyArabicShaping(b)),b}(y.text,c,m)}),p}const FT={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function VJe(p){return p==="︶"||p==="﹈"||p==="︸"||p==="﹄"||p==="﹂"||p==="︾"||p==="︼"||p==="︺"||p==="︘"||p==="﹀"||p==="︐"||p==="︓"||p==="︔"||p==="`"||p===" ̄"||p==="︑"||p==="︒"}function HJe(p){return p==="︵"||p==="﹇"||p==="︷"||p==="﹃"||p==="﹁"||p==="︽"||p==="︻"||p==="︹"||p==="︗"||p==="︿"}const cde=4294967296,Aje=1/cde,Eje=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let RD=class{constructor(p=new Uint8Array(16)){this.buf=ArrayBuffer.isView(p)?p:new Uint8Array(p),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(p,c,m=this.length){for(;this.pos>3,A=this.pos;this.type=7&y,p(b,c,this),this.pos===A&&this.skip(y)}return c}readMessage(p,c){return this.readFields(p,c,this.readVarint()+this.pos)}readFixed32(){const p=this.dataView.getUint32(this.pos,!0);return this.pos+=4,p}readSFixed32(){const p=this.dataView.getInt32(this.pos,!0);return this.pos+=4,p}readFixed64(){const p=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*cde;return this.pos+=8,p}readSFixed64(){const p=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*cde;return this.pos+=8,p}readFloat(){const p=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,p}readDouble(){const p=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,p}readVarint(p){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(b,A,I){const O=I.buf;let z,q;if(q=O[I.pos++],z=(112&q)>>4,q<128||(q=O[I.pos++],z|=(127&q)<<3,q<128)||(q=O[I.pos++],z|=(127&q)<<10,q<128)||(q=O[I.pos++],z|=(127&q)<<17,q<128)||(q=O[I.pos++],z|=(127&q)<<24,q<128)||(q=O[I.pos++],z|=(1&q)<<31,q<128))return tC(b,z,A);throw new Error("Expected varint not more than 10 bytes")}(m,p,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const p=this.readVarint();return p%2==1?(p+1)/-2:p/2}readBoolean(){return!!this.readVarint()}readString(){const p=this.readVarint()+this.pos,c=this.pos;return this.pos=p,p-c>=12&&Eje?Eje.decode(this.buf.subarray(c,p)):function(m,y,b){let A="",I=y;for(;I239?4:O>223?3:O>191?2:1;if(I+se>b)break;se===1?O<128&&(Q=O):se===2?(z=m[I+1],(192&z)==128&&(Q=(31&O)<<6|63&z,Q<=127&&(Q=null))):se===3?(z=m[I+1],q=m[I+2],(192&z)==128&&(192&q)==128&&(Q=(15&O)<<12|(63&z)<<6|63&q,(Q<=2047||Q>=55296&&Q<=57343)&&(Q=null))):se===4&&(z=m[I+1],q=m[I+2],X=m[I+3],(192&z)==128&&(192&q)==128&&(192&X)==128&&(Q=(15&O)<<18|(63&z)<<12|(63&q)<<6|63&X,(Q<=65535||Q>=1114112)&&(Q=null))),Q===null?(Q=65533,se=1):Q>65535&&(Q-=65536,A+=String.fromCharCode(Q>>>10&1023|55296),Q=56320|1023&Q),A+=String.fromCharCode(Q),I+=se}return A}(this.buf,c,p)}readBytes(){const p=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,p);return this.pos=p,c}readPackedVarint(p=[],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(p,c){this.writeVarint(p<<3|c)}realloc(p){let c=this.length||16;for(;c268435455||p<0?function(c,m){let y,b;if(c>=0?(y=c%4294967296|0,b=c/4294967296|0):(y=~(-c%4294967296),b=~(-c/4294967296),4294967295^y?y=y+1|0:(y=0,b=b+1|0)),c>=18446744073709552e3||c<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");m.realloc(10),function(A,I,O){O.buf[O.pos++]=127&A|128,A>>>=7,O.buf[O.pos++]=127&A|128,A>>>=7,O.buf[O.pos++]=127&A|128,A>>>=7,O.buf[O.pos++]=127&A|128,O.buf[O.pos]=127&(A>>>=7)}(y,0,m),function(A,I){const O=(7&A)<<4;I.buf[I.pos++]|=O|((A>>>=3)?128:0),A&&(I.buf[I.pos++]=127&A|((A>>>=7)?128:0),A&&(I.buf[I.pos++]=127&A|((A>>>=7)?128:0),A&&(I.buf[I.pos++]=127&A|((A>>>=7)?128:0),A&&(I.buf[I.pos++]=127&A|((A>>>=7)?128:0),A&&(I.buf[I.pos++]=127&A)))))}(b,m)}(p,this):(this.realloc(4),this.buf[this.pos++]=127&p|(p>127?128:0),p<=127||(this.buf[this.pos++]=127&(p>>>=7)|(p>127?128:0),p<=127||(this.buf[this.pos++]=127&(p>>>=7)|(p>127?128:0),p<=127||(this.buf[this.pos++]=p>>>7&127))))}writeSVarint(p){this.writeVarint(p<0?2*-p-1:2*p)}writeBoolean(p){this.writeVarint(+p)}writeString(p){p=String(p),this.realloc(4*p.length),this.pos++;const c=this.pos;this.pos=function(y,b,A){for(let I,O,z=0;z55295&&I<57344){if(!O){I>56319||z+1===b.length?(y[A++]=239,y[A++]=191,y[A++]=189):O=I;continue}if(I<56320){y[A++]=239,y[A++]=191,y[A++]=189,O=I;continue}I=O-55296<<10|I-56320|65536,O=null}else O&&(y[A++]=239,y[A++]=191,y[A++]=189,O=null);I<128?y[A++]=I:(I<2048?y[A++]=I>>6|192:(I<65536?y[A++]=I>>12|224:(y[A++]=I>>18|240,y[A++]=I>>12&63|128),y[A++]=I>>6&63|128),y[A++]=63&I|128)}return A}(this.buf,p,this.pos);const m=this.pos-c;m>=128&&Ije(c,m,this),this.pos=c-1,this.writeVarint(m),this.pos+=m}writeFloat(p){this.realloc(4),this.dataView.setFloat32(this.pos,p,!0),this.pos+=4}writeDouble(p){this.realloc(8),this.dataView.setFloat64(this.pos,p,!0),this.pos+=8}writeBytes(p){const c=p.length;this.writeVarint(c),this.realloc(c);for(let m=0;m=128&&Ije(m,y,this),this.pos=m-1,this.writeVarint(y),this.pos+=y}writeMessage(p,c,m){this.writeTag(p,2),this.writeRawMessage(c,m)}writePackedVarint(p,c){c.length&&this.writeMessage(p,WJe,c)}writePackedSVarint(p,c){c.length&&this.writeMessage(p,GJe,c)}writePackedBoolean(p,c){c.length&&this.writeMessage(p,YJe,c)}writePackedFloat(p,c){c.length&&this.writeMessage(p,KJe,c)}writePackedDouble(p,c){c.length&&this.writeMessage(p,ZJe,c)}writePackedFixed32(p,c){c.length&&this.writeMessage(p,XJe,c)}writePackedSFixed32(p,c){c.length&&this.writeMessage(p,QJe,c)}writePackedFixed64(p,c){c.length&&this.writeMessage(p,JJe,c)}writePackedSFixed64(p,c){c.length&&this.writeMessage(p,eet,c)}writeBytesField(p,c){this.writeTag(p,2),this.writeBytes(c)}writeFixed32Field(p,c){this.writeTag(p,5),this.writeFixed32(c)}writeSFixed32Field(p,c){this.writeTag(p,5),this.writeSFixed32(c)}writeFixed64Field(p,c){this.writeTag(p,1),this.writeFixed64(c)}writeSFixed64Field(p,c){this.writeTag(p,1),this.writeSFixed64(c)}writeVarintField(p,c){this.writeTag(p,0),this.writeVarint(c)}writeSVarintField(p,c){this.writeTag(p,0),this.writeSVarint(c)}writeStringField(p,c){this.writeTag(p,2),this.writeString(c)}writeFloatField(p,c){this.writeTag(p,5),this.writeFloat(c)}writeDoubleField(p,c){this.writeTag(p,1),this.writeDouble(c)}writeBooleanField(p,c){this.writeVarintField(p,+c)}};function tC(p,c,m){return m?4294967296*c+(p>>>0):4294967296*(c>>>0)+(p>>>0)}function Ije(p,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 b=m.pos-1;b>=p;b--)m.buf[b+y]=m.buf[b]}function WJe(p,c){for(let m=0;m=0&&y>=c&&FD[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 sC;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(zT.forText(c.scale,c.fontStack||m));const y=this.sections.length-1;for(let b=0;b=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ude(p,c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe=1){const Me=sC.fromFeature(p,b,xe);Q===ih.vertical&&Me.verticalizePunctuation(se);let Ce=[];const ze=function(St,It,Ot,ns,qt,us){if(!St)return[];const gs=[],xs=function(Ms,ds,as,Ts,Ws,Rs){let Mr=0;for(let or=0;or=0;let Is=0;for(let Ms=0;Ms0&&Ta>Nn&&(Nn=Ta)}else{const wa=Ot[Es.fontStack];if(!wa)continue;wa[rr]&&(wn=wa[rr]);const Ma=It[Es.fontStack];if(!Ma)continue;const Ta=Ma.glyphs[rr];if(!Ta)continue;if(Lr=Ta.metrics,Ln=rr!==8203?Ol:0,Rs){const ei=Ma.ascender!==void 0?Math.abs(Ma.ascender):0,gi=Ma.descender!==void 0?Math.abs(Ma.descender):0,ui=(ei+gi)*Ar;di-m/2;){if(I--,I<0)return!1;O-=p[I].dist(A),A=p[I]}O+=p[I].dist(p[I+1]),I++;const z=[];let q=0;for(;Oy;)q-=z.shift().angleDelta;if(q>b)return!1;I++,O+=X.dist(Q)}return!0}function qje(p){let c=0;for(let m=0;mq){const le=(q-z)/ae,xe=Jr(Q.x,se.x,le),Me=Jr(Q.y,se.y,le),Ce=new yy(xe,Me,0,se.angleTo(Q),X);return!I||Uje(p,Ce,O,I,c)?Ce:void 0}z+=ae}}function oet(p,c,m,y,b,A,I,O,z){const q=Vje(y,A,I),X=Hje(y,b),Q=X*I,se=p[0].x===0||p[0].x===z||p[0].y===0||p[0].y===z;return c-Q=0&&Je=0&&vt=0&&se+q<=X){const mt=new yy(Je,vt,0,ze,le);y&&!Uje(p,mt,A,y,b)||ae.push(mt)}}Q+=Ce}return O||ae.length||I||(ae=Wje(p,Q/2,m,y,b,A,I,!0,z)),ae}function Gje(p){let c=0,m=0;for(const I of p)c+=I.w*I.h,m=Math.max(m,I.w);p.sort((I,O)=>O.h-I.h);const y=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),m),h:1/0}];let b=0,A=0;for(const I of p)for(let O=y.length-1;O>=0;O--){const z=y[O];if(!(I.w>z.w||I.h>z.h)){if(I.x=z.x,I.y=z.y,A=Math.max(A,I.y+I.h),b=Math.max(b,I.x+I.w),I.w===z.w&&I.h===z.h){const q=y.pop();q&&O1?le-1:le,rd.copy(Q.data,q,{x:0,y:0},{x:xe,y:Me},Q.data,y),rd.copy(Q.data,q,{x:0,y:ze-le},{x:xe,y:Me-le},{width:Ce,height:le},y),rd.copy(Q.data,q,{x:0,y:0},{x:xe,y:Me+ze},{width:Ce,height:le},y),rd.copy(Q.data,q,{x:Ce-le,y:0},{x:xe-le,y:Me},{width:le,height:ze},y),rd.copy(Q.data,q,{x:0,y:0},{x:xe+Ce,y:Me},{width:le,height:ze},y),rd.copy(Q.data,q,{x:Ce-le,y:ze-le},{x:xe-le,y:Me-le},{width:le,height:le},y),rd.copy(Q.data,q,{x:0,y:ze-le},{x:xe+Ce,y:Me-le},{width:le,height:le},y),rd.copy(Q.data,q,{x:0,y:0},{x:xe+Ce,y:Me+ze},{width:le,height:le},y),rd.copy(Q.data,q,{x:Ce-le,y:0},{x:xe-le,y:Me+ze},{width:le,height:le},y)}this.lut=y,this.image=q,this.iconPositions=b,this.patternPositions=A}addImages(c,m,y,b){for(const[A,I]of c.entries()){const{bin:O,imagePosition:z,imageVariant:q}=gde(A,I,y);m.set(A,z),b.push(O),I.hasRenderCallback&&this.haveRenderCallbacks.push(q.id)}}patchUpdatedImages(c,m,y){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(b=>c.hasImage(b,y)),c.dispatchRenderCallbacks(this.haveRenderCallbacks,y);for(const b of c.getUpdatedImages(y)){for(const A of this.iconPositions.keys()){const I=mf.parse(A);if(La.isEqual(I.id,b)){const O=c.getImage(b,y);this.patchUpdatedImage(this.iconPositions.get(A),O,m,null)}}for(const A of this.patternPositions.keys()){const I=mf.parse(A);if(La.isEqual(I.id,b)){const O=c.getImage(b,y);this.patchUpdatedImage(this.patternPositions.get(A),O,m,this.lut)}}}}patchUpdatedImage(c,m,y,b=null){if(!c||!m||c.version===m.version)return;c.version=m.version;const[A,I]=c.tl,O=c.sdf;if(this.lut||O){const z={width:m.data.width,height:m.data.height},q=new rd(z);rd.copy(m.data,q,{x:0,y:0},{x:0,y:0},z,b,O),y.update(q,{position:{x:A,y:I}})}else y.update(m.data,{position:{x:A,y:I}})}}xr(BT,"ImagePosition"),xr(Kje,"ImageAtlas");const $T=1e20;function Zje(p,c,m,y,b,A,I,O,z){for(let q=c;q-1);z++,A[z]=O,I[z]=q,I[z+1]=$T}for(let O=0,z=0;O{let z=this.entries[A];z||(z=this.entries[A]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let q=z.glyphs[I];if(q!==void 0)return void O(null,{stack:A,id:I,glyph:q});if(q=this._tinySDF(z,A,I),q)return z.glyphs[I]=q,void O(null,{stack:A,id:I,glyph:q});const X=Math.floor(I/256);if(256*X>65535)return cr("glyphs > 65535 not supported"),void O(null,{stack:A,id:I,glyph:q});if(z.ranges[X])return void O(null,{stack:A,id:I,glyph:q});let Q=z.requests[X];Q||(Q=z.requests[X]=[],aC.loadGlyphRange(A,X,b,this.requestManager,(se,ae)=>{if(ae){z.ascender=ae.ascender,z.descender=ae.descender;for(const le in ae.glyphs)this._doesCharSupportLocalGlyph(+le)||(z.glyphs[+le]=ae.glyphs[+le]);z.ranges[X]=!0}for(const le of Q)le(se,ae);delete z.requests[X]})),Q.push((se,ae)=>{se?O(se):ae&&O(null,{stack:A,id:I,glyph:ae.glyphs[I]||null})})},(A,I)=>{if(A)m(A);else if(I){const O={};for(const{stack:z,id:q,glyph:X}of I)O[z]===void 0&&(O[z]={}),O[z].glyphs===void 0&&(O[z].glyphs={}),O[z].glyphs[q]=X&&{id:X.id,bitmap:X.bitmap.clone(),metrics:X.metrics},O[z].ascender=this.entries[z].ascender,O[z].descender=this.entries[z].descender;m(null,O)}})}_doesCharSupportLocalGlyph(c){return this.localGlyphMode!==xde.none&&(this.localGlyphMode===xde.all?!!this.localFontFamily:!!this.localFontFamily&&(qr["CJK Unified Ideographs"](c)||qr["Hangul Syllables"](c)||qr.Hiragana(c)||qr.Katakana(c)||qr["CJK Symbols and Punctuation"](c)||qr["CJK Unified Ideographs Extension A"](c)||qr["CJK Unified Ideographs Extension B"](c)||qr.Osage(c)))}_tinySDF(c,m,y){const b=this.localFontFamily;if(!b||!this._doesCharSupportLocalGlyph(y))return;let A=c.tinySDF;if(!A){let xe="400";/bold/i.test(m)?xe="900":/medium/i.test(m)?xe="500":/light/i.test(m)&&(xe="200"),A=c.tinySDF=new aC.TinySDF({fontFamily:b,fontWeight:xe,fontSize:24*Ef,buffer:3*Ef,radius:8*Ef}),A.fontWeight=xe}if(this.localGlyphs[A.fontWeight][y])return this.localGlyphs[A.fontWeight][y];const I=String.fromCodePoint(y),{data:O,width:z,height:q,glyphWidth:X,glyphHeight:Q,glyphLeft:se,glyphTop:ae,glyphAdvance:le}=A.draw(I);return this.localGlyphs[A.fontWeight][y]={id:y,bitmap:new cv({width:z,height:q},O),metrics:{width:X/Ef,height:Q/Ef,left:se/Ef,top:ae/Ef-27,advance:le/Ef,localGlyph:!0}}}}aC.loadGlyphRange=function(p,c,m,y,b){const A=256*c,I=A+255,O=y.transformRequest(y.normalizeGlyphsURL(m).replace("{fontstack}",p).replace("{range}",`${A}-${I}`),hf.Glyphs);Ju(O,(z,q)=>{if(z)b(z);else if(q){const X={},Q=function(se){return new RD(se).readFields(tet,{})}(q);for(const se of Q.glyphs)X[se.id]=se;b(null,{glyphs:X,ascender:Q.ascender,descender:Q.descender})}})},aC.TinySDF=class{constructor({fontSize:p=24,buffer:c=3,radius:m=8,cutoff:y=.25,fontFamily:b="sans-serif",fontWeight:A="normal",fontStyle:I="normal",lang:O=null}={}){this.buffer=c,this.cutoff=y,this.radius=m,this.lang=O;const z=this.size=p+4*c,q=this._createCanvas(z),X=this.ctx=q.getContext("2d",{willReadFrequently:!0});X.font=`${I} ${A} ${p}px ${b}`,X.textBaseline="alphabetic",X.textAlign="left",X.fillStyle="black",this.gridOuter=new Float64Array(z*z),this.gridInner=new Float64Array(z*z),this.f=new Float64Array(z),this.z=new Float64Array(z+1),this.v=new Uint16Array(z)}_createCanvas(p){const c=document.createElement("canvas");return c.width=c.height=p,c}draw(p){const{width:c,actualBoundingBoxAscent:m,actualBoundingBoxDescent:y,actualBoundingBoxLeft:b,actualBoundingBoxRight:A}=this.ctx.measureText(p),I=Math.ceil(m),O=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(A-b))),z=Math.min(this.size-this.buffer,I+Math.ceil(y)),q=O+2*this.buffer,X=z+2*this.buffer,Q=Math.max(q*X,0),se=new Uint8ClampedArray(Q),ae={data:se,width:q,height:X,glyphWidth:O,glyphHeight:z,glyphTop:I,glyphLeft:0,glyphAdvance:c};if(O===0||z===0)return ae;const{ctx:le,buffer:xe,gridInner:Me,gridOuter:Ce}=this;this.lang&&(le.lang=this.lang),le.clearRect(xe,xe,O,z),le.fillText(p,xe,xe+I);const ze=le.getImageData(xe,xe,O,z);Ce.fill($T,0,Q),Me.fill(0,0,Q);for(let Ve=0;Ve0?St*St:0,Me[mt]=St<0?St*St:0}}Zje(Ce,0,0,q,X,q,this.f,this.v,this.z),Zje(Me,xe,xe,O,z,q,this.f,this.v,this.z);for(let Ve=0;Ve{const As=$D(qt.stretch-ze,Ve,X,p.left*b),Is=UD(qt.fixed-mt,St,qt.stretch,le),Ns=$D(us.stretch-Je,vt,Q,p.top*b),Ms=UD(us.fixed-It,Ot,us.stretch,xe),ds=$D(gs.stretch-ze,Ve,X,p.left*b),as=UD(gs.fixed-mt,St,gs.stretch,le),Ts=$D(xs.stretch-Je,vt,Q,p.top*b),Ws=UD(xs.fixed-It,Ot,xs.stretch,xe),Rs=new cs(As,Ns),Mr=new cs(ds,Ns),or=new cs(ds,Ts),mr=new cs(As,Ts),vr=new cs(Is/O,Ms/O),Dn=new cs(as/O,Ws/O),zs=c*Math.PI/180;if(zs){const di=Math.sin(zs),pt=Math.cos(zs),bt=[pt,-di,di,pt];Rs._matMult(bt),Mr._matMult(bt),mr._matMult(bt),or._matMult(bt)}const _r=qt.stretch+qt.fixed,an=gs.stretch+gs.fixed,oa=us.stretch+us.fixed,ha=xs.stretch+xs.fixed,Nn=p.imageSecondary;return{tl:Rs,tr:Mr,bl:mr,br:or,texPrimary:{x:I.paddedRect.x+Jg+_r,y:I.paddedRect.y+Jg+oa,w:an-_r,h:ha-oa},texSecondary:Nn?{x:Nn.paddedRect.x+Jg+_r,y:Nn.paddedRect.y+Jg+oa,w:an-_r,h:ha-oa}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:vr,pixelOffsetBR:Dn,minFontScaleX:St/O/X,minFontScaleY:Ot/O/Q,isSDF:m}};if(y&&(I.stretchX||I.stretchY)){const qt=Qje(se,Me,le),us=Qje(ae,Ce,xe);for(let gs=0;gsA)&&(A=le.x),(!ae||le.y>I)&&(I=le.y)}const z=Math.min(A-y,I-b);let q=z/2;const X=new ZN([],het);if(z===0)return new cs(y,b);for(let ae=y;aeQ.d||!Q.d)&&(Q=ae,m&&console.log("found best %d after %d probes",Math.round(1e4*ae.d)/1e4,se)),ae.max-Q.d<=c||(q=ae.h/2,X.push(new iC(ae.p.x-q,ae.p.y-q,q,p)),X.push(new iC(ae.p.x+q,ae.p.y-q,q,p)),X.push(new iC(ae.p.x-q,ae.p.y+q,q,p)),X.push(new iC(ae.p.x+q,ae.p.y+q,q,p)),se+=4)}return m&&(console.log(`num probes: ${se}`),console.log(`best distance: ${Q.d}`)),Q.p}function het(p,c){return c.max-p.max}class iC{constructor(c,m,y,b){this.p=new cs(c,m),this.h=y,this.d=function(A,I){let O=!1,z=1/0;for(let q=0;qA.y!=xe.y>A.y&&A.x<(xe.x-le.x)*(A.y-le.y)/(xe.y-le.y)+le.x&&(O=!O),z=Math.min(z,jo(A,le,xe))}}return(O?1:-1)*Math.sqrt(z)}(this.p,b),this.max=this.d+this.h*Math.SQRT2}}const met=Object.keys,vde=Number.POSITIVE_INFINITY,pet=Math.sqrt(2);function uv(p,c,m,y,b){const A=mde(p)&&p.collisionPadding?p.collisionPadding:[0,0,0,0],I={top:p.top-A[1],bottom:p.bottom+A[3],left:p.left-A[0],right:p.right+A[2],scaled:!1};return y!==void 0&&function(O,z){O.top*=z,O.bottom*=z,O.left*=z,O.right*=z,O.scaled=!0}(I,y),m&&function(O,z){if(!z)return;const q=Or(z),X=new cs(O.left,O.top),Q=new cs(O.right,O.top),se=new cs(O.left,O.bottom),ae=new cs(O.right,O.bottom),le=new cs(0,0);X._rotateAround(q,le),Q._rotateAround(q,le),se._rotateAround(q,le),ae._rotateAround(q,le),O.left=Math.min(X.x,Q.x,se.x,ae.x),O.right=Math.max(X.x,Q.x,se.x,ae.x),O.top=Math.min(X.y,Q.y,se.y,ae.y),O.bottom=Math.max(X.y,Q.y,se.y,ae.y)}(I,m),b&&(I.left+=b[0],I.right+=b[0],I.top+=b[1],I.bottom+=b[1]),c?{top:Math.min(c.top,I.top),bottom:Math.max(c.bottom,I.bottom),left:Math.min(c.left,I.left),right:Math.max(c.right,I.right),scaled:c.scaled||I.scaled}:I}function eke(p,[c,m]){let y=0,b=0;if(m===vde){c<0&&(c=0);const A=c/pet;switch(p){case"top-right":case"top-left":b=A-7;break;case"bottom-right":case"bottom-left":b=7-A;break;case"bottom":b=7-c;break;case"top":b=c-7}switch(p){case"top-right":case"bottom-right":y=-A;break;case"top-left":case"bottom-left":y=A;break;case"left":y=c;break;case"right":y=-c}}else{switch(c=Math.abs(c),m=Math.abs(m),p){case"top-right":case"top-left":case"top":b=m-7;break;case"bottom-right":case"bottom-left":case"bottom":b=7-m}switch(p){case"top-right":case"bottom-right":case"right":y=-c;break;case"top-left":case"bottom-left":case"left":y=c}}return[y,b]}function fet(p,c,m,y,b,A,I,O,z,q,X,Q,se,ae){const le=p.layers[0],xe=le.appearances;if(xe.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Me={iconBBox:null,iconVerticalBBox:null},Ce={textBBox:null,textVerticalBBox:null},{baseIconRotate:ze,baseTextRotate:Ve,iconScaleFactor:Je}=function(mt,St,It){const Ot=mt.get("icon-rotate").evaluate(St,{},It),ns=mt.get("text-rotate").evaluate(St,{},It),[qt,us]=mt.get("icon-size-scale-range");return{baseIconRotate:Ot,baseTextRotate:ns,iconScaleFactor:_e(1,qt,us)}}(y,b,A);c&&(Me.iconBBox=uv(c,Me.iconBBox,ze,I),m)&&(Me.iconVerticalBBox=uv(m,Me.iconVerticalBBox,ze+90,I));const vt=VD(Q.horizontal);vt&&(Ce.textBBox=uv(vt,Ce.textBBox,Ve,1,ae)),Q.vertical&&(Ce.textVerticalBBox=uv(Q.vertical,Ce.textVerticalBBox,Ve+90,1,ae));for(const mt of xe)mt.hasIconProperties()&&get(Me,p,le,mt,b,A,O,ze,I,z,c,q,Je,X),mt.hasTextProperties()&&xet(Ce,le,mt,b,A,ae,Ve,se,vt,Q.vertical);return{iconBBox:Me.iconBBox,iconVerticalBBox:Me.iconVerticalBBox,textBBox:Ce.textBBox,textVerticalBBox:Ce.textVerticalBBox}}function get(p,c,m,y,b,A,I,O,z,q,X,Q,se,ae){const{appearanceIconOffset:le,appearanceIconRotate:xe,appearanceIconSize:Me}=function(Je,vt,mt,St,It,Ot,ns,qt){const us=Je.hasProperty("icon-offset")?vt.getAppearanceValueAndResolveTokens(Je,"icon-offset",mt,St,[]):null,gs=us&&Array.isArray(us)?us:It,xs=Je.hasProperty("icon-rotate")?vt.getAppearanceValueAndResolveTokens(Je,"icon-rotate",mt,St,[]):null,As=typeof xs=="number"?xs:Ot,Is=Je.hasProperty("icon-size")?vt.getAppearanceValueAndResolveTokens(Je,"icon-size",mt,St,[]):null;return{appearanceIconOffset:gs,appearanceIconRotate:As,appearanceIconSize:typeof Is=="number"?Is*qt.iconScaleFactor:ns}}(y,m,b,A,I,O,z,q);let Ce=null,ze=null,Ve=null;y.hasProperty("icon-image")?Ve=function(Je,vt,mt,St,It,Ot,ns){let qt=null;const us=vt.getAppearanceValueAndResolveTokens(mt,"icon-image",St,It,[]);if(us){const gs=Je.getResolvedImageFromTokens(us),xs=mt.getUnevaluatedProperty("icon-size"),As=UT(gs,rC(Je.zoom,xs,Je.worldview),xs,It,Je.zoom,St,Je.pixelRatio,ns,Je.worldview);qt=Ot.get(As.iconPrimary.toString())}return qt}(c,m,y,b,A,Q,se):X&&(Ve=X.imagePrimary),Ve&&(Ce=zD(Ve,null,le,ae),c.allowVerticalPlacement&&(ze=zD(Ve,null,le,ae))),Ce&&(p.iconBBox=uv(Ce,p.iconBBox,xe,Me)),ze&&(p.iconVerticalBBox=uv(ze,p.iconVerticalBBox,xe+90,Me))}function xet(p,c,m,y,b,A,I,O,z,q){const{appearanceTextOffset:X,appearanceTextRotate:Q,appearanceTextSize:se}=function(le,xe,Me,Ce,ze,Ve,Je){const vt=le.hasProperty("text-offset")?xe.getAppearanceValueAndResolveTokens(le,"text-offset",Me,Ce,[]):null,mt=vt&&Array.isArray(vt)?[vt[0]*Ol,vt[1]*Ol]:ze,St=le.hasProperty("text-rotate")?xe.getAppearanceValueAndResolveTokens(le,"text-rotate",Me,Ce,[]):null,It=typeof St=="number"?St:Ve,Ot=le.hasProperty("text-size")?xe.getAppearanceValueAndResolveTokens(le,"text-size",Me,Ce,[]):null;return{appearanceTextOffset:mt,appearanceTextRotate:It,appearanceTextSize:typeof Ot=="number"?Ot:Je}}(m,c,y,b,A,I,O),ae=se/O;z&&(p.textBBox=uv(z,p.textBBox,Q,ae,X)),q&&(p.textVerticalBBox=uv(q,p.textVerticalBBox,Q+90,ae,X))}function qD(p,c,m,y,b,A,I,O,z){if(!c||!c.usvg)return;const q=$je(y),X=$je(b),Q=A!=="both"&&A!=="width"||!zje(y)?1:X.width/q.width,se=A!=="both"&&A!=="height"||!Bje(y)?1:X.height/q.height;m.scaleSelf(Q,se);const ae=m.toString();I.set(ae,m),O.set(ae,c);const{imagePosition:le}=gde(ae,c,ib);z.set(ae,le)}function tke(p,c,m,y,b,A,I,O,z){if(!p)return;const q=function(X,Q,se,ae,le,xe){if(X.kind==="camera")return X.maxSize;if(X.kind==="composite"){const Me=Q.possiblyEvaluate(new Si(X.maxZoom,{worldview:xe}),se).evaluate(le,{},se),Ce=Q.possiblyEvaluate(new Si(X.minZoom,{worldview:xe}),se).evaluate(le,{},se);return Math.max(Me,Ce)}return Q.possiblyEvaluate(new Si(ae,{worldview:xe})).evaluate(le,{},se)}(c,m,y,b,A,z);return p.scaleSelf(q*O*I)}function UT(p,c,m,y,b,A,I,O,z){return{iconPrimary:tke(p.getPrimary(),c,m,y,b,A,I,O,z),iconSecondary:tke(p.getSecondary(),c,m,y,b,A,I,O,z)}}function yet(p,c,m){if(!c)return;const y=m.get(p.toString()),b=m.get(c.toString());y&&b&&(y.paddedRect.w===b.paddedRect.w&&y.paddedRect.h===b.paddedRect.h||cr(`Mismatch in icon variant sizes: ${p.toString()} and ${c.toString()}`),y.usvg!==b.usvg&&cr(`Mismatch in icon variant image types: ${p.id} and ${c.id}`))}function ske(p,c,m,y){if(!p)return;const b=c.get(m.toString());if(p.imagePrimary=b,y){const A=c.get(y.toString());p.imageSecondary=A}}function vet(p,c){for(const m in p.horizontal)rke(p.horizontal[m],c);rke(p.vertical,c)}function rke(p,c){if(p){for(const m of p.positionedLines)for(const y of m.positionedGlyphs)if(y.image!==null){const b=y.image.toString();y.rect=c.get(b).paddedRect}}}function _de(p){switch(p){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function _et(p,c,m,y,b,A,I,O,z){const q=VD(A.horizontal)||A.vertical,X=m.get("icon-text-fit-padding").evaluate(y,{},b);let Q,se=c;return c&&z!=="none"&&(p.allowVerticalPlacement&&A.vertical&&(Q=pde(c,A.vertical,z,X,O,I)),q&&(se=pde(c,q,z,X,O,I))),{defaultShapedIcon:se,verticallyShapedIcon:Q}}function bet(p,c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze,Ve,Je,vt,mt,St){let It=I.textMaxSize.evaluate(c,{},se);It===void 0?It=O*I.textScaleFactor:It*=I.textScaleFactor;const Ot=p.layers[0].layout,ns=Ol,qt=O*I.textScaleFactor/ns,us=VD(m.horizontal)||m.vertical;if(Me!=="none"&&p.appearanceFeatureData&&c.index18&&Ts>2&&(Ts>>=1),Math.max(Hs/(512*Ts),1)*Ot.get("symbol-spacing")),Is=Ot.get("text-padding")*p.tilePixelRatio,Ns=Ot.get("icon-padding")*p.tilePixelRatio,Ms=Or(Ot.get("text-max-angle")),ds=Ot.get("icon-rotation-alignment")==="map"&&Ve!=="point",as=As/2;var Ts;p.hasAnyIconTextFit===!1&&Me!=="none"&&(p.hasAnyIconTextFit=!0);const Ws=c.properties?+c.properties[is]:null,Rs=Ws&&p.elevationFeatureIdToIndex?p.elevationFeatureIdToIndex.get(Ws):65535,Mr=(or,mr,vr)=>{if(mr.x<0||mr.x>=Hs||mr.y<0||mr.y>=Hs)return;let Dn=null;if(gs){const{x:zs,y:_r,z:an}=ae.projectTilePoint(mr.x,mr.y,vr);Dn={anchor:new yy(zs,_r,an,0,void 0),up:ae.upVector(vr,mr.x,mr.y)}}(function(zs,_r,an,oa,ha,Nn,di,pt,bt,hs,Es,sr,rr,Ar,Lr,wn,An,Ln,ta,Gr,rn,wa,Ma,Ta,ei,gi,ui,Ra,Ua,En,ua,Qi,Hr){const sa=zs.addToLineVertexArray(_r,oa);let mi,_i,Ci,To,ki,Wr,io,ti=0,Ui=0,dl=0,Rl=0,Zo=-1,Yo=-1;const Sl={};let du=Cs("");const Ni=an?an.anchor:_r,ko=Ra!=="none";let Ao=0,Cu=0;if(bt._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Uc=bt.layout.get("text-offset").evaluate(rn,{},ei);Ao=Uc[0]*Ol,Cu=Uc[1]*Ol}else Ao=bt.layout.get("text-radial-offset").evaluate(rn,{},ei)*Ol,Cu=vde;if(zs.allowVerticalPlacement&&ha.vertical){const Uc=ha.vertical;if(Lr)Wr=bde(Uc),pt&&(io=bde(pt));else{const Ud=bt.layout.get("text-rotate").evaluate(rn,{},ei)+90;Ci=HD(hs,Ni,_r,Es,sr,rr,Uc,Ar,Ud,wn,Qi),pt&&(To=HD(hs,Ni,_r,Es,sr,rr,pt,Ln,Ud,null,ua))}}if(Nn){const Uc=zs.iconSizeData,Ud=bt.layout.get("icon-rotate").evaluate(rn,{},ei),oh=yde(Nn,Ud,Ma,ko,wa.iconScaleFactor),pv=pt?yde(pt,Ud,Ma,ko,wa.iconScaleFactor):void 0;_i=HD(hs,Ni,_r,Es,sr,rr,Nn,Ln,Ud,null,En);const mC=function(Df,iA,wNe,Ltt,jNe,kNe,Dtt,Ott){const NNe=Df.layers[0],SNe=NNe.appearances;let pC=iA.length;if(wNe&&(pC=Math.max(pC,wNe.length)),SNe.length===0)return pC;const[Rtt,Ftt]=Ltt.get("icon-size-scale-range"),ztt=_e(1,Rtt,Ftt);for(const CNe of SNe){const MNe=CNe.getUnevaluatedProperties();if(MNe._values["icon-image"].value!==void 0){const TNe=NNe.getAppearanceValueAndResolveTokens(CNe,"icon-image",jNe,kNe,[]);if(TNe){const ANe=Df.getResolvedImageFromTokens(TNe);if(ANe){const ENe=MNe._values["icon-size"],Btt=UT(ANe,rC(Df.zoom,ENe,Df.worldview),ENe,kNe,Df.zoom,jNe,Df.pixelRatio,ztt,Df.worldview),$tt=Dtt.get(Btt.iconPrimary.toString());pC=Math.max(pC,cet($tt,Ott))}}}}return pC}(zs,oh,pv,bt.layout,rn,ei,zs.iconAtlasPositions,ko);ti=4*mC;let Lf=null;Uc.kind==="source"?(Lf=[Af*bt.layout.get("icon-size").evaluate(rn,{},ei)*wa.iconScaleFactor],Lf[0]>vy&&cr(`${zs.layerIds[0]}: Value for "icon-size" is >= ${qT}. Reduce your "icon-size".`)):Uc.kind==="composite"&&(Lf=[Af*wa.compositeIconSizes[0].evaluate(rn,{},ei)*wa.iconScaleFactor,Af*wa.compositeIconSizes[1].evaluate(rn,{},ei)*wa.iconScaleFactor],(Lf[0]>vy||Lf[1]>vy)&&cr(`${zs.layerIds[0]}: Value for "icon-size" is >= ${qT}. Reduce your "icon-size".`)),zs.addSymbols(zs.icon,oh,Lf,Gr,ta,rn,void 0,an,_r,sa.lineStartIndex,sa.lineLength,-1,Ta,ei,gi,ui,zs.symbolInstances.length,mC),Zo=zs.icon.placedSymbolArray.length-1,pv&&(Ui=4*mC,zs.addSymbols(zs.icon,pv,Lf,Gr,ta,rn,ih.vertical,an,_r,sa.lineStartIndex,sa.lineLength,-1,Ta,ei,gi,ui,zs.symbolInstances.length,mC),Yo=zs.icon.placedSymbolArray.length-1)}for(const Uc in ha.horizontal){const Ud=Uc,oh=ha.horizontal[Ud];mi||(du=Cs(oh.text),Lr?ki=bde(oh):mi=HD(hs,Ni,_r,Es,sr,rr,oh,Ar,bt.layout.get("text-rotate").evaluate(rn,{},ei),wn,Qi));const pv=oh.positionedLines.length===1;if(dl+=nke(zs,an,_r,oh,di,bt,Lr,rn,wn,sa,ha.vertical?ih.horizontal:ih.horizontalOnly,pv?met(ha.horizontal):[Ud],Sl,Zo,wa,Ta,ei,zs.symbolInstances.length,gi),pv)break}ha.vertical&&(Rl+=nke(zs,an,_r,ha.vertical,di,bt,Lr,rn,wn,sa,ih.vertical,["vertical"],Sl,Yo,wa,Ta,ei,zs.symbolInstances.length,gi));let ul=-1;const kp=(Uc,Ud)=>Uc?Math.max(Uc,Ud):Ud;ul=kp(ki,ul),ul=kp(Wr,ul),ul=kp(io,ul);const ex=ul>-1?1:0;zs.glyphOffsetArray.length>=65535&&cr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),rn.sortKey!==void 0&&zs.addToSortKeyRanges(zs.symbolInstances.length,rn.sortKey),zs.symbolInstances.emplaceBack(_r.x,_r.y,Ni.x,Ni.y,Ni.z,Sl.right>=0?Sl.right:-1,Sl.center>=0?Sl.center:-1,Sl.left>=0?Sl.left:-1,Sl.vertical>=0?Sl.vertical:-1,Zo,Yo,du,mi!==void 0?mi:zs.collisionBoxArray.length,mi!==void 0?mi+1:zs.collisionBoxArray.length,Ci!==void 0?Ci:zs.collisionBoxArray.length,Ci!==void 0?Ci+1:zs.collisionBoxArray.length,_i!==void 0?_i:zs.collisionBoxArray.length,_i!==void 0?_i+1:zs.collisionBoxArray.length,To||zs.collisionBoxArray.length,To?To+1:zs.collisionBoxArray.length,Es,dl,Rl,ti,Ui,ex,0,Ao,Cu,ul,0,ko?1:0,Ua)})(p,mr,Dn,or,m,y,A,b,p.layers[0],p.collisionBoxArray,c.index,c.sourceLayerIndex,p.index,Is,ze,q,0,Ns,ds,Ce,c,I,X,Q,se,le,xe,Me,Rs,Je,vt,mt)};if(Ve==="line")for(const or of SD(c.geometry,0,0,Hs,Hs)){const mr=oet(or,As,Ms,m.vertical||us,y,ns,xs,p.overscaling,Hs);for(const vr of mr)us&&wet(p,us.text,as,vr)||Mr(or,vr,se)}else if(Ve==="line-center"){for(const or of c.geometry)if(or.length>1){const mr=iet(or,Ms,m.vertical||us,y,ns,xs);mr&&Mr(or,mr,se)}}else if(c.type==="Polygon")for(const or of NT(c.geometry,0)){const mr=uet(or,16);Mr(or[0],new yy(mr.x,mr.y,0,0,void 0),se)}else if(c.type==="LineString")for(const or of c.geometry)Mr(or,new yy(or[0].x,or[0].y,0,0,void 0),se);else if(c.type==="Point")for(const or of c.geometry)for(const mr of or)Mr([mr],new yy(mr.x,mr.y,0,0,void 0),se)}const qT=255,vy=qT*Af;function nke(p,c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze){const Ve=function(mt,St,It,Ot,ns,qt,us,gs){const xs=[];if(St.positionedLines.length===0)return xs;const As=Ot.layout.get("text-rotate").evaluate(qt,{})*Math.PI/180,Is=function(Ts){const Ws=Ts[0],Rs=Ts[1],Mr=Ws*Rs;return Mr>0?[Ws,-Rs]:Mr<0?[-Ws,Rs]:Ws===0?[Rs,Ws]:[Rs,-Ws]}(It);let Ns=Math.abs(St.top-St.bottom);for(const Ts of St.positionedLines)Ns-=Ts.lineOffset;const Ms=St.positionedLines.length,ds=Ns/Ms;let as=St.top-It[1];for(let Ts=0;Tsvy&&cr(`${p.layerIds[0]}: Value for "text-size" is >= ${qT}. Reduce your "text-size".`)):Je.kind==="composite"&&(vt=[Af*le.compositeTextSizes[0].evaluate(O,{},Me)*le.textScaleFactor,Af*le.compositeTextSizes[1].evaluate(O,{},Me)*le.textScaleFactor],(vt[0]>vy||vt[1]>vy)&&cr(`${p.layerIds[0]}: Value for "text-size" is >= ${qT}. Reduce your "text-size".`)),p.addSymbols(p.text,Ve,vt,z,I,O,X,c,m,q.lineStartIndex,q.lineLength,ae,xe,Me,ze,!1,Ce,Ve.length);for(const mt of Q)se[mt]=p.text.placedSymbolArray.length-1;return 4*Ve.length}function VD(p){for(const c in p)return p[c];return null}function HD(p,c,m,y,b,A,I,O,z,q,X){let Q,se,ae,le;if(Q=X?X.top:I.top,se=X?X.bottom:I.bottom,ae=X?X.left:I.left,le=X?X.right:I.right,mde(I)&&I.collisionPadding){const xe=I.collisionPadding;ae-=xe[0],Q-=xe[1],le+=xe[2],se+=xe[3]}if(z){const xe=new cs(ae,Q),Me=new cs(le,Q),Ce=new cs(ae,se),ze=new cs(le,se),Ve=Or(z);let Je=new cs(0,0);q&&(Je=new cs(q[0],q[1])),xe._rotateAround(Ve,Je),Me._rotateAround(Ve,Je),Ce._rotateAround(Ve,Je),ze._rotateAround(Ve,Je),ae=Math.min(xe.x,Me.x,Ce.x,ze.x),le=Math.max(xe.x,Me.x,Ce.x,ze.x),Q=Math.min(xe.y,Me.y,Ce.y,ze.y),se=Math.max(xe.y,Me.y,Ce.y,ze.y)}return p.emplaceBack(c.x,c.y,c.z,m.x,m.y,ae,Q,le,se,O,y,b,A),p.length-1}function bde(p){mde(p)&&p.collisionPadding&&(p.top-=p.collisionPadding[1],p.bottom+=p.collisionPadding[3]);const c=p.bottom-p.top;return c>0?Math.max(10,c):null}function wet(p,c,m,y){const b=p.compareText;if(c in b){const A=b[c];for(let I=A.length-1;I>=0;I--)if(y.dist(A[I])Ve&&(Je(mt,xs,It,Ot,us,gs),Je(xs,St,us,gs,ns,qt))}Je(Q,se,y,A,b,A),Je(se,ae,b,A,b,I),Je(ae,le,b,I,y,I),Je(le,Q,y,I,y,A),xe-=Ve,Me-=Ve,Ce+=Ve,ze+=Ve;const vt=1/Math.max(Ce-xe,ze-Me);return{scale:vt,x:xe*vt,y:Me*vt,x2:Ce*vt,y2:ze*vt,projection:c}}function ike(p,{x:c,y:m},y=0){return new cs(((c-y)*p.scale-p.x)*Hs,(m*p.scale-p.y)*Hs)}const jet=k(new Float32Array(16));class hv{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,b=!0){return c._coordinatePoint(c.locationCoordinate(m,y),b)}pixelsPerMeter(c,m){return te(1,c)*m}pixelSpaceConversion(c,m,y){return 1}farthestPixelDistance(c){return ake(c,c.pixelsPerMeter)}pointCoordinate(c,m,y,b){const A=c.horizonLineFromTop(!1),I=new cs(m,Math.max(A,y));return c.rayIntersectionCoordinate(c.pointRayIntersection(I,b))}pointCoordinate3D(c,m,y){const b=new cs(m,y);if(c.elevation)return c.elevation.pointCoordinate(b);{const A=this.pointCoordinate(c,b.x,b.y,0);return[A.x,A.y,A.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<-oC+y&&(m=-oC+y):m>oC-y&&(m=oC-y);const I=A/Math.pow(GD(m),b);let O=I*Math.sin(b*c),z=A-I*Math.cos(b*c);return O=.5*(O/Math.PI+.5),z=.5*(z/Math.PI+.5),{x:O,y:this.southernCenter?z:1-z,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:b}=this,A=b-m,I=Math.sign(A),O=Math.sign(y)*Math.sqrt(c*c+A*A);let z=Math.atan2(c,Math.abs(A))*I;A*y<0&&(z-=Math.PI*Math.sign(c)*I);const q=_e(Oi(z/y)+this.center[0],-180,180),X=_e(Oi(2*Math.atan(Math.pow(b/O,1/y))-oC),-fe,fe);return new x(q,this.southernCenter?-X:X)}}class oke extends hv{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:U(c),y:K(m),z:0}}unproject(c,m){const y=re(c),b=pe(m);return new x(y,b)}}const lke=Or(fe);class Tet extends hv{project(c,m){const y=(m=Or(m))*m,b=y*y;return{x:.5*((c=Or(c))*(.8707-.131979*y+b*(b*(.003971*y-.001529*b)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+y*(.015085+b*(.028874*y-.044475-.005916*b)))/Math.PI+1),z:0}}unproject(c,m){c=(2*c-.5)*Math.PI;let y=m=(2*(1-m)-1)*Math.PI,b=25,A=0,I=y*y;do{I=y*y;const q=I*I;A=(y*(1.007226+I*(.015085+q*(.028874*I-.044475-.005916*q)))-m)/(1.007226+I*(.045255+q*(.259866*I-.311325-.005916*11*q))),y=_e(y-A,-lke,lke)}while(Math.abs(A)>1e-6&&--b>0);I=y*y;const O=_e(Oi(c/(.8707+I*(I*(I*I*I*(.003971-.001529*I)-.013791)-.131979))),-180,180),z=Oi(y);return new x(O,z)}}const cke=Or(fe);class Aet extends hv{project(c,m){m=Or(m),c=Or(c);const y=Math.cos(m),b=2/Math.PI,A=Math.acos(y*Math.cos(c/2)),I=Math.sin(A)/A,O=.5*(c*b+2*y*Math.sin(c/2)/I)||0,z=.5*(m+Math.sin(m)/I)||0;return{x:.5*(O/Math.PI+.5),y:1-.5*(z/Math.PI+1),z:0}}unproject(c,m){let y=c=(2*c-.5)*Math.PI,b=m=(2*(1-m)-1)*Math.PI,A=25;const I=1e-6;let O=0,z=0;do{const q=Math.cos(b),X=Math.sin(b),Q=2*X*q,se=X*X,ae=q*q,le=Math.cos(y/2),xe=Math.sin(y/2),Me=2*le*xe,Ce=xe*xe,ze=1-ae*le*le,Ve=ze?1/ze:0,Je=ze?Math.acos(q*le)*Math.sqrt(1/ze):0,vt=.5*(2*Je*q*xe+2*y/Math.PI)-c,mt=.5*(Je*X+b)-m,St=.5*Ve*(ae*Ce+Je*q*le*se)+1/Math.PI,It=Ve*(Me*Q/4-Je*X*xe),Ot=.125*Ve*(Q*xe-Je*X*ae*Me),ns=.5*Ve*(se*le+Je*Ce*q)+.5,qt=It*Ot-ns*St;O=(mt*It-vt*ns)/qt,z=(vt*Ot-mt*St)/qt,y=_e(y-O,-Math.PI,Math.PI),b=_e(b-z,-cke,cke)}while((Math.abs(O)>I||Math.abs(z)>I)&&--A>0);return new x(Oi(y),Oi(b))}}class dke extends hv{constructor(c){super(c),this.center=c.center||[0,0],this.parallels=c.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Or(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:b}=this;return{x:Or(c)*b*y+.5,y:-Math.sin(Or(m))/b*y+.5,z:0}}unproject(c,m){const{scale:y,cosPhi:b}=this,A=-(m-.5)/y,I=_e(Oi((c-.5)/y)/b,-180,180),O=Math.asin(_e(A*b,-1,1)),z=_e(Oi(O),-fe,fe);return new x(I,z)}}class Eet extends oke{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 b=vT(c,m,y);return st(b,b,xD(Mm(y))),{x:b[0],y:b[1],z:b[2]}}locationPoint(c,m,y){const b=av(m.lat,m.lng),A=De([],b),I=y?c._centerAltitude+y:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(m),c._centerAltitude):c._centerAltitude;Ke(b,b,A,te(1,0)*Hs*I);const O=k(new Float64Array(16));return S(O,c.pixelMatrix,c.globeMatrix),st(b,b,O),new cs(b[0],b[1])}pixelsPerMeter(c,m){return te(1,0)*m}pixelSpaceConversion(c,m,y){const b=te(1,c)*m,A=Jr(te(1,45)*m,b,y);return this.pixelsPerMeter(c,m)/A}createTileMatrix(c,m,y){const b=Sce(Mm(y.canonical));return S(new Float64Array(16),c.globeMatrix,b)}createInversionMatrix(c,m){const{center:y}=c,b=xD(Mm(m));return B(b,b,Or(y.lng)),L(b,b,Or(y.lat)),D(b,b,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(b)}pointCoordinate(c,m,y,b){return ov(c,m,y,!0)||new Ze(0,0)}pointCoordinate3D(c,m,y){const b=this.pointCoordinate(c,m,y,0);return[b.x,b.y,b.z]}isPointAboveHorizon(c,m){return!ov(c,m.x,m.y,!1)}farthestPixelDistance(c){const m=function(b,A){const I=b.cameraToCenterDistance,O=b._centerAltitude*A,z=b._camera,q=b._camera.forward(),X=ce([],Se([],q,-I),[0,0,O]),Q=b.worldSize/(2*Math.PI),se=[0,0,-Q],ae=b.width/b.height,le=Math.tan(b.fovAboveCenter),xe=Se([],z.up(),le),Me=Se([],z.right(),le*ae),Ce=De([],ce([],ce([],q,xe),Me)),ze=[];let Ve;if(new yr(X,Ce).closestPointOnSphere(se,Q,ze)){const Je=ce([],ze,se),vt=ke([],Je,X);Ve=Math.cos(b.fovAboveCenter)*de(vt)}else{const Je=ke([],X,se),vt=ke([],se,X);De(vt,vt);const mt=de(Je)-Q;Ve=Math.sqrt(mt*(mt+2*Q));const St=Math.acos(Ve/(Q+mt))-Math.acos(Ge(q,vt));Ve*=Math.cos(St)}return 1.01*Ve}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),y=lv(c.zoom);if(y>0){const b=ake(c,te(1,c.center.lat)*c.worldSize),A=c.worldSize/(2*Math.PI),I=Math.max(c.width,c.height)/c.worldSize*Math.PI;return Jr(m,b+A*(1-Math.cos(I)),Math.pow(y,10))}return m}upVector(c,m,y){return vT(m,y,c,1)}upVectorScale(c){return{metersToTile:wp(gD(Mm(c)))}}}function uke(p){const c=p.parallels,m=!!c&&Math.abs(c[0]+c[1])<.01;switch(p.name){case"mercator":return new oke(p);case"equirectangular":return new Cet(p);case"naturalEarth":return new Tet(p);case"equalEarth":return new Net(p);case"winkelTripel":return new Aet(p);case"albers":return m?new dke(p):new ket(p);case"lambertConformalConic":return m?new dke(p):new Met(p);case"globe":return new Eet(p)}throw new Error(`Invalid projection name: ${p.name}`)}const Iet=Bt.types,Pet=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ZT(p,c,m,y,b,A,I,O,z,q,X,Q,se){const ae=O?Math.min(vy,Math.round(O[0])):0,le=O?Math.min(vy,Math.round(O[1])):0;p.emplaceBack(c,m,Math.round(32*y),Math.round(32*b),A,I,(ae<<1)+(z?1:0),0+(le<<1),16*q,16*X,256*Q,256*se)}function YT(p,c,m){p.emplaceBack(c,m)}function XT(p,c,m,y,b,A,I){p.emplaceBack(c,m,y,b,A,I)}const KD=(p,c,m,y)=>{for(let b=0;b0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,zJe.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,DJe.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||A)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,RJe.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,FJe.members,!0)),this.opacityVertexBuffer.itemSize=1),(y||b)&&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())}}xr(wde,"SymbolBuffers");class jde{constructor(c,m,y){this.layoutVertexArray=new c,this.layoutAttributes=m,this.indexArray=new y,this.segments=new ro,this.collisionVertexArray=new nT,this.collisionVertexArrayExt=new Kg}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,BJe.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,$Je.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}xr(jde,"CollisionBuffers");class ZD{constructor(c){this.collisionBoxArray=c.collisionBoxArray,this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(I=>I.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=k([]),this.placementViewportMatrix=k([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=c.worldview,this.localizable=c.localizable,this.textSizeData=rC(this.zoom,m["text-size"],this.worldview),this.iconSizeData=rC(this.zoom,m["icon-size"],this.worldview);const y=this.layers[0].layout,b=y.get("symbol-sort-key"),A=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=A!=="viewport-y"&&b.constantOr(1)!==void 0,this.sortFeaturesByY=(A==="viewport-y"||A==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=y.get("text-writing-mode").map(I=>ih[I]),this.stateDependentLayerIds=this.layers.filter(I=>I.isStateDependent()).map(I=>I.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 wde(new Sm(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new wde(new Sm(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.glyphOffsetArray=new zS,this.lineVertexArray=new uD,this.symbolInstances=new uT}calculateGlyphDependencies(c,m,y,b,A){for(const I of c){const O=I.codePointAt(0);if(O===void 0)break;if(m[O]=!0,b&&A&&O<=65535){const z=FT[I];z&&(m[z.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(c,m,y,b,A,I){let O=1;const z=c.getUnevaluatedProperties()._values["icon-size"],q=rC(this.zoom,z,this.worldview),X=nC(q,m);if(q.kind!=="constant"&&q.kind!=="camera"||(O=X.uSize),q.kind==="composite"){const{minZoom:Q,maxZoom:se}=q,ae=z.possiblyEvaluate(new Si(Q,{worldview:this.worldview}),b),le=z.possiblyEvaluate(new Si(se,{worldview:this.worldview}),b),xe=ae.evaluate(y,{},b,A);O=xe+(le.evaluate(y,{},b,A)-xe)*X.uSizeT}return q.kind==="source"&&(O=z.possiblyEvaluate(new Si(this.zoom,{worldview:this.worldview}),b).evaluate(y,{},b,A)),O*I}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!jD(this.activeReplacements,y)&&(this.activeReplacements=y,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Rd.build(c):c}populate(c,m,y,b){const A=this.layers[0],I=A.layout,O=this.projection.name==="globe",z=I.get("text-font"),q=I.get("text-field"),X=I.get("icon-image"),[Q,se]=I.get("icon-size-scale-range"),ae=_e(m.scaleFactor||1,Q,se),le=(q.value.kind!=="constant"||q.value.value instanceof Od&&!q.value.value.isEmpty()||q.value.value.toString().length>0)&&(z.value.kind!=="constant"||z.value.value.length>0),xe=X.value.kind!=="constant"||!!X.value.value||Object.keys(X.parameters).length>0,Me=this.hasAnyAppearanceProperty("icon-image"),Ce=I.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!le&&!xe&&!Me)return;const ze=m.iconDependencies,Ve=m.glyphDependencies,Je=m.availableImages,vt=new Si(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),mt=St=>{const It=St.id.toString();ze.has(It)?ze.get(It).push(St):ze.set(It,[St])};for(const St of c){const{feature:It,id:Ot,index:ns,sourceLayerIndex:qt}=St,us=A._featureFilter.needGeometry,gs=Ut(It,us);if(!A._featureFilter.filter(vt,gs,y))continue;if(us||(gs.geometry=At(It,y,b)),O&&It.type!==1&&y.z<=5){const Ts=gs.geometry,Ws=.98078528056,Rs=(Mr,or)=>Ge(vT(Mr.x,Mr.y,y,1),vT(or.x,or.y,y,1)){if(!Ts.getProperty("icon-image"))return;const Ws=this.getCombinedIconPrimary(Ts,Is,gs,y,Je,ds,ae);Ws&&mt(Ws)}),xs){const Ts=z.evaluate(gs,{},y).join(","),Ws=I.get("text-rotation-alignment")==="map"&&I.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(ih.vertical)>=0;for(const Rs of xs.sections)if(Rs.image){const Mr=Rs.image.getPrimary().scaleSelf(this.pixelRatio),or=Mr.id.toString(),mr=ze.get(or)||[];mr.push(Mr),ze.set(or,mr)}else{const Mr=$_(xs.toString()),or=Rs.fontStack||Ts,mr=Ve[or]=Ve[or]||{};this.calculateGlyphDependencies(Rs.text,mr,Ws,this.allowVerticalPlacement,Mr)}}}if(I.get("symbol-placement")==="line"&&(this.features=function(St){const It={},Ot={},ns=[];let qt=0;function us(Is){ns.push(St[Is]),qt++}function gs(Is,Ns,Ms){const ds=Ot[Is];return delete Ot[Is],Ot[Ns]=ds,ns[ds].geometry[0].pop(),ns[ds].geometry[0]=ns[ds].geometry[0].concat(Ms[0]),ds}function xs(Is,Ns,Ms){const ds=It[Ns];return delete It[Ns],It[Is]=ds,ns[ds].geometry[0].shift(),ns[ds].geometry[0]=Ms[0].concat(ns[ds].geometry[0]),ds}function As(Is,Ns,Ms){const ds=Ms?Ns[0][Ns[0].length-1]:Ns[0][0];return`${Is}:${ds.x}:${ds.y}`}for(let Is=0;IsIs.geometry)}(this.features)),I.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 I.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,b,A,I,O){let z,q;const X=c.getUnevaluatedProperties();if(X._values["icon-image"].value!==void 0){const Q=m.getAppearanceValueAndResolveTokens(c,"icon-image",y,b,A);z=this.getResolvedImageFromTokens(Q)}else{const Q=m.getValueAndResolveTokens("icon-image",y,b,A);z=this.getResolvedImageFromTokens(Q)}if(z){const Q=X._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];q=UT(z,rC(this.zoom,Q,this.worldview),Q,b,this.zoom,I,this.pixelRatio,O,this.worldview).iconPrimary}return q}updateAppearanceBasedIconTextures(c,m,y,b){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const A=this.layers[0];let I=!1,O=0;const z=A.layout,[q,X]=z.get("icon-size-scale-range"),Q=_e(1,q,X);for(let se=0;se=0){const Me=xe.id,Ce=m&&Me!==void 0?m[String(Me)]:void 0,ze={type:"Point",id:xe.id,properties:xe.properties,geometry:[]},Ve=this.layers[0].appearances&&this.layers[0].appearances.find(Je=>Je.isActive({globals:b,feature:ze,canonical:c,featureState:Ce}));if(xe.activeAppearance===Ve){O+=ae.numIconVertices;continue}if(Ve){xe.activeAppearance=Ve;const Je=this.getCombinedIconPrimary(Ve,A,ze,c,y,{sortKey:void 0,text:void 0,icon:null,index:ae.featureIndex,sourceLayerIndex:ae.featureIndex,geometry:[],properties:xe.properties,type:"Point",id:xe.id},Q);if(!Je)continue;const vt=Je.toString(),mt=this.iconAtlasPositions&&this.iconAtlasPositions.get(vt);if(mt){const St=A.getAppearanceValueAndResolveTokens(Ve,"icon-offset",ze,c,y),It=St&&Array.isArray(St)?St:[0,0];let Ot=zD(mt,void 0,It,A.layout.get("icon-anchor").evaluate(ze,{},c));const ns=A.getAppearanceValueAndResolveTokens(Ve,"icon-rotate",ze,c,y),qt=typeof ns=="number"?ns:0,us=mt.sdf,gs=A.layout.get("icon-text-fit").constantOr("none");gs!=="none"&&xe.textShaping&&xe.iconTextFitPadding&&xe.fontScale&&(Ot=pde(Ot,xe.textShaping,gs,xe.iconTextFitPadding,It,xe.fontScale));const xs=this.calculateEffectiveAppearanceIconSize(Ve,b.zoom,ze,c,y,Q),As=0,Is=1+(Math.min(vy,Math.round(xs*Af))<<1),Ns=yde(Ot,qt,us,gs!=="none",Q);xe.isUsingAppearanceVertexData||(xe.isUsingAppearanceVertexData=!0,xe.layoutBasedVertexData=this.icon.getIconVertexData(O,ae.numIconVertices));for(let ds=0;ds0&&(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),I=!0),O+=ae.numIconVertices,xe.activeAppearance=null;else if(xe.isUsingAppearanceVertexData){const vt=xe.layoutBasedVertexData.length/12;for(let mt=0;mt0||se>0,Me=ae>0,Ce=this.elevationFeatures[z.elevationFeatureIndex];if(Ce){const ze=new cs(z.tileAnchorX,z.tileAnchorY),Ve=.075+Ce.pointElevation(ze);z.zOffset!==Ve&&(m=!0,z.zOffset=Ve),Ve!==0&&(this.hasAnyZOffset=!0);const Je=Ce.computeSlopeNormal(ze,b),vt=fs(xt(),oe(0,0,1),Je);We(q,q,vt),We(X,X,vt),q[2]*=y,X[2]*=y,q[0]===1&&q[1]===0&&q[2]===0&&X[0]===0&&X[1]===1&&X[2]===0||(A=A||xe,I=I||Me)}if(xe&&(KD(this.text.orientationVertexArray,Q,q,X),KD(this.text.orientationVertexArray,se,q,X)),Me){const{placedIconSymbolIndex:ze,verticalPlacedIconSymbolIndex:Ve}=z;ze>=0&&KD(this.icon.orientationVertexArray,ae,q,X),Ve>=0&&KD(this.icon.orientationVertexArray,le,q,X)}}A||(this.text.orientationVertexArray=void 0),I||(this.icon.orientationVertexArray=void 0),m&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const c=(A,I,O)=>{y+=I,y>A.length&&A.resize(y);for(let z=-I;z<0;z++)A.emplace(z+y,O)},m=(A,I,O)=>{b+=I,b>A.length&&A.resize(b);for(let z=-I;z<0;z++)A.emplace(z+b,O)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let y=0,b=0;for(let A=0;A0;if((O>0||z>0)&&(c(this.text.zOffsetVertexArray,O,X),c(this.text.zOffsetVertexArray,z,X)),Q){const{placedIconSymbolIndex:se,verticalPlacedIconSymbolIndex:ae}=I;se>=0&&m(this.icon.zOffsetVertexArray,q,X),ae>=0&&m(this.icon.zOffsetVertexArray,I.numVerticalIconVertices,X)}}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,b,A){!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(I=>I.appearances&&I.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,b){return!!(c&&m&&y)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(c,m,y,b)&&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=uke(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:b,y:A}of m)this.lineVertexArray.emplaceBack(b,A);return{lineStartIndex:y,lineLength:this.lineVertexArray.length-y}}addSymbols(c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe,Me,Ce,ze){const Ve=c.indexArray,Je=c.layoutVertexArray,vt=c.globeExtVertexArray,mt=c.segments.prepareSegment(4*ze,Je,Ve,this.canOverlap?I.sortKey:void 0),St=this.glyphOffsetArray.length,It=mt.vertexLength,Ot=this.allowVerticalPlacement&&O===ih.vertical?Math.PI/2:0,ns=I.text&&I.text.sections;for(let gs=0;gs=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:b),I=fde(this.textSizeData,c,A)/Ol;return this.tilePixelRatio*I}getSymbolInstanceIconSize(c,m,y){const b=this.icon.placedSymbolArray.get(y),A=fde(this.iconSizeData,c,b);return this.tilePixelRatio*A}_commitDebugCollisionVertexUpdate(c,m,y,b){c.emplaceBack(m,-y,-y,b),c.emplaceBack(m,y,-y,b),c.emplaceBack(m,y,y,b),c.emplaceBack(m,-y,y,b)}_updateTextDebugCollisionBoxes(c,m,y,b,A,I,O){for(let z=b;z0}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),b=y.vertexStartIndex+4*y.numGlyphs;for(let A=y.vertexStartIndex;Ab[O]-b[z]||A[z]-A[O]),I}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:b,centerJustifiedTextSymbolIndex:A,leftJustifiedTextSymbolIndex:I,verticalPlacedTextSymbolIndex:O,placedIconSymbolIndex:z,verticalPlacedIconSymbolIndex:q}=y;b>=0&&this.addIndicesForPlacedSymbol(this.text,b),A>=0&&A!==b&&this.addIndicesForPlacedSymbol(this.text,A),I>=0&&I!==A&&I!==b&&this.addIndicesForPlacedSymbol(this.text,I),O>=0&&this.addIndicesForPlacedSymbol(this.text,O),z>=0&&this.addIndicesForPlacedSymbol(this.icon,z),q>=0&&this.addIndicesForPlacedSymbol(this.icon,q)}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 p?String(p[y]):"")}let mke,pke,kde;xr(ZD,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),ZD.addDynamicAttributes=lC;class fke{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:bm,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}}xr(fke,"FormatSectionOverride",{omit:["defaultValue"]});const Nde=()=>kde||(kde={layout:mke||(mke=new xo({"symbol-placement":new $s(Vt.layout_symbol["symbol-placement"]),"symbol-spacing":new $s(Vt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new $s(Vt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Xs(Vt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new $s(Vt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new $s(Vt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new $s(Vt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new $s(Vt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new $s(Vt.layout_symbol["icon-ignore-placement"]),"icon-optional":new $s(Vt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new $s(Vt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Xs(Vt.layout_symbol["icon-size"]),"icon-size-scale-range":new $s(Vt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Xs(Vt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Xs(Vt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Xs(Vt.layout_symbol["icon-image"]),"icon-image-use-theme":new $s({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Xs(Vt.layout_symbol["icon-rotate"]),"icon-padding":new $s(Vt.layout_symbol["icon-padding"]),"icon-keep-upright":new $s(Vt.layout_symbol["icon-keep-upright"]),"icon-offset":new Xs(Vt.layout_symbol["icon-offset"]),"icon-anchor":new Xs(Vt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new $s(Vt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new $s(Vt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new $s(Vt.layout_symbol["text-rotation-alignment"]),"text-field":new Xs(Vt.layout_symbol["text-field"]),"text-font":new Xs(Vt.layout_symbol["text-font"]),"text-size":new Xs(Vt.layout_symbol["text-size"]),"text-size-scale-range":new $s(Vt.layout_symbol["text-size-scale-range"]),"text-max-width":new Xs(Vt.layout_symbol["text-max-width"]),"text-line-height":new Xs(Vt.layout_symbol["text-line-height"]),"text-letter-spacing":new Xs(Vt.layout_symbol["text-letter-spacing"]),"text-justify":new Xs(Vt.layout_symbol["text-justify"]),"text-radial-offset":new Xs(Vt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new $s(Vt.layout_symbol["text-variable-anchor"]),"text-anchor":new Xs(Vt.layout_symbol["text-anchor"]),"text-max-angle":new $s(Vt.layout_symbol["text-max-angle"]),"text-writing-mode":new $s(Vt.layout_symbol["text-writing-mode"]),"text-rotate":new Xs(Vt.layout_symbol["text-rotate"]),"text-padding":new $s(Vt.layout_symbol["text-padding"]),"text-keep-upright":new $s(Vt.layout_symbol["text-keep-upright"]),"text-transform":new Xs(Vt.layout_symbol["text-transform"]),"text-offset":new Xs(Vt.layout_symbol["text-offset"]),"text-allow-overlap":new $s(Vt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new $s(Vt.layout_symbol["text-ignore-placement"]),"text-optional":new $s(Vt.layout_symbol["text-optional"]),visibility:new $s(Vt.layout_symbol.visibility)})),paint:pke||(pke=new xo({"icon-opacity":new Xs(Vt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Xs(Vt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Xs(Vt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Xs(Vt.paint_symbol["text-emissive-strength"]),"icon-color":new Xs(Vt.paint_symbol["icon-color"]),"icon-halo-color":new Xs(Vt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Xs(Vt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Xs(Vt.paint_symbol["icon-halo-blur"]),"icon-translate":new $s(Vt.paint_symbol["icon-translate"]),"icon-translate-anchor":new $s(Vt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new $s(Vt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Xs(Vt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Xs(Vt.paint_symbol["text-occlusion-opacity"]),"text-color":new Xs(Vt.paint_symbol["text-color"],{runtimeType:iu,getOverride:p=>p.textColor,hasOverride:p=>!!p.textColor}),"text-halo-color":new Xs(Vt.paint_symbol["text-halo-color"]),"text-halo-width":new Xs(Vt.paint_symbol["text-halo-width"]),"text-halo-blur":new Xs(Vt.paint_symbol["text-halo-blur"]),"text-translate":new $s(Vt.paint_symbol["text-translate"]),"text-translate-anchor":new $s(Vt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new $s(Vt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new $s(Vt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new $s(Vt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new $s(Vt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Xs(Vt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"})}))},kde);class YD extends Bd{constructor(c,m,y,b){super(c,Nde(),m,y,b,c.layout?c.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=k([]),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(b=>{b.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 b=[];for(const A of y)b.indexOf(A)<0&&b.push(A);this.layout._values["text-writing-mode"]=b}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(c,m,y,b){return this._saturation===c&&this._contrast===m&&this._brightnessMin===y&&this._brightnessMax===b||(this._colorAdjustmentMatrix=function(A,I,O,z){A=Zi(A),I=pa(I);const q=j(),X=A/3,Q=1-2*X,se=[Q,X,X,0,X,Q,X,0,X,X,Q,0,0,0,0,1],ae=.5-.5*I,le=z-O;return S(q,[le,0,0,0,0,le,0,0,0,0,le,0,O,O,O,1],[I,0,0,0,0,I,0,0,0,0,I,0,ae,ae,ae,1]),S(q,q,se),q}(c,m,y,b),this._saturation=c,this._contrast=m,this._brightnessMin=y,this._brightnessMax=b),this._colorAdjustmentMatrix}getValueAndResolveTokens(c,m,y,b){const A=this.layout.get(c).evaluate(m,{},y,b),I=this._unevaluatedLayout._values[c];return I.isDataDriven()||z_(I.value)||!A?A:hke(m.properties,A)}getAppearanceValueAndResolveTokens(c,m,y,b,A){const I=c.getProperty(m);if(!I)return;const O=I.evaluate(y,{},b,A),z=c.getUnevaluatedProperties()._values[m];return z.isDataDriven()||z_(z.value)||!O||typeof O!="string"?O:hke(y.properties,O)}createBucket(c){return new ZD(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of Nde().paint.overridableProperties){if(!YD.hasPaintOverride(this.layout,c))continue;const m=this.paint.get(c),y=new fke(m),b=new fS(y,m.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let A=null;A=m.value.kind==="constant"||m.value.kind==="source"?new Y0("source",b):new iy("composite",b,m.value.zoomStops,m.value.interpolationType),this.paint._values[c]=new ly(m.property,A,m.parameters)}}_handleOverridablePaintPropertyUpdate(c,m,y){return!(!this.layout||m.isDataDriven()||y.isDataDriven())&&YD.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,m){const y=c.get("text-field"),b=Nde().paint.properties[m];let A=!1;const I=O=>{for(const z of O)if(b.overrides&&b.overrides.hasOverride(z))return void(A=!0)};if(y.value.kind==="constant"&&y.value.value instanceof Od)I(y.value.value.sections);else if(y.value.kind==="source"){const O=q=>{A||(q instanceof pf&&Dl(q.value)===k_?I(q.value.sections):q instanceof pp?I(q.sections):q.eachChild(O))},z=y.value;z._styleExpression&&O(z._styleExpression.expression)}return A}getProgramIds(){return["symbol"]}getDefaultProgramParams(c,m,y){return{config:new Yg(this,{zoom:m,lut:y}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let gke,xke,yke,vke;var Sde=ea([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function XD(p,c,m,y,b,A,I,O){const z=[p,c,1,m,y,1,b,A,1],q=[I,O,1],X=v([],z),[Q,se,ae]=he(q,q,X);return _(z,z,[Q,0,0,0,se,0,0,0,ae])}function _ke(p,c,m,y,b,A,I,O){const z=function(q,X,Q,se,ae,le,xe,Me){const Ce=XD(0,0,1,0,1,1,0,1),ze=XD(q,X,Q,se,ae,le,xe,Me);return _(ze,ze,v([],Ce))}(p,c,m,y,b,A,I,O);return[z[2]/z[8]/Hs,z[5]/z[8]/Hs]}function QD(p){return[p[0],Math.min(Math.max(p[1],-fe),fe)]}class bke extends Qn{constructor(c,m,y,b){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(b),this.options=m,this._dirty=!1}load(c,m){if(this._loaded=m||!1,this.fire(new Ks("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=D0(this.map._requestManager.transformRequest(this.url,hf.Image),(y,b)=>{this._imageRequest=null,this._loaded=!0,y?this.fire(new dn(y)):b&&(this.image=b instanceof HTMLImageElement?il.getImageData(b):b,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 DT(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 Ks("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 DT||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 A of c)A[1]>y&&(y=A[1]),A[1]fe?this.onNorthPole=!0:b<-fe&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const A=c.map(Ze.fromLngLat);this.tileID=function(I){let O=1/0,z=1/0,q=-1/0,X=-1/0;for(const xe of I)O=Math.min(O,xe.x),z=Math.min(z,xe.y),q=Math.max(q,xe.x),X=Math.max(X,xe.y);const Q=Math.max(q-O,X-z),se=Math.max(0,Math.floor(-Math.log2(Q))),ae=Math.pow(2,se);let le=Math.floor((O+q)/2*ae);return le>1&&(le-=1),new fi(se,le,Math.floor((z+X)/2*ae))}(A),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Ks("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof DT||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(c){for(const Ce in this.tiles){const ze=this.tiles[Ce];ze.state!=="loaded"&&(ze.state="loaded",ze.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=VT(new fi(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(Ce){const ze=Ce[1].x-Ce[0].x,Ve=Ce[1].y-Ce[0].y,Je=Ce[2].x-Ce[1].x,vt=Ce[2].y-Ce[1].y,mt=Ce[3].x-Ce[2].x,St=Ce[3].y-Ce[2].y,It=Ce[0].x-Ce[3].x,Ot=Ce[0].y-Ce[3].y,ns=ze*vt-Je*Ve,qt=Je*St-mt*vt,us=mt*Ot-It*St,gs=It*Ve-ze*Ot;return ns>0&&qt>0&&us>0&&gs>0||ns<0&&qt<0&&us<0&&gs<0}(y))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const b=VT(this.tileID,this.map.transform.projection),[A,I,O,z]=this.coordinates.map(Ce=>{const ze=b.projection.project(Ce[0],Ce[1]);return ike(b,ze)._round()});this.perspectiveTransform=_ke(A.x,A.y,I.x,I.y,O.x,O.y,z.x,z.y);const q=this._boundsArray=new ev;q.emplaceBack(A.x,A.y,0,0),q.emplaceBack(I.x,I.y,Hs,0),q.emplaceBack(z.x,z.y,0,Hs),q.emplaceBack(O.x,O.y,Hs,Hs),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=c.createVertexBuffer(q,Sde.members),this.boundsSegments=ro.simpleSegment(0,0,4,2);const X=[],Q=[QD((se=this.coordinates)[0]),QD(se[1]),QD(se[2]),QD(se[3])];var se;const[ae,le,xe,Me]=function(Ce){let ze=Ce[0][0],Ve=ze,Je=Ce[0][1],vt=Je;for(let mt=1;mtVe&&(Ve=Ce[mt][0]),Ce[mt][1]vt&&(vt=Ce[mt][1]);return[ze,Je,Ve-ze,vt-Je]}(Q);{const Ce=new ev,[ze,Ve,Je,vt]=function(Ns){let Ms=Ns[0].x,ds=Ms,as=Ns[0].y,Ts=as;for(let Ws=1;Wsds&&(ds=Ns[Ws].x),Ns[Ws].yTs&&(Ts=Ns[Ws].y);return[Ms,as,ds-Ms,Ts-as]}(y),mt=Ns=>[(Ns.x-ze)/Je,(Ns.y-Ve)/vt],[St,It,Ot,ns]=y.map(mt),qt=function(Ns,Ms,ds,as,Ts,Ws,Rs,Mr){const or=XD(0,0,1,0,1,1,0,1);return _(or,or,v([],XD(Ns,Ms,ds,as,Ts,Ws,Rs,Mr)))}(St[0],St[1],It[0],It[1],Ot[0],Ot[1],ns[0],ns[1]);this.elevatedGlobePerspectiveTransform=_ke(St[0],St[1],It[0],It[1],Ot[0],Ot[1],ns[0],ns[1]);const us=(Ns,Ms)=>{X.push(Ns.lng);const ds=Math.round((Ns.lng-ae)/xe*Hs),as=Math.round((Ns.lat-le)/Me*Hs),Ts=mt(Ms),Ws=he([],[Ts[0],Ts[1],1],qt),Rs=Math.round(Ws[0]/Ws[2]*Hs),Mr=Math.round(Ws[1]/Ws[2]*Hs);Ce.emplaceBack(ds,as,Rs,Mr)},gs=y[3].x-y[0].x,xs=y[3].y-y[0].y,As=y[2].x-y[1].x,Is=y[2].y-y[1].y;for(let Ns=0;Ns<65;Ns++){const Ms=Ns/64,ds=[y[0].x+Ms*gs,y[0].y+Ms*xs],as=[y[1].x+Ms*As,y[1].y+Ms*Is],Ts=as[0]-ds[0],Ws=as[1]-ds[1];for(let Rs=0;Rs<65;Rs++){const Mr=Rs/64,or={x:ds[0]+Ts*Mr,y:ds[1]+Ws*Mr};us(m.projection.unproject(or.x,or.y),or)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(Ce,Sde.members)}{this.maxLongitudeTriangleSize=0;let Ce=[],ze=new ol;const Ve=(Je,vt,mt)=>{ze.emplaceBack(Je,vt,mt);const St=X[Je],It=X[vt],Ot=X[mt],ns=Math.min(Math.min(St,It),Ot),qt=Math.max(Math.max(St,It),Ot)-ns;qt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=qt),Ce.push(ns+qt/2)};for(let Je=0;Je<64;Je++)for(let vt=0;vt<64;vt++){const mt=65*Je+vt,St=mt+1,It=mt+65,Ot=It+1;Ve(mt,It,St),Ve(St,It,Ot)}[Ce,ze]=function(Je,vt){const mt=Array.from({length:Je.length},(Ot,ns)=>ns);mt.sort((Ot,ns)=>Je[Ot]-Je[ns]);const St=[],It=new ol;for(let Ot=0;Ot{I.segments.push({vertexOffset:0,primitiveOffset:Q,vertexLength:m.segments[0].vertexLength,primitiveLength:se,sortKey:void 0,vaos:{}})},z=.51*this.maxLongitudeTriangleSize;if(Math.abs(y[0]-b)<=z){const Q=Ki(y,0,y.length,b+z);return Q===y.length||O(Q,Fo(y,Q+1,y.length,b+360-z)-Q),I}bHs?b-Hs:b,new cs(Math.trunc(b),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 Tde{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,b){}populate(c,m,y,b){this.tileToMeter=Le(y);const A=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:I,id:O,index:z,sourceLayerIndex:q}of c){const X=O??(I.properties&&I.properties.hasOwnProperty("id")?I.properties.id:void 0),Q=Ut(I,A);if(!this.layers[0]._featureFilter.filter(new Si(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Q,y))continue;const se={id:X,sourceLayerIndex:q,index:z,geometry:A?Q.geometry:At(I,y,b),properties:I.properties,type:I.type,patterns:{}},ae=this.addFeature(se,se.geometry,Q);ae&&m.featureIndex.insert(I,se.geometry,z,q,this.index,this.instancesPerModel[ae].instancedDataArray.length,Hs/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const c=this.layers[0].modelManager,m=this.layers[0].scope;let y=0;for(const b of this.modelUris){const A=c.getModel(b,m);if(!A)continue;const I=this.instancesPerModel[b];if(I){const O=.5*Ae(A.aabb.max,A.aabb.min)*I.maxScale+I.maxXYTranslationDistance,z=Math.min(Hs,Math.max(O/this.tileToMeter,Hs/32));y=Math.max(z,y)}}return y}update(c,m,y,b){for(const A in this.instancesPerModel){const I=this.instancesPerModel[A];for(const O in c)I.idToFeaturesIndex.hasOwnProperty(O)&&(this.evaluate(I.features[I.idToFeaturesIndex[O]],c[O],I,!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 b of y.features){const A=this.layers[0],I=b.feature,O=this.canonical,z=A.paint.get("model-rotation").evaluate(I,{},O),q=A.paint.get("model-scale").evaluate(I,{},O),X=A.paint.get("model-translation").evaluate(I,{},O);Ye(b.rotation,z)&&Ye(b.scale,q)&&Ye(b.translation,X)||(this.evaluate(b,b.featureStates,y,!0),c=!0)}}return c}updateReplacement(c,m,y,b){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const A=m.getReplacementRegionsForTile(c.toUnwrapped(),!0);if(jD(this.activeReplacements,A))return!1;this.activeReplacements=A;let I=!1;for(const O in this.instancesPerModel){const z=this.instancesPerModel[O],q=z.instancedDataArray;for(const X of z.features){const Q=X.instancedDataOffset,se=X.instancedDataCount;for(let ae=0;aeHs;xe=Me?xe-Hs:xe;const Ce=Math.floor(xe),ze=Math.floor(q.float32[le+1]);let Ve=!1;for(const Je of this.activeReplacements)if(!x2e(Je,y,Tke.Model,b)&&!(Je.min.x>Ce||Ce>Je.max.x||Je.min.y>ze||ze>Je.max.y)&&(Ve=w2e(b2e(Ce,ze,c.canonical,Je.footprintTileId.canonical),Je.footprint),Ve))break;q.float32[le]=Ve?xe+Hs:xe,I=I||Ve!==Me}}}return I}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,rJe.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(c){for(const y in this.instancesPerModel){const b=this.instancesPerModel[y];b.instancedDataArray.length!==0&&b.instancedDataBuffer&&b.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 b=this.layers[0],A=b.layout.get("model-id").evaluate(y,{},this.canonical);if(!A)return cr(`modelId is not evaluated for layer ${b.id} and it is not going to get rendered.`),A;(Mde(A,!1)||this.styleDefinedModelURLs[A]!==void 0)&&(this.modelUris.includes(A)||this.modelUris.push(A)),this.instancesPerModel[A]||(this.instancesPerModel[A]=new Eke);const I=this.instancesPerModel[A],O=I.instancedDataArray,z=new Ake(y,O.length);for(const q of m)for(const X of q){if(X.x<0||X.x>=Hs||X.y<0||X.y>=Hs)continue;if(this.lookupDim!==0){const se=(this.lookupDim-1)/Hs,ae=this.lookupDim*(X.y*se|0)+X.x*se|0;if(this.lookup){if(this.lookup[ae]!==0)continue;this.lookup[ae]=1}}this.instanceCount++;const Q=O.length;O.resize(Q+1),I.instancesEvaluatedElevation.push(0),O.float32[16*Q]=X.x,O.float32[16*Q+1]=X.y}return z.instancedDataCount=I.instancedDataArray.length-z.instancedDataOffset,z.instancedDataCount>0&&(c.id&&(I.idToFeaturesIndex[c.id]=I.features.length),I.features.push(z),this.evaluate(z,{},I,!1)),A}getModelUris(){return this.modelUris}evaluate(c,m,y,b){const A=this.layers[0],I=c.feature,O=this.canonical,z=c.rotation=A.paint.get("model-rotation").evaluate(I,m,O),q=c.scale=A.paint.get("model-scale").evaluate(I,m,O),X=c.translation=A.paint.get("model-translation").evaluate(I,m,O),Q=Object.assign({},A.paint.get("model-color").evaluate(I,m,O));Q.a=A.paint.get("model-color-mix-intensity").evaluate(I,m,O);const se=[];this.maxVerticalOffset0?Math.sqrt(ae):0;y.maxScale=Math.max(Math.max(y.maxScale,q[0]),Math.max(q[1],q[2])),y.maxXYTranslationDistance=Math.max(y.maxXYTranslationDistance,le),this.maxScale=Math.max(Math.max(this.maxScale,q[0]),Math.max(q[1],q[2])),lje(se,z,q);const xe=Math.round(100*Q.a)+Q.b/1.05;for(let Me=0;Me10?this.tileToMeter:Le(O,vt)),Ve[ze+4]=X[0],Ve[ze+5]=X[1],Ve[ze+6]=X[2]+Je,Ve[ze+7]=se[0],Ve[ze+8]=se[1],Ve[ze+9]=se[2],Ve[ze+10]=se[4],Ve[ze+11]=se[5],Ve[ze+12]=se[6],Ve[ze+13]=se[8],Ve[ze+14]=se[9],Ve[ze+15]=se[10],y.instancesEvaluatedElevation[Ce]=X[2]}}}let Ike,Pke;xr(Tde,"ModelBucket",{omit:["layers"]}),xr(Eke,"PerModelAttributes"),xr(Ake,"ModelFeature");class cC{constructor(c,m,y){this._demTile=c,this._dem=this._demTile.dem,this._scale=m,this._offset=y}static create(c,m,y){const b=y||c.findDEMTileFor(m);if(!b||!b.dem)return;const A=b.dem,I=b.tileID,O=1<q.fqid),this.stateDependentLayerIds=this.layers.filter(q=>q.isStateDependent()).map(q=>q.id),this.modelTraits|=eC.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,b&&(this.modelTraits|=eC.HasMapboxMeshFeatures),A&&(this.modelTraits|=eC.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=I,this.worldview=z,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const q of m)this.nodesInfo.push(new Rke(q)),Dke(q,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 b=y.node;b.footprint&&m.push({footprint:b.footprint,id:c})}}updateAppearances(c,m,y,b){}update(c){const m=Object.keys(c).length!==0;if(m&&!this.stateDependentLayers.length)return;const y=m?this.stateDependentLayers:this.layers;if(!ka(c,this.states))for(const b of y)this.evaluate(b,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 b=y.node;this.uploaded?this.updatePbrBuffer(b):ede(b,c,!0)}for(const y of m)DD(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 b=c.transform.projectionOptions,A=c.style.getBrightness(),I=this.brightness!==A;if(!this.uploaded||this.dirty||b.name!==this.projection.name||QT(y.paint.get("model-color").value,I)||QT(y.paint.get("model-color-mix-intensity").value,I)||QT(y.paint.get("model-roughness").value,I)||QT(y.paint.get("model-emissive-strength").value,I)||QT(y.paint.get("model-height-based-emissive-strength-multiplier").value,I)){this.projection=b,this.brightness=A;const O=this.getNodesInfo();for(const z of O)z.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(),b=this.id.canonical;for(const A of y){const I=A.feature;A.evaluatedTranslation=m.paint.get("model-translation").evaluate(I,{},b),A.evaluatedScale=m.paint.get("model-scale").evaluate(I,{},b)}}evaluate(c,m){const y=this.getNodesInfo();for(const b of y){if(!b.node.meshes)continue;const A=b.feature,I=m&&m[A.id];if(ka(I,b.state))continue;b.state=structuredClone(I);const O=b.node.meshes&&b.node.meshes[0].featureData,z=b.evaluatedColor[2],q=b.evaluatedRMEA[2],X=this.id.canonical;if(b.hasTranslucentParts=!1,O){for(let Q=0;Q=mt)continue;const Ns=Ade[Is],Ms=Math.abs(Ns);Ms>qt&&(ns=Ns,qt=Ms,us=As,gs=xs)}if(qt>.1){const xs=1-(mt+.5*Math.abs(us*gs))/le;let As=m._dem.get(It,St)+ns*xs;const Is=m._dem.get(It+us,St+gs),Ns=m._dem.get(It-us,St-gs,!0);(As-Is)*(As-Ns)>0&&(As=(Is+Ns)/2),Ade[Ot]=m._dem.set(It,St,As),ob[Ot]=mt}}}}}O&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=il.now())}setFilter(c){this.filter=c?kS(c):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(c=>this.filter.filter(new Si(this.id.overscaledZ,{worldview:this.worldview}),c.feature,this.id.canonical)):this.nodesInfo}destroy(){const c=this.getNodesInfo();for(const m of c)DD(m.node),tde(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 b of this.getNodesInfo()){const A=b.node.footprint;b.hiddenByReplacement=!!A&&!y.find(I=>I.footprint===A)}}getHeightAtTileCoord(c,m){const y=[],b=[0,0,0],A=k([]);for(const I of this.getNodesInfo()){const O=I.node.meshes[0],z=O.transformedAabb;if(cz.max[0]||m>z.max[1])continue;if(I.node.hidden===!0)return{height:1/0,maxHeight:I.feature.properties.height,hidden:!1,verticalScale:I.evaluatedScale[2]};M(A,I.node.globalMatrix),b[0]=c,b[1]=m,st(b,b,A);const q=(b[0]-O.aabb.min[0])/(O.aabb.max[0]-O.aabb.min[0])*nb|0,X=Math.min(63,(b[1]-O.aabb.min[1])/(O.aabb.max[1]-O.aabb.min[1])*nb|0)*nb+Math.min(63,q),Q=O.heightmap[X];if(!(Q<0&&I.node.footprint))return I.hiddenByReplacement?void 0:{height:Q,maxHeight:I.feature.properties.height,hidden:!1,verticalScale:I.evaluatedScale[2]};if(I.node.footprint.grid.query(new cs(c,m),new cs(c,m),y),y.length>0)return{height:void 0,maxHeight:I.feature.properties.height,hidden:I.hiddenByReplacement,verticalScale:I.evaluatedScale[2]}}}}function QT(p,c){return p instanceof Y0&&!p.isLightConstant&&c}function Ret(p,c,m,y,b,A,I,O){let z=(61440&c|(61440&c)>>4)>>8,q=(3840&c|(3840&c)>>4)>>4,X=240&c|(240&c)>>4;m[3]>0&&(z=Jr(z,255*m[0],m[3]),q=Jr(q,255*m[1],m[3]),X=Jr(X,255*m[2],m[3]));const Q=z<<8|q,se=X<<8|Math.floor(255*y[3]),ae=function(mt){const St=_e(mt,0,2);return Math.min(Math.round(.5*St*255),255)}(y[2])<<8|15*y[0]<<4|15*y[1],le=_e(b[0],0,1),xe=_e(b[1],0,1),Me=_e(b[2],0,1),Ce=_e(b[3],0,1);let ze,Ve,Je,vt;if(le!==xe&&I!==A&&xe!==le){const mt=I-A;Ve=1/(mt*(xe-le)),Je=-(A+mt*le)/(mt*(xe-le));const St=_e(b[4],-1,1);vt=Math.pow(10,St),ze=255*Me<<8|255*Ce}else ze=65535,Ve=0,Je=1,vt=1;if(p.emplaceBack(Q,se,ae,ze,Ve,Je,vt),O){const mt=O.length;O.clear();for(let St=0;St>16&65535,X=A?z>>16&65535:65535&z,Q=(15&X)<8?15&X:0,se=p.evaluatedRMEA[Q],ae=p.evaluatedColor[Q],le=p.emissionHeightBasedParams[Q];let xe;if(O&&Q===2&&y.lights&&(xe=new DS,xe.resize(10*y.lights.length)),Ret(I.featureArray,q,ae,se,le,I.aabb.min[2],I.aabb.max[2],xe),xe&&O){O=!1;const Me=y.meshes[y.lightMeshIndex];Me.featureArray=xe,Me.featureArray._trim()}}I.featureArray._trim(),b++}}xr(eO,"Tiled3dModelBucket",{omit:["layers"]}),xr(Rke,"Tiled3dModelFeature");const zet=["id","tile","layer","source","sourceLayer","state"];class lb{constructor(c,m,y,b,A){this.type="Feature",this._vectorTileFeature=c,this._z=m,this._x=y,this._y=b,this.properties=c?c.properties:{},this.id=A}clone(){const c=new lb(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 zet)this[m]!==void 0&&(c[m]=this[m]);return c}}class cb extends Qn{constructor(c,m,y,b){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],b=this._modelsInfo.get(m);if(b){const A=b.model;A.position=y.position!=null?new x(y.position[0],y.position[1]):new x(0,0),A.orientation=y.orientation!=null?y.orientation:[0,0,0],b.modelSpec=y,cb.applyModelSpecification(A,y),A.computeBoundsAndApplyParent(),this.models.push(A)}else{const A=nje(this.map._requestManager.transformRequest(y.uri,hf.Model).url).then(I=>{if(!I)return;const O=rde(I),z=new cje(m,y.uri,y.position,y.orientation,O);cb.applyModelSpecification(z,y),z.computeBoundsAndApplyParent(),this.models.push(z),this._modelsInfo.set(m,{modelSpec:y,model:z})}).catch(I=>{this.fire(new dn(new Error(`Could not load model ${m} from ${y.uri}: ${I.message}`)))});c.push(A)}}Promise.allSettled(c).then(()=>{this._loaded=!0,this.fire(new Ks("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new dn(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(c,m){m.nodeOverrides&&cb.convertNodeOverrides(c,m.nodeOverrides),m.materialOverrides&&cb.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,b])=>{const A={orientation:[0,0,0]};if(b.hasOwnProperty("orientation")){const I=b.orientation;I&&(A.orientation=I)}c.nodeOverrides.set(y,A)})}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,b])=>{const A={color:new Da(1,1,1),colorMix:0,emissionStrength:0,opacity:1},I=b["model-color"];I!==void 0&&(A.color.r=I[0],A.color.g=I[1],A.color.b=I[2]);const O=b["model-color-mix-intensity"];O!==void 0&&(A.colorMix=O);const z=b["model-emissive-strength"];z!==void 0&&(A.emissionStrength=z);const q=b["model-opacity"];q!==void 0&&(A.opacity=q),c.materialOverrides.set(y,A)})}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=Nm(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 b=c[y];if(this._modelsInfo.has(y)){const A=this._modelsInfo.get(y);A&&A.modelSpec.uri===b.uri&&m.set(y,A)}}this._modelsInfo=m,this._options.models=c,this._loaded=!1,this.load()}}function Ede(p,c,m,y){const b=1<Je.polygon).flat());const Me=ae?O:null,[Ce,ze]=W2e(A,y,Q,X,q,I,Me,se,le,A.center.lat,p.tileID.canonical),Ve=p.queryGeometry;return H2e(Ce,ze,Ve.isPointQuery()?Ve.screenBounds:Ve.screenGeometry)}},building:class extends Bd{constructor(p,c,m,y){super(p,{layout:gje||(gje=new xo({visibility:new $s(Vt.layout_building.visibility),"building-facade":new Xs(Vt.layout_building["building-facade"]),"building-facade-floors":new Xs(Vt.layout_building["building-facade-floors"]),"building-facade-unit-width":new Xs(Vt.layout_building["building-facade-unit-width"]),"building-facade-window":new Xs(Vt.layout_building["building-facade-window"]),"building-roof-shape":new Xs(Vt.layout_building["building-roof-shape"]),"building-height":new Xs(Vt.layout_building["building-height"]),"building-base":new Xs(Vt.layout_building["building-base"]),"building-flood-light-wall-radius":new Xs(Vt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Xs(Vt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Xs(Vt.layout_building["building-flip-roof-orientation"])})),paint:xje||(xje=new xo({"building-opacity":new $s(Vt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new $s(Vt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new $s(Vt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new $s(Vt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new $s(Vt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new $s(Vt.paint_building["building-vertical-scale"]),"building-cast-shadows":new $s(Vt.paint_building["building-cast-shadows"]),"building-color":new Xs(Vt.paint_building["building-color"]),"building-emissive-strength":new Xs(Vt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new $s(Vt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new $s(Vt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new $s(Vt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new $s(Vt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new $s(Vt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Xs({type:"string",default:"default","property-type":"data-driven"})}))},c,m,y),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(p){return new fje(p)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(p){return!0}queryRadius(p){return 0}queryIntersectsFeature(p,c,m,y,b,A,I,O,z){let q=this.layout.get("building-height").evaluate(c,m);const X=this.layout.get("building-base").evaluate(c,m),Q=p.tile.getBucket(this).getFootprint(c);if(Q){if(Q.hiddenFlags!==0)return!1;q=Q.height}const[se,ae]=W2e(A,y,X,q,new cs(0,0),I,null,[0,0],1,A.center.lat,p.tileID.canonical),le=p.queryGeometry;return H2e(se,ae,le.isPointQuery()?le.screenBounds:le.screenGeometry)}},line:class extends Bd{constructor(p,c,m,y){const b=Cje();super(p,b,c,m,y),b.layout&&(this.layout=new cy(b.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(p){if(p==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof P_,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(p,c){super.recalculate(p,c),this.paint._values["line-floorwidth"]=(()=>{if(RT)return RT;const m=Cje();return RT=new PJe(m.paint.properties["line-width"].specification),RT.useIntegerZoom=!0,RT})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,p)}createBucket(p){return new ide(p)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(p,c,m){const y=Nje(this);return{config:new Yg(this,{zoom:c,lut:m}),defines:y,overrideFog:!1}}queryRadius(p){const c=p,m=Mje(sd("line-width",this,c),sd("line-gap-width",this,c)),y=sd("line-offset",this,c);return m/2+Math.abs(y)+gc(this.paint.get("line-translate"))}queryIntersectsFeature(p,c,m,y,b,A){if(p.queryGeometry.isAboveHorizon)return!1;const I=nh(p.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),A.angle,p.pixelToTileUnitsFactor),O=p.pixelToTileUnitsFactor/2*Mje(this.paint.get("line-width").evaluate(c,m),this.paint.get("line-gap-width").evaluate(c,m)),z=this.paint.get("line-offset").evaluate(c,m);return z&&(y=function(q,X){const Q=[],se=new cs(0,0);for(let ae=0;ae=3){for(let le=0;le>16&255)/255,(p>>8&255)/255,(255&p)/255,1)}function ett(p,c,m){p===1?(c.rgb_color=nO(m.readVarint()),c.paint="rgb_color"):p===2?(c.linear_gradient_idx=m.readVarint(),c.paint="linear_gradient_idx"):p===3?(c.radial_gradient_idx=m.readVarint(),c.paint="radial_gradient_idx"):p===5?m.readPackedFloat(c.dasharray):p===6?c.dashoffset=m.readFloat():p===7?c.miterlimit=m.readFloat():p===8?c.opacity=m.readVarint():p===9?c.width=m.readFloat():p===10?c.linecap=m.readVarint():p===11&&(c.linejoin=m.readVarint())}function ttt(p,c,m){p===1?c.transform=rO(m,m.readVarint()+m.pos):p===2?c.spread_method=m.readVarint():p===3?c.stops.push($ke(m,m.readVarint()+m.pos)):p===4?c.x1=m.readFloat():p===5?c.y1=m.readFloat():p===6?c.x2=m.readFloat():p===7&&(c.y2=m.readFloat())}function $ke(p,c){return p.readFields(stt,{offset:0,opacity:255,rgb_color:Ide},c)}function stt(p,c,m){p===1?c.offset=m.readFloat():p===2?c.opacity=m.readVarint():p===3&&(c.rgb_color=nO(m.readVarint()))}function rtt(p,c,m){p===1?c.transform=rO(m,m.readVarint()+m.pos):p===2?c.spread_method=m.readVarint():p===3?c.stops.push($ke(m,m.readVarint()+m.pos)):p===4?c.cx=m.readFloat():p===5?c.cy=m.readFloat():p===6?c.r=m.readFloat():p===7?c.fx=m.readFloat():p===8?c.fy=m.readFloat():p===9&&(c.fr=m.readFloat())}function ntt(p,c,m){p===1?c.transform=rO(m,m.readVarint()+m.pos):p===2?c.clip_path_idx=m.readVarint():p===3&&c.children.push(sO(m,m.readVarint()+m.pos))}function att(p,c,m){p===1?c.left=c.top=m.readFloat():p===2?c.width=c.height=m.readFloat():p===3?c.top=m.readFloat():p===4?c.height=m.readFloat():p===5?c.mask_type=m.readVarint():p===6?c.mask_idx=m.readVarint():p===7&&c.children.push(sO(m,m.readVarint()+m.pos))}class itt{static calculate(c={},m=[]){const y=new Map,b=new Map;if(Object.keys(c).length===0)return y;m.forEach(A=>{b.set(A.name,A.rgb_color||new Da(0,0,0))});for(const[A,I]of Object.entries(c))b.has(A)?y.set(b.get(A).toString(),I):console.warn(`Ignoring unknown image variable "${A}"`);return y}}function dC(p,c=255,m){const y=c/255,b=p.toString(),A=m.has(b)?m.get(b).clone():p.clone();return A.a*=y,A.toString()}function eA(p,c){if(!Lh()){const m=document.createElement("canvas");return m.width=p,m.height=c,m}return new OffscreenCanvas(p,c)}let Dde,tA=null;function Ode(p,c,m,y,b){for(const A of y.children)Uke(p,c,m,A,b)}function Uke(p,c,m,y,b){y.group?(p.save(),function(A,I,O,z,q){const X=z.mask_idx!=null?O.masks[z.mask_idx]:null,Q=z.clip_path_idx!=null?O.clip_paths[z.clip_path_idx]:null;if(z.transform&&(I=uC(z.transform).preMultiplySelf(I)),!function(le,xe,Me){return le.opacity!==255||xe||Me}(z,Q!=null,X!=null))return void Ode(A,I,O,z,q);const se=eA(A.canvas.width,A.canvas.height),ae=se.getContext("2d");Ode(ae,I,O,z,q),Q&&Zke(ae,I,O,Q),X&&Yke(ae,I,O,X,q),A.globalAlpha=z.opacity/255,A.drawImage(se,0,0)}(p,c,m,y.group,b),p.restore()):y.path&&(p.save(),function(A,I,O,z,q){A.setTransform(I),z.paint_order===Uet.PAINT_ORDER_FILL_AND_STROKE?(qke(A,O,z,q),Hke(A,O,z,q)):(Hke(A,O,z,q),qke(A,O,z,q))}(p,c,m,y.path,b),p.restore())}function qke(p,c,m,y){const b=m.fill;if(!b)return;const A=b.opacity/255;switch(p.save(),p.beginPath(),Xke(m,p),b.paint){case"rgb_color":p.fillStyle=dC(b.rgb_color,b.opacity,y);break;case"linear_gradient_idx":{const I=c.linear_gradients[b.linear_gradient_idx];I.transform&&p.setTransform(uC(I.transform).preMultiplySelf(p.getTransform())),p.fillStyle=Wke(p,I,A,y);break}case"radial_gradient_idx":{const I=c.radial_gradients[b.radial_gradient_idx];I.transform&&p.setTransform(uC(I.transform).preMultiplySelf(p.getTransform())),p.fillStyle=Gke(p,I,A,y)}}p.fill(Vke(m)),p.restore()}function Vke(p){return p.rule===Pde.PATH_RULE_NON_ZERO?"nonzero":p.rule===Pde.PATH_RULE_EVEN_ODD?"evenodd":void 0}function Hke(p,c,m,y){const b=m.stroke;if(!b)return;const A=Qke(m);p.lineWidth=b.width,p.miterLimit=b.miterlimit,p.setLineDash(b.dasharray),p.lineDashOffset=b.dashoffset;const I=b.opacity/255;switch(b.paint){case"rgb_color":p.strokeStyle=dC(b.rgb_color,b.opacity,y);break;case"linear_gradient_idx":p.strokeStyle=Wke(p,c.linear_gradients[b.linear_gradient_idx],I,y,!0);break;case"radial_gradient_idx":p.strokeStyle=Gke(p,c.radial_gradients[b.radial_gradient_idx],I,y,!0)}switch(b.linejoin){case tO.LINE_JOIN_MITER_CLIP:case tO.LINE_JOIN_MITER:p.lineJoin="miter";break;case tO.LINE_JOIN_ROUND:p.lineJoin="round";break;case tO.LINE_JOIN_BEVEL:p.lineJoin="bevel"}switch(b.linecap){case Lde.LINE_CAP_BUTT:p.lineCap="butt";break;case Lde.LINE_CAP_ROUND:p.lineCap="round";break;case Lde.LINE_CAP_SQUARE:p.lineCap="square"}p.stroke(A)}function Wke(p,c,m,y,b=!1){if(c.stops.length===1){const se=c.stops[0];return dC(se.rgb_color,se.opacity*m,y)}const{x1:A,y1:I,x2:O,y2:z}=c;let q=new DOMPoint(A,I),X=new DOMPoint(O,z);if(b){const se=uC(c.transform);q=se.transformPoint(q),X=se.transformPoint(X)}const Q=p.createLinearGradient(q.x,q.y,X.x,X.y);for(const se of c.stops)Q.addColorStop(se.offset,dC(se.rgb_color,se.opacity*m,y));return Q}function Gke(p,c,m,y,b=!1){if(c.stops.length===1){const Ce=c.stops[0];return dC(Ce.rgb_color,Ce.opacity*m,y)}const A=uC(c.transform),{fx:I,fy:O,fr:z,cx:q,cy:X,r:Q}=c;let se=new DOMPoint(I,O),ae=new DOMPoint(q,X),le=z,xe=Q;if(b){se=A.transformPoint(se),ae=A.transformPoint(ae);const Ce=(A.a+A.d)/2;le=z*Ce,xe=c.r*Ce}const Me=p.createRadialGradient(se.x,se.y,le,ae.x,ae.y,xe);for(const Ce of c.stops)Me.addColorStop(Ce.offset,dC(Ce.rgb_color,Ce.opacity*m,y));return Me}function Kke(p,c,m,y){const b=y.transform?uC(y.transform).preMultiplySelf(c):c,A=eA(p.canvas.width,p.canvas.height),I=A.getContext("2d");for(const z of y.children)if(z.group)Kke(I,b,m,z.group);else if(z.path){const q=z.path,X=new Path2D;X.addPath(Qke(q),b),I.fill(X,Vke(q))}const O=y.clip_path_idx!=null?m.clip_paths[y.clip_path_idx]:null;O&&Zke(I,b,m,O),p.globalCompositeOperation="source-over",p.drawImage(A,0,0)}function Zke(p,c,m,y){const b=eA(p.canvas.width,p.canvas.height);Kke(b.getContext("2d"),c,m,y),p.globalCompositeOperation="destination-in",p.drawImage(b,0,0)}function Yke(p,c,m,y,b){if(y.children.length===0)return;const A=y.mask_idx!=null?m.masks[y.mask_idx]:null;A&&Yke(p,c,m,A,b);const I=p.canvas.width,O=p.canvas.height,z=eA(I,O),q=z.getContext("2d"),X=y.width,Q=y.height,se=y.left,ae=y.top,le=new Path2D,xe=new Path2D;xe.rect(se,ae,X,Q),le.addPath(xe,c),q.clip(le);for(const ze of y.children)Uke(q,c,m,ze,b);const Me=q.getImageData(0,0,I,O),Ce=Me.data;if(y.mask_type===Fke.MASK_TYPE_LUMINANCE)for(let ze=0;zec[I])return null}else{const O=1/y[I];let z=(p[I]-m[I])*O,q=(c[I]-m[I])*O;if(z>q){const X=z;z=q,q=X}if(z>b&&(b=z),qA)return null}return b}function tNe(p,c,m,y,b,A,I,O,z,q,X){const Q=y-p,se=b-c,ae=A-m,le=I-p,xe=O-c,Me=z-m,Ce=X[1]*Me-X[2]*xe,ze=X[2]*le-X[0]*Me,Ve=X[0]*xe-X[1]*le,Je=Q*Ce+se*ze+ae*Ve;if(Math.abs(Je)<1e-15)return null;const vt=1/Je,mt=q[0]-p,St=q[1]-c,It=q[2]-m,Ot=(mt*Ce+St*ze+It*Ve)*vt;if(Ot<0||Ot>1)return null;const ns=St*ae-It*se,qt=It*Q-mt*ae,us=mt*se-St*Q,gs=(X[0]*ns+X[1]*qt+X[2]*us)*vt;return gs<0||Ot+gs>1?null:(le*ns+xe*qt+Me*us)*vt}function sNe(p,c,m){return(p-c)/(m-c)}function rNe(p,c,m,y,b,A,I,O,z){const q=1<{const ze=Me?1:0,Ve=(ae+1)*xe-ze,Je=le*xe,vt=(le+1)*xe-ze;Ce[0]=ae*xe,Ce[1]=Je,Ce[2]=Ve,Ce[3]=vt};let Q=new Jke(z);const se=[];for(let ae=0;ae=1;z/=2){const ae=O[O.length-1];Q=new Jke(z);for(let le=0;le0;){const{idx:le,t:xe,nodex:Me,nodey:Ce,depth:ze}=ae.pop();if(this.leaves[le]){rNe(Me,Ce,ze,c,m,y,b,Q,se);const Je=1<=Is[2])return xe}continue}let Ve=0;for(let Je=0;Je=q[X[It]]&&(X.splice(It,0,Je),St=!0);St||(X[Ve]=Je),Ve++}}for(let Je=0;Je=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],b=iO.getUnpackVector(m);let A=Math.floor((c+b[3])/b[2]);return y[2]=A%256,A=Math.floor(A/256),y[1]=A%256,A=Math.floor(A/256),y[0]=A,y}getPixels(){return new Jwe({width:this.stride,height:this.stride},this.pixels)}backfillBorder(c,m,y){if(this.dim!==c.dim)throw new Error("dem dimension mismatch");let b=m*this.dim,A=m*this.dim+this.dim,I=y*this.dim,O=y*this.dim+this.dim;switch(m){case-1:b=A-1;break;case 1:A=b+1}switch(y){case-1:I=O-1;break;case 1:O=I+1}const z=-m*this.dim,q=-y*this.dim;for(let X=I;X=1;y--){const b=y===1?1:0,A=y===2?1:0;for(let I=0;I>>1^-(1&p[c]);return p}function _tt(p,c){switch(c){case"uint32":return p;case"uint16":for(let m=0;m>4|(61440&y)>>8|(240&b)<<4|61440&b,p[m+1]=15&y|(3840&y)>>4|(15&b)<<8|(3840&b)<<4}return p;case"uint8":for(let m=0;m>6|(192&b)>>4|(192&A)>>2|192&I,p[m+1]=(48&y)>>4|(48&b)>>2|48&A|(48&I)<<2,p[m+2]=(12&y)>>2|12&b|(12&A)<<2|(12&I)<<4,p[m+3]=3&y|(3&b)<<2|(3&A)<<4|(3&I)<<6}return p;default:throw new Error(`Invalid pixel format, "${c}"`)}}xr(iO,"DEMData"),xr(nNe,"DemMinMaxQuadTree",{omit:["dem"]});var Tm=Uint8Array,sA=Uint16Array,btt=Int32Array,iNe=new Tm([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]),oNe=new Tm([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]),wtt=new Tm([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lNe=function(p,c){for(var m=new sA(31),y=0;y<31;++y)m[y]=c+=1<>1|(21845&Nl)<<1;uNe[Nl]=((65280&(hC=(61680&(hC=(52428&hC)>>2|(13107&hC)<<2))>>4|(3855&hC)<<4))>>8|(255&hC)<<8)>>1}var rA=function(p,c,m){for(var y=p.length,b=0,A=new sA(c);b>z]=q;return I},nA=new Tm(288);for(Nl=0;Nl<144;++Nl)nA[Nl]=8;for(Nl=144;Nl<256;++Nl)nA[Nl]=9;for(Nl=256;Nl<280;++Nl)nA[Nl]=7;for(Nl=280;Nl<288;++Nl)nA[Nl]=8;var hNe=new Tm(32);for(Nl=0;Nl<32;++Nl)hNe[Nl]=5;var Ntt=rA(nA,9),Stt=rA(hNe,5),Fde=function(p){for(var c=p[0],m=1;mc&&(c=p[m]);return c},If=function(p,c,m){var y=c/8|0;return(p[y]|p[y+1]<<8)>>(7&c)&m},zde=function(p,c){var m=c/8|0;return(p[m]|p[m+1]<<8|p[m+2]<<16)>>(7&c)},Ctt=["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"],Pf=function(p,c,m){var y=new Error(c||Ctt[p]);if(y.code=p,Error.captureStackTrace&&Error.captureStackTrace(y,Pf),!m)throw y;return y},Mtt=new Tm(0),Ttt=typeof TextDecoder<"u"&&new TextDecoder;try{Ttt.decode(Mtt,{stream:!0})}catch{}const Att={gzip_data:"gzip"};class jp extends Error{constructor(c){super(c),this.name="MRTError"}}const Ett={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},mNe={uint32:1,uint16:2,uint8:4},Itt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Bde;class oO{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 jp(`Layer '${c}' not found`);return m}getHeaderLength(c){const m=new Uint8Array(c),y=new DataView(c);if(m[0]!==13)throw new jp("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 b=new Bde(m.subarray(0,y)).readFields(dtt,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==b.x||this.y!==b.y||this.z!==b.z))throw new jp(`Invalid attempt to parse header ${b.z}/${b.x}/${b.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=b.x,this.y=b.y,this.z=b.z;for(const A of b.layers)this.layers[A.name]=new pNe(A,{cacheSize:this._cacheSize});return this}createDecodingTask(c){const m=[],y=this.getLayer(c.layerName);for(let b of c.blockIndices){const A=y.dataIndex[b],I=A.firstByte-c.firstByte,O=A.lastByte-c.firstByte;if(y._blocksInProgress.has(b))continue;const z={layerName:y.name,firstByte:I,lastByte:O,pixelFormat:y.pixelFormat,blockIndex:b,blockShape:[A.bands.length].concat(y.bandShape),buffer:y.buffer,codec:A.codec.codec,filters:A.filters.map(q=>q.filter)};y._blocksInProgress.add(b),m.push(z)}return new fNe(m,()=>{m.forEach(b=>y._blocksInProgress.delete(b.blockIndex))},(b,A)=>{if(m.forEach(I=>y._blocksInProgress.delete(I.blockIndex)),b)throw b;A.forEach(I=>{this.getLayer(I.layerName).processDecodedData(I)})})}}class pNe{constructor({version:c,name:m,units:y,tileSize:b,pixelFormat:A,buffer:I,dataIndex:O},z){if(this.version=c,this.version!==1)throw new jp(`Cannot parse raster layer encoded with MRT version ${c}`);this.name=m,this.units=y,this.tileSize=b,this.buffer=I,this.pixelFormat=Ett[A],this.dataIndex=O,this.bandShape=[b+2*I,b+2*I,mNe[this.pixelFormat]],this._decodedBlocks=new aO(z?z.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return mNe[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,b]of this.dataIndex.entries()){for(const[A,I]of b.bands.entries())if(I===c)return{bandIndex:m+A,blockIndex:y,blockBandIndex:A};m+=b.bands.length}break;case"number":for(const[y,b]of this.dataIndex.entries()){if(c>=m&&cthis.cacheSize)throw new jp(`Number of blocks to decode (${A.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:y,blockIndices:b}}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 jp(`Band not found: ${JSON.stringify(c)}`);const b=this._decodedBlocks.get(m.toString());if(!b)throw new jp(`Data for band ${JSON.stringify(c)} of layer "${this.name}" not decoded.`);const A=this.dataIndex[m],I=this.bandShape.reduce((q,X)=>q*X,1),O=y*I,z=b.subarray(O,O+I);return{data:z,bytes:new Uint8Array(z.buffer).subarray(z.byteOffset,z.byteOffset+z.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:A.offset,scale:A.scale}}}oO.setPbf=function(p){Bde=p};class fNe{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)}}oO.performDecoding=function(p,c){const m=new Uint8Array(p);return Promise.all(c.tasks.map(y=>{const{layerName:b,firstByte:A,lastByte:I,pixelFormat:O,blockShape:z,blockIndex:q,filters:X,codec:Q}=y,se=m.subarray(A,I+1),ae=new Uint32Array(z[0]*z[1]*z[2]);let le;if(Q!=="gzip_data")throw new jp(`Unhandled codec: ${Q}`);return le=function(xe,Me){if(!globalThis.DecompressionStream&&Me==="gzip_data")return Promise.resolve(((Je=function(St){St[0]==31&&St[1]==139&&St[2]==8||Pf(6,"invalid gzip data");var It=St[3],Ot=10;4&It&&(Ot+=2+(St[10]|St[11]<<8));for(var ns=(It>>3&1)+(It>>4&1);ns>0;ns-=!St[Ot++]);return Ot+(2&It)}(Ve=xe))+8>Ve.length&&Pf(6,"invalid gzip data"),function(St,It,Ot,ns){var qt=St.length;if(!qt||It.f&&!It.l)return Ot||new Tm(0);var us=!Ot,gs=us||It.i!=2,xs=It.i;us&&(Ot=new Tm(3*qt));var As,Is,Ns=function(ui){var Ra=Ot.length;if(ui>Ra){var Ua=new Tm(Math.max(2*Ra,ui));Ua.set(Ot),Ot=Ua}},Ms=It.f||0,ds=It.p||0,as=It.b||0,Ts=It.l,Ws=It.d,Rs=It.m,Mr=It.n,or=8*qt;do{if(!Ts){Ms=If(St,ds,1);var mr=If(St,ds+1,3);if(ds+=3,!mr){var vr=St[(hs=4+((ds+7)/8|0))-4]|St[hs-3]<<8,Dn=hs+vr;if(Dn>qt){xs&&Pf(0);break}gs&&Ns(as+vr),Ot.set(St.subarray(hs,Dn),as),It.b=as+=vr,It.p=ds=8*Dn,It.f=Ms;continue}if(mr==1)Ts=Ntt,Ws=Stt,Rs=9,Mr=5;else if(mr==2){var zs=If(St,ds,31)+257,_r=If(St,ds+10,15)+4,an=zs+If(St,ds+5,31)+1;ds+=14;for(var oa=new Tm(an),ha=new Tm(19),Nn=0;Nn<_r;++Nn)ha[wtt[Nn]]=If(St,ds+3*Nn,7);ds+=3*_r;var di=Fde(ha),pt=(1<>4)<16)oa[Nn++]=hs;else{var sr=0,rr=0;for(hs==16?(rr=3+If(St,ds,3),ds+=2,sr=oa[Nn-1]):hs==17?(rr=3+If(St,ds,7),ds+=3):hs==18&&(rr=11+If(St,ds,127),ds+=7);rr--;)oa[Nn++]=sr}}var Ar=oa.subarray(0,zs),Lr=oa.subarray(zs);Rs=Fde(Ar),Mr=Fde(Lr),Ts=rA(Ar,Rs),Ws=rA(Lr,Mr)}else Pf(1);if(ds>or){xs&&Pf(0);break}}gs&&Ns(as+131072);for(var wn=(1<>4;if((ds+=15&sr)>or){xs&&Pf(0);break}if(sr||Pf(2),ta<256)Ot[as++]=ta;else{if(ta==256){Ln=ds,Ts=null;break}var Gr=ta-254;ta>264&&(Gr=If(St,ds,(1<<(Ma=iNe[Nn=ta-257]))-1)+dNe[Nn],ds+=Ma);var rn=Ws[zde(St,ds)&An],wa=rn>>4;if(rn||Pf(3),ds+=15&rn,Lr=ktt[wa],wa>3){var Ma=oNe[wa];Lr+=zde(St,ds)&(1<or){xs&&Pf(0);break}gs&&Ns(as+131072);var Ta=as+Gr;if(asAs.length)&&(Is=As.length),new Tm(As.subarray(0,Is))):Ot.subarray(0,as)}(Ve.subarray(Je,-8),{i:2},new Tm(((Ce=Ve)[(ze=Ce.length)-4]|Ce[ze-3]<<8|Ce[ze-2]<<16|Ce[ze-1]<<24)>>>0))));var Ce,ze,Ve,Je;const vt=Att[Me];if(!vt)throw new Error(`Unhandled codec: ${Me}`);const mt=new globalThis.DecompressionStream(vt);return new Response(new Blob([xe]).stream().pipeThrough(mt)).arrayBuffer().then(St=>new Uint8Array(St))}(se,Q).then(xe=>(function(Me,Ce){Me.readFields(gtt,Ce)}(new Bde(xe),ae),new Itt[O](ae.buffer))),le.then(xe=>{for(let Me=X.length-1;Me>=0;Me--)switch(X[Me]){case"delta_filter":ytt(xe,z);break;case"zigzag_filter":vtt(xe);break;case"bitshuffle_filter":_tt(xe,O);break;default:throw new jp(`Unhandled filter "${X[Me]}"`)}return{layerName:b,blockIndex:q,data:xe}}).catch(xe=>{throw xe})}))},xr(fNe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),xr(oO,"MapboxRasterTile"),xr(pNe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class gNe{constructor(c){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&se[3]>=0&&q.insert(z,se[0],se[1],se[2],se[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yt(new RD(this.rawTileData)).layers,this.sourceLayerCoder=new gNe(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:b,tileTransform:A,pixelPosMatrix:I,availableImages:O,worldview:z}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const q=m.queryRadius?m.queryRadius:0,X=y.bufferedTilespaceBounds,Q=this.grid.query(X.min.x,X.min.y,X.max.x,X.max.y,(xe,Me,Ce,ze)=>$d(y.bufferedTilespaceGeometry,xe-q,Me-q,Ce+q,ze+q));Q.sort(Ptt);let se=null;b.elevation&&Q.length>0&&(se=cC.create(b.elevation,this.tileID));const ae={};let le;for(let xe=0;xe(ze||(ze=At(Ve,this.tileID.canonical,A)),Je.queryIntersectsFeature(y,Ve,vt,ze,this.z,b,I,se,mt)))}return ae}loadMatchingFeature(c,m,y,b,A,I){const{featureIndex:O,bucketIndex:z,sourceLayerIndex:q,layoutVertexArrayOffset:X}=m,Q=this.bucketLayerIDs[z],se=y.layers,ae=Object.keys(se);if(ae.length&&!ur(ae,Q))return;const le=y.sourceCache,xe=this.sourceLayerCoder.decode(q),Me=this.vtLayers[xe].feature(O),Ce=this.getId(Me,xe);for(let ze=0;ze`${O.key}: ${O.message}`).join(", ");return void cr(`Failed to create expression for promoteId: ${I}`)}this.promoteIdExpression=A.value}y=this.promoteIdExpression.evaluate({zoom:0},c)}else y=c.properties[b];typeof y=="boolean"&&(y=Number(y))}return y}}function yNe(p,c,m,y,b){return Jt(p,(A,I)=>{const O=c instanceof cy?c.get(I):null;return O&&O.evaluate?O.evaluate(m,y,void 0,b):O})}function Ptt(p,c){return c-p}xr(xNe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const vNe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class $de{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 b=y>>4;if(b!==1)throw new Error(`Got v${b} data when expected v1.`);const A=vNe[15&y];if(!A)throw new Error("Unrecognized array type.");const[I]=new Uint16Array(c,2,1),[O]=new Uint32Array(c,4,1);return new $de(O,I,A,c)}constructor(c,m=64,y=Float64Array,b){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 A=vNe.indexOf(this.ArrayType),I=2*c*this.ArrayType.BYTES_PER_ELEMENT,O=c*this.IndexArrayType.BYTES_PER_ELEMENT,z=(8-O%8)%8;if(A<0)throw new Error(`Unexpected typed array class: ${y}.`);b&&b instanceof ArrayBuffer?(this.data=b,this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+O+z,2*c),this._pos=2*c,this._finished=!0):(this.data=new ArrayBuffer(8+I+O+z),this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+O+z,2*c),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+A]),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 Ude(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(c,m,y,b){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:A,coords:I,nodeSize:O}=this,z=[0,A.length-1,0],q=[];for(;z.length;){const X=z.pop()||0,Q=z.pop()||0,se=z.pop()||0;if(Q-se<=O){for(let Me=se;Me<=Q;Me++){const Ce=I[2*Me],ze=I[2*Me+1];Ce>=c&&Ce<=y&&ze>=m&&ze<=b&&q.push(A[Me])}continue}const ae=se+Q>>1,le=I[2*ae],xe=I[2*ae+1];le>=c&&le<=y&&xe>=m&&xe<=b&&q.push(A[ae]),(X===0?c<=le:m<=xe)&&(z.push(se),z.push(ae-1),z.push(1-X)),(X===0?y>=le:b>=xe)&&(z.push(ae+1),z.push(Q),z.push(1-X))}return q}within(c,m,y){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:b,coords:A,nodeSize:I}=this,O=[0,b.length-1,0],z=[],q=y*y;for(;O.length;){const X=O.pop()||0,Q=O.pop()||0,se=O.pop()||0;if(Q-se<=I){for(let Me=se;Me<=Q;Me++)bNe(A[2*Me],A[2*Me+1],c,m)<=q&&z.push(b[Me]);continue}const ae=se+Q>>1,le=A[2*ae],xe=A[2*ae+1];bNe(le,xe,c,m)<=q&&z.push(b[ae]),(X===0?c-y<=le:m-y<=xe)&&(O.push(se),O.push(ae-1),O.push(1-X)),(X===0?c+y>=le:m+y>=xe)&&(O.push(ae+1),O.push(Q),O.push(1-X))}return z}}function Ude(p,c,m,y,b,A){if(b-y<=m)return;const I=y+b>>1;_Ne(p,c,I,y,b,A),Ude(p,c,m,y,I-1,1-A),Ude(p,c,m,I+1,b,1-A)}function _Ne(p,c,m,y,b,A){for(;b>y;){if(b-y>600){const q=b-y+1,X=m-y+1,Q=Math.log(q),se=.5*Math.exp(2*Q/3),ae=.5*Math.sqrt(Q*se*(q-se)/q)*(X-q/2<0?-1:1);_Ne(p,c,m,Math.max(y,Math.floor(m-X*se/q+ae)),Math.min(b,Math.floor(m+(q-X)*se/q+ae)),A)}const I=c[2*m+A];let O=y,z=b;for(aA(p,c,y,m),c[2*b+A]>I&&aA(p,c,y,b);OI;)z--}c[2*y+A]===I?aA(p,c,y,z):(z++,aA(p,c,z,b)),z<=m&&(y=z+1),m<=z&&(b=z-1)}}function aA(p,c,m,y){qde(p,m,y),qde(c,2*m,2*y),qde(c,2*m+1,2*y+1)}function qde(p,c,m){const y=p[c];p[c]=p[m],p[m]=y}function bNe(p,c,m,y){const b=p-m,A=c-y;return b*b+A*A}i.$=qN,i.A=mf,i.B=Nm,i.C=2,i.D=YS,i.E=Qn,i.F=BT,i.G=Gje,i.H=UN,i.I=La,i.J=JL,i.K=Cr,i.L=F0,i.M=mS,i.N=F_,i.O=BL,i.P=cs,i.Q=z_,i.R=hf,i.S=jS,i.T=Xce,i.U=Hg,i.V=JD,i.W=GM,i.X=q0,i.Y=U0,i.Z=I_,i._=Fd,i.a=function(p){return Xn.API_CDN_URL_REGEX.test(p)},i.a$=pe,i.a0=sn,i.a1=Yl,i.a2=yp,i.a3=class extends JD{},i.a4=pS,i.a5=zL,i.a6=Vt,i.a7=function(p){const c=p.value;return c?sn(c)?Mde(c,!0)?[]:[new JD(p.key,c,`invalid url "${c}"`)]:[new JD(p.key,c,`string expected, "${Cr(c)}" found`)]:[]},i.a8=ZL,i.a9=xo,i.aA=_e,i.aB=S,i.aC=ut,i.aD=ed,i.aE=pi,i.aF=U,i.aG=Xe,i.aH=function(p,c){const m={};for(let y=0;y{y(A,I)},c):y(A,I),()=>{}}return b.callbacks.push(y),b.cancel||(b.cancel=m((A,I)=>{b.result=[A,I];for(const O of b.callbacks)this.scheduler?this.scheduler.add(()=>{O(A,I)},c):O(A,I);setTimeout(()=>delete this.entries[p],3e3)})),()=>{b.result||(b.callbacks=b.callbacks.filter(A=>A!==y),b.callbacks.length||(b.cancel(),delete this.entries[p]))}}},i.aL=function(p,c,m){const y=JSON.stringify(p.request);return p.data&&(this.deduped.entries[y]={result:[null,p.data]}),this.deduped.request(y,{type:"parseTile",isSymbolTile:p.isSymbolTile,zoom:p.tileZoom},b=>{const A=Ju(p.request,(I,O,z)=>{I?b(I):O&&b(null,{rawData:O,vectorTile:m?void 0:new Yt(new RD(O)),responseHeaders:new Map(z.entries())})});return()=>{A.cancel(),b()}},c)},i.aM=function(p){return p?{cacheControl:p.get("Cache-Control"),expires:p.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=Dd,i.aO=function(p){xd++,xd>I0&&(p.getActor().send("enforceCacheSizeLimit",E0),xd=0)},i.aP=function(p){return p<=1?1:Math.pow(2,Math.floor(Math.log2(p)))},i.aQ=uo,i.aR=wke,i.aS=Mke,i.aT=x,i.aU=bke,i.aV=function(p,c){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){c(null,m)};for(let y=0;y{}}},i.aW=DT,i.aX=cb,i.aY=Ft,i.aZ=VT,i.a_=re,i.aa=$s,i.ab=class{constructor(p){this.specification=p}possiblyEvaluate(p,c){return yn(p.expression.evaluate(c))}interpolate(p,c,m){return{x:Jr(p.x,c.x,m),y:Jr(p.y,c.y,m),z:Jr(p.z,c.z,m),azimuthal:Jr(p.azimuthal,c.azimuthal,m),polar:Jr(p.polar,c.polar,m)}}},i.ac=Si,i.ad=iy,i.ae=Ze,i.af=st,i.ag=de,i.ah=Pe,i.ai=cy,i.aj=lv,i.ak=Jr,i.al=Hs,i.am=gM,i.an=Or,i.ao=Da,i.ap=class{constructor(p){this.specification=p}possiblyEvaluate(p,c){return function([m,y]){const b=yn([1,m,y]);return{x:b.x,y:b.y,z:b.z}}(p.expression.evaluate(c))}interpolate(p,c,m){return{x:Jr(p.x,c.x,m),y:Jr(p.y,c.y,m),z:Jr(p.z,c.z,m)}}},i.aq=function(p,c,m=0,y=!0){const b=new cs(m,m),A=p.sub(b),I=c.add(b),O=[A,new cs(I.x,A.y),I,new cs(A.x,I.y)];return y&&O.push(A.clone()),O},i.ar=function(p,c){const m=[];for(let y=0;y1)return!1;const m=c.getSource().maxzoom,y=1<1)return c;const b=y.getSource().maxzoom,A=1<{const O=this.getAtTileOffset(p,b,A,I),z=y.upVector(p.canonical,b.x,b.y);return Se(z,z,O*y.upVectorScale(p.canonical,c,m).metersToTile),z}}getForTilePoints(p,c,m,y){if(this.isUsingMockSource())return!1;const b=cC.create(this,p,y);return!!b&&(c.forEach(A=>{A[2]=this.exaggeration()*b.getElevationAt(A[0],A[1],m)}),!0)}getMinMaxForTile(p){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(p);if(!c||!c.dem)return null;const m=c.dem.tree,y=c.tileID,b=1<0&&(y+=(p[b]-0)*(p[b]-0)),c[b]<0&&(y+=(0-c[b])*(0-c[b]));return y},i.c0=w2e,i.c1=hde,i.c2=eke,i.c3=_de,i.c4=$de,i.c5=Se,i.c6=Fe,i.c7=_t,i.c8=function(p,c,m){m*=.5;var y=c[0],b=c[1],A=c[2],I=c[3],O=Math.sin(m),z=Math.cos(m);return p[0]=y*z+b*O,p[1]=b*z-y*O,p[2]=A*z+I*O,p[3]=I*z-A*O,p},i.c9=qe,i.cA=ie,i.cB=Oa,i.cC=ije,i.cD=fi,i.cE=Rwe,i.cF=function(p,c,m,y,b,A,I,O,z){if(z.name==="globe")return Rwe(p,c,new fi(m,y,b),!1);const q=VT({z:m,x:y,y:b},z);return new Nr([(A+q.x/q.scale)*c,c*(q.y/q.scale),I],[(A+q.x2/q.scale)*c,c*(q.y2/q.scale),O])},i.cG=function(p,c,m){return p[0]=Math.min(c[0],m[0]),p[1]=Math.min(c[1],m[1]),p[2]=Math.min(c[2],m[2]),p[3]=Math.min(c[3],m[3]),p},i.cH=function(p,c,m){return p[0]=Math.max(c[0],m[0]),p[1]=Math.max(c[1],m[1]),p[2]=Math.max(c[2],m[2]),p[3]=Math.max(c[3],m[3]),p},i.cI=function(p){const c=Math.round((p+45+360)%360/90)%4;return Rc[c]},i.cJ=fe,i.cK=dt,i.cL=GS,i.cM=function(p){const c=k(new Float64Array(16));S(c,p.pixelMatrix,p.globeMatrix);const m=[0,Bh,0],y=[0,$h,0];return st(m,m,c),st(y,y,c),[m[0]>0&&m[0]<=p.width&&m[1]>0&&m[1]<=p.height&&!Mce(p,new x(p.center.lat,90)),y[0]>0&&y[0]<=p.width&&y[1]>0&&y[1]<=p.height&&!Mce(p,new x(p.center.lat,-90))]},i.cN=function(p,c){const{scale:m}=p.tileTransform,y=m*Hs/(p.tileSize*Math.pow(2,c.zoom-p.tileID.overscaledZ+p.tileID.canonical.z));return function(b,A,I){var O=A[1],z=A[2],q=A[3],X=I[0],Q=I[1];return b[0]=A[0]*X,b[1]=O*X,b[2]=z*Q,b[3]=q*Q,b}(new Float32Array(4),c.inverseAdjustmentMatrix,[y,y])},i.cO=ED,i.cP=ne,i.cQ=aje,i.cR=function(p){const c=aje(p,!0);return f([],[c[0],c[1],c[4],c[5]])},i.cS=D,i.cT=ir,i.cU=L,i.cV=function(p){const{x:c,y:m}=p.point,{lng:y,lat:b}=p._center;return Bwe(c,m,p.worldSize,y,b)},i.cW=Te,i.cX=Oi,i.cY=ao,i.cZ=$c,i.c_=zh,i.ca=Pa,i.cb=function(p,c){return p[0]=-c[0],p[1]=-c[1],p[2]=-c[2],p[3]=c[3],p},i.cc=J,i.cd=function(p,c,m,y,b){var A=1/Math.tan(c/2);if(p[0]=A/m,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=A,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[11]=-1,p[12]=0,p[13]=0,p[15]=0,b!=null&&b!==1/0){var I=1/(y-b);p[10]=(b+y)*I,p[14]=2*b*y*I}else p[10]=-1,p[14]=-2*y;return p},i.ce=function(p,c,m,y,b,A,I){var O=1/(c-m),z=1/(y-b),q=1/(A-I);return p[0]=-2*O,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=-2*z,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=2*q,p[11]=0,p[12]=(c+m)*O,p[13]=(b+y)*z,p[14]=(I+A)*q,p[15]=1,p},i.cf=te,i.cg=function(p,c,m){p[4*c+0]=m[0],p[4*c+1]=m[1],p[4*c+2]=m[2],p[4*c+3]=m[3]},i.ch=qS,i.ci=K_,i.cj=ll,i.ck=bp,i.cl=Y_,i.cm=uke,i.cn=function(){var p=new h(4);return h!=Float32Array&&(p[1]=0,p[2]=0),p[0]=1,p[3]=1,p},i.co=function(p,c,m){var y=c[0],b=c[1],A=c[2],I=c[3],O=Math.sin(m),z=Math.cos(m);return p[0]=y*z+A*O,p[1]=b*z+I*O,p[2]=y*-O+A*z,p[3]=b*-O+I*z,p},i.cp=function(p,c){return p[0]===c[0]&&p[1]===c[1]&&p[2]===c[2]&&p[3]===c[3]},i.cq=Ye,i.cr=function(p){var c=p[0],m=p[1],y=p[2],b=p[3];return Math.sqrt(c*c+m*m+y*y+b*b)},i.cs=ss,i.ct=We,i.cu=zo,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=Ie,i.d=function(p){return Xn.API_TILEJSON_REGEX.test(p)},i.d$=class{constructor(p,c,m,y){this.context=p,this.format=y,this.size=m,this.texture=p.gl.createTexture();const[b,A,I]=this.size,{gl:O}=p;O.bindTexture(O.TEXTURE_3D,this.texture),p.pixelStoreUnpackFlipY.set(!1),p.pixelStoreUnpack.set(1),p.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&O.texImage3D(O.TEXTURE_3D,0,this.format,b,A,I,0,Zce(this.format),Yce(this.format),c.data)}bind(p,c){const{context:m}=this,{gl:y}=m;y.bindTexture(y.TEXTURE_3D,this.texture),p!==this.minFilter&&(y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MAG_FILTER,p),y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MIN_FILTER,p),this.minFilter=p),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:p}=this.context;p.deleteTexture(this.texture),this.texture=null}},i.d0=function(p){return p*p*p*p*p},i.d1=F,i.d2=45,i.d3=VS,i.d4=function(p,c,m){const y=Math.sqrt(p*p+c*c+m*m),b=y>0?Math.acos(m/y)*li:0;let A=p!==0||c!==0?Math.atan2(-c,-p)*li+90:0;return A<0&&(A+=360),[y,A,b]},i.d5=oe,i.d6=yn,i.d7=Le,i.d8=ce,i.d9=Nr,i.dA=function(p){return p({pluginStatus:zd,pluginURL:vf}),bS.on("pluginStateChange",p),p},i.dB=Z_,i.dC=class extends wf{constructor(p){super(p),this.current=HS}set(p,c,m){if(this.fetchUniformLocation(p,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=Co,i.dE=function(p,c,m){const y=lv(m.zoom),b=p.style.map._antialias,A=p.terrain&&p.terrain.exaggeration()>0;return y===0&&!b&&!A},i.dF=function(p){const c=p.pixelsPerMeter,m=c/te(1,p.center.lat),y=k(new Float64Array(16));return E(y,y,[p.point.x,p.point.y,0]),D(y,y,[m,m,c]),Float32Array.from(y)},i.dG=fD,i.dH=function(p){const c=fe-5;p=_e(p,-c,c)/c*90;const m=Math.pow(Math.abs(Math.sin(Or(p))),3);return Math.round(m*(yT.length-1))},i.dI=function(p,c,m,y){const b=c.getNorth(),A=c.getSouth(),I=c.getWest(),O=c.getEast(),z=1<0){const le=180/y;_(ae,ae,[le/q+1,0,0,0,le/X+1,0,-.5*le/Q,.5*le/se,1])}return ae[2]=z,ae[5]=p.x,ae[8]=p.y,ae},i.dJ=Mm,i.dK=function(p,c,m){const y=k(new Float64Array(16)),b=(c/(1<({u_matrix:new Y_(p),u_texsize:new bp(p),u_pixels_to_tile_units:new WS(p),u_device_pixel_ratio:new ll(p),u_width_scale:new ll(p),u_floor_width_scale:new ll(p),u_image:new qS(p),u_units_to_pixels:new bp(p),u_tile_units_to_pixels:new ll(p),u_alpha_discard_threshold:new ll(p),u_trim_offset:new bp(p),u_trim_fade_range:new bp(p),u_trim_color:new VS(p),u_zbias_factor:new ll(p),u_tile_to_meter:new ll(p),u_ground_shadow_factor:new K_(p),u_pattern_transition:new ll(p)}),i.dX=p=>({u_matrix:new Y_(p),u_pixels_to_tile_units:new WS(p),u_device_pixel_ratio:new ll(p),u_width_scale:new ll(p),u_floor_width_scale:new ll(p),u_units_to_pixels:new bp(p),u_dash_image:new qS(p),u_gradient_image:new qS(p),u_image_height:new ll(p),u_texsize:new bp(p),u_tile_units_to_pixels:new ll(p),u_alpha_discard_threshold:new ll(p),u_trim_offset:new bp(p),u_trim_fade_range:new bp(p),u_trim_color:new VS(p),u_zbias_factor:new ll(p),u_tile_to_meter:new ll(p),u_ground_shadow_factor:new K_(p)}),i.dY=p=>({u_camera_to_center_distance:new ll(p),u_extrude_scale:new WS(p),u_device_pixel_ratio:new ll(p),u_matrix:new Y_(p),u_inv_rot_matrix:new Y_(p),u_merc_center:new bp(p),u_tile_id:new K_(p),u_zoom_transition:new ll(p),u_up_dir:new K_(p),u_emissive_strength:new ll(p)}),i.dZ=LS,i.d_=UJe,i.da=ge,i.db=function(p){return[Math.pow(p[0],1/2.2),Math.pow(p[1],1/2.2),Math.pow(p[2],1/2.2)]},i.dc=nje,i.dd=rde,i.de=cje,i.df=Mde,i.dg=function(p,c){return p.readFields(qet,{icons:[]},c)},i.dh=CD,i.di=aC,i.dj=xde,i.dk=L0,i.dl=U_,i.dm=Lg,i.dn=Cs,i.dp=ps,i.dq=function(p){const c=p.indexOf(hy);return c>=0?p.slice(0,c):p},i.dr=function(p){return p.indexOf(hy)>=0},i.ds=function(p){const c=p.lastIndexOf(hy);return c>=0?p.slice(c+1):""},i.dt=function(p){const c=[],m=p.id;return m===void 0&&c.push({message:`layers.${m}: missing required property "id"`}),p.render===void 0&&c.push({message:`layers.${m}: missing required method "render"`}),p.renderingMode&&p.renderingMode!=="2d"&&p.renderingMode!=="3d"&&c.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),c},i.du=function(p,c,m,y){return p.type==="custom"?new Oet(p,c):new $et[p.type](p,c,m,y)},i.dv=Ss,i.dw=function(p){const c=p.indexOf(hy);return c>=0?p.slice(c+1):""},i.dx=class extends lb{constructor(p,c){super(p._vectorTileFeature,p._z,p._x,p._y,p.id),p.state&&(this.state=Object.assign({},p.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=p.source,this.sourceLayer=p.sourceLayer,this.layer=p.layer)}toJSON(){const p=super.toJSON();return p.target=this.target,p.namespace=this.namespace,p}},i.dy=bS,i.dz=up,i.e=Xn,i.e$=ue,i.e0=qwe,i.e1=(p,c,m,y,b,A)=>{const I=p.transform,O=I.projection.name==="globe";let z;if(A.paint.get("circle-pitch-alignment")==="map")if(O){const X=zwe(I.zoom,c.canonical)*I._pixelsPerMercatorPixel;z=Float32Array.from([X,0,0,X])}else z=I.calculatePixelsToTileUnitsMatrix(m);else z=new Float32Array([I.pixelsToGLUnits[0],0,0,I.pixelsToGLUnits[1]]);const q={u_camera_to_center_distance:p.transform.getCameraToCenterDistance(I.projection),u_matrix:p.translatePosMatrix(c.projMatrix,m,A.paint.get("circle-translate"),A.paint.get("circle-translate-anchor")),u_device_pixel_ratio:il.devicePixelRatio,u_extrude_scale:z,u_inv_rot_matrix:nQe,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:A.paint.get("circle-emissive-strength")};if(O){q.u_inv_rot_matrix=y,q.u_merc_center=b,q.u_tile_id=[c.canonical.x,c.canonical.y,1<{const X=p.transform,Q=X.pitch<15?wje(.07,.7,_e((14-X.zoom)/5,0,1)):.07,se=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:kje(p,c,m,y),u_texsize:c.imageAtlasTexture?c.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:X.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:b,u_width_scale:A,u_floor_width_scale:I,u_image:0,u_tile_units_to_pixels:jje(c,X),u_units_to_pixels:[1/X.pixelsToGLUnits[0],1/X.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(se?null:m.lut).toArray01(),u_zbias_factor:Q,u_tile_to_meter:Le(c.tileID.canonical,0),u_ground_shadow_factor:z,u_pattern_transition:q}},i.e5=(p,c,m,y,b,A,I,O,z,q)=>{const X=p.transform,Q=X.calculatePixelsToTileUnitsMatrix(c),se=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",ae=X.pitch<15?wje(.07,.7,_e((14-X.zoom)/5,0,1)):.07;return{u_matrix:kje(p,c,m,y),u_pixels_to_tile_units:Q,u_device_pixel_ratio:A,u_width_scale:I,u_floor_width_scale:O,u_units_to_pixels:[1/X.pixelsToGLUnits[0],1/X.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:b,u_texsize:Sje(m)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:jje(c,p.transform),u_alpha_discard_threshold:0,u_trim_offset:z,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(se?null:m.lut).toArray01(),u_zbias_factor:ae,u_tile_to_meter:Le(c.tileID.canonical,0),u_ground_shadow_factor:q}},i.e6=Zt,i.e7=_T,i.e8=me,i.e9=qh,i.eA=function(p,c){var m=2*Math.acos(c[3]),y=Math.sin(m/2);return y>d?(p[0]=c[0]/y,p[1]=c[1]/y,p[2]=c[2]/y):(p[0]=1,p[1]=0,p[2]=0),m},i.eB=Ede,i.eC=LD,i.eD=PD,i.eE=[1,1,1],i.eF=cC,i.eG=it,i.eH=function(p,c,m,y){var b=c[0],A=c[1],I=c[2],O=c[3];return p[0]=b+y*(m[0]-b),p[1]=A+y*(m[1]-A),p[2]=I+y*(m[2]-I),p[3]=O+y*(m[3]-O),p},i.eI=eC,i.eJ=rh,i.eK=_p,i.eL=function(p,c,m,y,b,A,I,O,z,q,X,Q,se,ae,le,xe){var Me=new h(16);return Me[0]=p,Me[1]=c,Me[2]=m,Me[3]=y,Me[4]=b,Me[5]=A,Me[6]=I,Me[7]=O,Me[8]=z,Me[9]=q,Me[10]=X,Me[11]=Q,Me[12]=se,Me[13]=ae,Me[14]=le,Me[15]=xe,Me},i.eM=N,i.eN=sv,i.eO=lT,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new cs(1/0,1/0),max:new cs(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(p,c=!1){const m=v2e(new cs(0,0),new cs(Hs,Hs),p),y=[];if(c&&!Rce(m,this._globalClipBounds))return y;for(const b of this._activeRegions){if(b.hiddenByOverlap||!Rce(m,b))continue;const A=PQe(b.min,b.max,p);y.push({min:A.min,max:A.max,sourceId:this._sourceIds[b.priority],footprint:b.footprint,footprintTileId:b.tileId,order:b.order,clipMask:b.clipMask,clipScope:b.clipScope})}return y}setSources(p){this._setSources(p.map(c=>({getSourceId:()=>c.cache.id,getFootprints:()=>{const m=[];for(const y of c.cache.getVisibleCoordinates()){const b=c.cache.getTile(y).buckets[c.layer];b&&b.updateFootprints(y.toUnwrapped(),m)}return m},getOrder:()=>c.order,getClipMask:()=>c.clipMask,getClipScope:()=>c.clipScope})))}_addSource(p){const c=p.getFootprints();if(c.length===0)return;const m=p.getOrder(),y=p.getClipMask(),b=p.getClipScope();for(const A of c){if(!A.footprint)continue;const I=v2e(A.footprint.min,A.footprint.max,A.id);this._activeRegions.push({min:I.min,max:I.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:A.id,footprint:A.footprint,order:m,clipMask:y,clipScope:b})}this._sourceIds.push(p.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,m)=>c.priority-m.priority||wD(c.min,m.min)||wD(c.max,m.max)||c.order-m.order||c.clipMask-m.clipMask||function(y,b){const A=(I,O)=>I+O;return y.length-b.length||y.reduce(A,"").localeCompare(b.reduce(A,""))}(c.clipScope,m.clipScope));let p=this._activeRegions.length!==this._prevRegions.length;if(!p){let c=0;for(;!p&&c!==this._activeRegions.length;){const m=this._activeRegions[c],y=this._prevRegions[c];p=m.priority!==y.priority||!y2e(m,y)||m.order!==y.order||m.clipMask!==y.clipMask||!ka(m.clipScope,y.clipScope),this._activeRegions[c].hiddenByOverlap=y.hiddenByOverlap,++c}}if(p){++this._updateTime;for(const m of this._activeRegions)m.order!==ST&&(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 b=y[m].priority;for(;m1){let m=0,y=c(m);for(;m!==y;){let b=m;const A=m;for(;b!==y;){const I=this._activeRegions[b];I.hiddenByOverlap=!1;for(let O=0;O=0;c--)this._addSource(p[c]);this._computeReplacement()}},i.eQ=ST,i.eR=class{constructor(p){this._createGrid(p),this._createPoles(p)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const p of this._poleSegments)p.destroy();for(const p of this._gridSegments)p.withSkirts.destroy(),p.withoutSkirts.destroy()}_fillGridMeshWithLods(p,c){const m=new Gg,y=new ol,b=[],A=p+1+2,I=c[0]+1,O=c[0]+1+(1+c.length),z=(q,X,Q)=>{let se=q===A-1?q-2:q===0?q:q-1;return se+=Q?24575:0,[se,X]};for(let q=0;q0?(Me=2*Math.sqrt(xe+1),p[3]=.25*Me,p[0]=(Q-ae)/Me,p[1]=(se-z)/Me,p[2]=(O-q)/Me):I>X&&I>le?(Me=2*Math.sqrt(1+I-X-le),p[3]=(Q-ae)/Me,p[0]=.25*Me,p[1]=(O+q)/Me,p[2]=(se+z)/Me):X>le?(Me=2*Math.sqrt(1+X-I-le),p[3]=(se-z)/Me,p[0]=(O+q)/Me,p[1]=.25*Me,p[2]=(Q+ae)/Me):(Me=2*Math.sqrt(1+le-I-X),p[3]=(O-q)/Me,p[0]=(se+z)/Me,p[1]=(Q+ae)/Me,p[2]=.25*Me),p},i.f=function(p){return btoa(encodeURIComponent(p).replace(/%([0-9A-F]{2})/g,(c,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([p,c,m]){const y=Math.hypot(p,c,m),b=Math.atan2(p,m),A=.5*Math.PI-Math.acos(-c/y);return new x(Oi(b),Oi(A))},i.f1=tt,i.f2=Qce,i.f3=function(p){const c=p.navigator?p.navigator.userAgent:null;return!!function(m){if(Po==null){const y=m.navigator?m.navigator.userAgent:null;Po=!!m.safari||!(!y||!(/\b(iPad|iPhone|iPod)\b/.test(y)||y.match("Safari")&&!y.match("Chrome")))}return Po}(p)&&!(!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(p,c){E0=p,I0=c},i.f5=Mce,i.f6=$we,i.f7=function(p){const c=[0,0,0],m=k(new Float64Array(16));return S(m,p.pixelMatrix,p.globeMatrix),st(c,c,m),new cs(c[0],c[1])},i.f8=function(){const p=IT;p&&(p.isPreloaded()&&p.numActive()===1?(p.release(qce),IT=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(){CD().acquire(qce)},i.fA=iO,i.fB=Bt,i.fC=function(p){let c=0;if(new Uint32Array(p,0,1)[0]!==J2e){const m=new Uint32Array(p,0,7),[,,y,b,A,I]=m;c=m.byteLength+b+A+I+A,(y!==p.byteLength||c>=p.byteLength)&&cr("Invalid b3dm header information.")}return rje(p,c)},i.fD=function(p,c){const m=rde(p);for(const y of m){for(const b of y.meshes)dJe(b);y.lights&&(y.lightMeshIndex=y.meshes.length,y.meshes.push(uJe(y.lights,c)))}return m},i.fE=eO,i.fF=aa,i.fG=K2e,i.fH=_f,i.fI=Su,i.fJ=function(p){Bc(),Xu!=null&&Xu.then(c=>{c.keys().then(m=>{for(let y=0;ycr(b.message))}).catch(m=>cr(m.message))}).catch(c=>cr(c.message))},i.fa=q_,i.fb=function(p,c,m=!1){if(zd===Su.deferred||zd===Su.loading||zd===Su.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");vf=il.resolveURL(p),zd=Su.deferred,XM=c,_S(),m||KL()},i.fc=function(p){XS=il.resolveURL(p),QS||(QS=new YS(CD(),new Qn)),QS.broadcast("setMeshoptUrl",XS)},i.fd=X2e,i.fe=function(p){Wce=il.resolveURL(p),QS||(QS=new YS(CD(),new Qn)),QS.broadcast("setDracoUrl",Wce)},i.ff=Y2e,i.fg=ET,i.fh=function(p){const c=ku();if(!c)return;const m=c.delete(A0);p&&m.then(()=>p()).catch(p)},i.fi=rb,i.fj=xr,i.fk=cv,i.fl=Ef,i.fm=gNe,i.fn=xNe,i.fo=yje,i.fp=is,i.fq="hd_road_elevation",i.fr=Ba,i.fs=Jt,i.ft=gy,i.fu=gde,i.fv=ib,i.fw=function(p,c,m,y,b,A,I,O=1,z,q,X){p.createArrays(),p.tilePixelRatio=Hs/(512*p.overscaling),p.compareText={},p.iconsNeedLinear=!1;const Q=p.layers[0].layout,se=p.layers[0]._unevaluatedLayout._values,ae={};ae.scaleFactor=O,ae.textSizeScaleRange=Q.get("text-size-scale-range"),ae.iconSizeScaleRange=Q.get("icon-size-scale-range");const[le,xe]=ae.textSizeScaleRange,[Me,Ce]=ae.iconSizeScaleRange;ae.textScaleFactor=_e(ae.scaleFactor,le,xe),ae.iconScaleFactor=_e(ae.scaleFactor,Me,Ce);const ze=se["text-size"],Ve=se["icon-size"];if(p.textSizeData.kind==="composite"){const{minZoom:Ot,maxZoom:ns}=p.textSizeData;ae.compositeTextSizes=[ze.possiblyEvaluate(new Si(Ot,{worldview:X}),A),ze.possiblyEvaluate(new Si(ns,{worldview:X}),A)]}if(p.iconSizeData.kind==="composite"){const{minZoom:Ot,maxZoom:ns}=p.iconSizeData;ae.compositeIconSizes=[Ve.possiblyEvaluate(new Si(Ot,{worldview:X}),A),Ve.possiblyEvaluate(new Si(ns,{worldview:X}),A)]}ae.layoutTextSize=ze.possiblyEvaluate(new Si(I+1,{worldview:X}),A),ae.layoutIconSize=Ve.possiblyEvaluate(new Si(I+1,{worldview:X}),A),ae.textMaxSize=ze.possiblyEvaluate(new Si(18,{worldview:X}),A);const Je=Q.get("symbol-placement"),vt=Q.get("text-rotation-alignment")==="map"&&Je!=="point",mt=Q.get("text-size");let St=!1;const It=[];for(const Ot of p.features){const ns=Q.get("text-font").evaluate(Ot,{},A).join(","),qt=mt.evaluate(Ot,{},A)*ae.textScaleFactor,us=ae.layoutTextSize.evaluate(Ot,{},A)*ae.textScaleFactor,gs=ae.layoutIconSize.evaluate(Ot,{},A)*ae.iconScaleFactor,xs={horizontal:{},vertical:void 0},As=Ot.text;let Is,Ns=[0,0];if(As){const Nn=As.toString(),di=Q.get("text-letter-spacing").evaluate(Ot,{},A)*Ol,pt=Q.get("text-line-height").evaluate(Ot,{},A)*Ol,bt=ZM(Nn)?di:0,hs=Q.get("text-anchor").evaluate(Ot,{},A),Es=Q.get("text-variable-anchor");if(!Es){const wn=Q.get("text-radial-offset").evaluate(Ot,{},A);if(wn)Ns=eke(hs,[wn*Ol,vde]);else{const An=Q.get("text-offset").evaluate(Ot,{},A);Ns=[An[0]*Ol,An[1]*Ol]}}let sr=vt?"center":Q.get("text-justify").evaluate(Ot,{},A);const rr=Je==="point",Ar=rr?Q.get("text-max-width").evaluate(Ot,{},A)*Ol:1/0,Lr=wn=>{p.allowVerticalPlacement&&$_(Nn)&&(xs.vertical=ude(As,c,m,b,ns,Ar,pt,hs,wn,bt,Ns,ih.vertical,!0,us,qt,z))};if(!vt&&Es){const wn=sr==="auto"?Es.map(Ln=>_de(Ln)):[sr];let An=!1;for(let Ln=0;Ln=0||!$_(Nn)){const wn=ude(As,c,m,b,ns,Ar,pt,hs,sr,bt,Ns,ih.horizontal,!1,us,qt,z);wn&&(xs.horizontal[sr]=wn)}Lr(rr?"left":sr)}}let Ms,ds,as,Ts,Ws,Rs,Mr=!1;const or=Q.get("icon-text-fit").evaluate(Ot,{},A);if(Ot.icon&&Ot.icon.hasPrimary()){const Nn=UT(Ot.icon,p.iconSizeData,se["icon-size"],A,p.zoom,Ot,z,ae.iconScaleFactor,X);Ms=Nn.iconPrimary,as=Nn.iconSecondary;const di=Ms.toString();if(ds=y.get(di),ds&&(Ws=Q.get("icon-offset").evaluate(Ot,{},A),Rs=Q.get("icon-anchor").evaluate(Ot,{},A),Is=zD(b.get(di),as?b.get(as.toString()):void 0,Ws,Rs),Mr=ds.sdf,p.sdfIcons===void 0?p.sdfIcons=ds.sdf:p.sdfIcons!==ds.sdf&&cr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ds.pixelRatio!==p.pixelRatio||Q.get("icon-rotate").constantOr(1)!==0)&&(p.iconsNeedLinear=!0)),as){const pt=as.toString();Ts=y.get(pt)}}St=St||!(!Ot.icon||!Ot.icon.hasSecondary());const mr=VD(xs.horizontal)||xs.vertical;p.iconsInText||(p.iconsInText=!!mr&&mr.iconsInText);const vr=us*ae.textScaleFactor/Ol,{defaultShapedIcon:Dn,verticallyShapedIcon:zs}=_et(p,Is,Q,Ot,A,xs,vr,Ws,or);or!=="none"&&Is&&(zje(Is)||Bje(Is))&&(qD(0,ds,Ms,Is,Dn,or,q,y,b),qD(0,Ts,as,Is,Dn,or,q,y,b),zs&&(qD(0,ds,Ms,Is,zs,or,q,y,b),qD(0,Ts,as,Is,zs,or,q,y,b))),Is=Dn;const{iconBBox:_r,iconVerticalBBox:an,textBBox:oa,textVerticalBBox:ha}=fet(p,Is,zs,Q,Ot,A,gs,Ws,ae,b,Rs,xs,us,Ns);It.push({feature:Ot,shapedTextOrientations:xs,shapedText:mr,shapedIcon:Is,iconPrimary:Ms,iconSecondary:as,iconOffset:Ws,iconAnchor:Rs,verticallyShapedIcon:zs,layoutTextSize:us,layoutIconSize:gs,textOffset:Ns,isSDFIcon:Mr,iconTextFit:or,iconCollisionBounds:_r,iconVerticalCollisionBounds:an,textCollisionBounds:oa,textVerticalCollisionBounds:ha})}return{featureData:It,sizes:ae,hasAnySecondaryIcon:St,textAlongLine:vt,symbolPlacement:Je}},i.fx=Kje,i.fy=function(p,c,m,y,b,A,I,O,z,q){p.iconAtlasPositions=q.iconPositions;const{featureData:X,hasAnySecondaryIcon:Q,sizes:se,textAlongLine:ae,symbolPlacement:le}=c;for(const xe of X){const{shapedIcon:Me,verticallyShapedIcon:Ce,feature:ze,shapedTextOrientations:Ve,shapedText:Je,layoutTextSize:vt,textOffset:mt,isSDFIcon:St,iconPrimary:It,iconSecondary:Ot,iconTextFit:ns,iconOffset:qt,iconCollisionBounds:us,iconVerticalCollisionBounds:gs,textCollisionBounds:xs}=xe;ske(Me,q.iconPositions,It,Ot),ske(Ce,q.iconPositions,It,Ot),vet(Ve,q.iconPositions),yet(It,Ot,q.iconPositions),(Je||Me)&&bet(p,ze,Ve,Me,Ce,z,se,vt,0,mt,St,y,b,I,O,Q,ns,qt,ae,le,us,gs,xs)}m&&p.generateCollisionDebugBuffers(A,p.collisionBoxArray,se.textScaleFactor)},i.fz=Yt,i.g=function(p,c){return up(Object.assign(p,{method:"GET"}),c)},i.h=function(p){return p.indexOf("mapbox:")===0},i.i=function(p){return Xn.API_STYLE_REGEX.test(p)&&!Ll(p)},i.j=Yi,i.k=Jo,i.l=function(p){return decodeURIComponent(atob(p).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(p,c){return up(Object.assign(p,{type:"json"}),c)},i.n=D0,i.o=il,i.p=function(p,c){return up(Object.assign(p,{method:"POST"}),c)},i.q=rd,i.r=Lh,i.s=function(p){try{const c=self[p];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return Vce||(Vce=new rb("ImageRasterizer")),Vce},i.u=function(){return function p(c){return c?(c^Math.random()*(16>>c/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,p)}()},i.v=function(p){return!!p&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(p)},i.w=cr,i.x=Rde,i.y=dn,i.z=Ks}),o(["./shared"],function(i){function d(rt){const _e=rt?rt.url.toString():void 0;return _e?performance.getEntriesByName(_e):[]}function h(rt){if(typeof rt=="number"||typeof rt=="boolean"||typeof rt=="string"||rt==null)return JSON.stringify(rt);if(Array.isArray(rt)){let Pe="[";for(const Qe of rt)Pe+=`${h(Qe)},`;return`${Pe}]`}let _e="{";for(const Pe of Object.keys(rt).sort())_e+=`${Pe}:${h(rt[Pe])},`;return`${_e}}`}function f(rt){let _e="";for(const Pe of i.bx)_e+=`/${h(rt[Pe])}`;return _e}class g{constructor(_e){this.keyCache={},this._layers={},this._layerConfigs={},_e&&this.replace(_e)}replace(_e,Pe){this._layerConfigs={},this._layers={},this.update(_e,[],Pe)}update(_e,Pe,Qe){this._options=Qe;for(const kt of _e)this._layerConfigs[kt.id]=kt,(this._layers[kt.id]=i.du(kt,this.scope,null,this._options)).compileFilter(Qe),this.keyCache[kt.id]&&delete this.keyCache[kt.id];for(const kt of Pe)delete this.keyCache[kt],delete this._layerConfigs[kt],delete this._layers[kt];this.familiesBySource={};const Tt=function(kt,Dt){const Zt={};for(let Jt=0;Jtthis._layers[ur.id]),Zt=Dt[0];if(Zt.visibility==="none")continue;const Ft=Zt.source||"";let Jt=this.familiesBySource[Ft];Jt||(Jt=this.familiesBySource[Ft]={});const Ss=Zt.sourceLayer||"_geojsonTileLayer";let ps=Jt[Ss];ps||(ps=Jt[Ss]=[]),ps.push(Dt)}}}const v=1*i.fl;class _{constructor(_e){const Pe={},Qe=[];for(const Zt in _e){const Ft=_e[Zt],Jt=Pe[Zt]={};for(const Ss in Ft.glyphs){const ps=Ft.glyphs[+Ss];if(!ps||ps.bitmap.width===0||ps.bitmap.height===0)continue;const ur=ps.metrics.localGlyph?v:1,Dr={x:0,y:0,w:ps.bitmap.width+2*ur,h:ps.bitmap.height+2*ur};Qe.push(Dr),Jt[Ss]=Dr}}const{w:Tt,h:kt}=i.G(Qe),Dt=new i.fk({width:Tt||1,height:kt||1});for(const Zt in _e){const Ft=_e[Zt];for(const Jt in Ft.glyphs){const Ss=Ft.glyphs[+Jt];if(!Ss||Ss.bitmap.width===0||Ss.bitmap.height===0)continue;const ps=Pe[Zt][Jt],ur=Ss.metrics.localGlyph?v:1;i.fk.copy(Ss.bitmap,Dt,{x:0,y:0},{x:ps.x+ur,y:ps.y+ur},Ss.bitmap)}}this.image=Dt,this.positions=Pe}}function j(rt,_e,Pe){rt[_e]?Pe&&(rt[_e].center=Pe):rt[_e]={floorIds:new Set,center:Pe||[0,0],floors:{}}}function w(rt,_e,Pe,Qe){for(const Tt of _e)j(rt,Tt),rt[Tt].floors[Pe]=Qe,rt[Tt].floorIds.add(Pe)}function k(rt){return{id:rt.properties.id.toString(),center:rt.properties.center.toString().split(";").map(Number)}}function M(rt){return{id:rt.properties.id.toString(),isDefault:!!rt.properties.is_default&&rt.properties.is_default,connections:rt.properties.connected_floor_ids?new Set(rt.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:rt.properties.conflicted_floor_ids?new Set(rt.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:rt.properties.building_ids?new Set(rt.properties.building_ids.toString().split(";")):new Set,name:rt.properties.name.toString(),zIndex:rt.properties.z_index}}function S(rt,_e){return _e.every(Pe=>rt.properties&&rt.properties[Pe]!=null)}function E(rt){return S(rt,["type","id","name"])&&rt.properties.type==="building"}function D(rt){return S(rt,["type","id","name","z_index"])&&rt.properties.type==="floor"}i.fj(_,"GlyphAtlas");class L{constructor(_e){this.tileID=new i.aQ(_e.tileID.overscaledZ,_e.tileID.wrap,_e.tileID.canonical.z,_e.tileID.canonical.x,_e.tileID.canonical.y),this.tileZoom=_e.tileZoom,this.uid=_e.uid,this.zoom=_e.zoom,this.lut=_e.lut,this.canonical=_e.tileID.canonical,this.pixelRatio=_e.pixelRatio,this.tileSize=_e.tileSize,this.source=_e.source,this.scope=_e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=_e.showCollisionBoxes,this.collectResourceTiming=!!_e.request&&_e.request.collectResourceTiming,this.promoteId=_e.promoteId,this.isSymbolTile=_e.isSymbolTile,this.tileTransform=i.aZ(_e.tileID.canonical,_e.projection),this.projection=_e.projection,this.worldview=_e.worldview,this.localizableLayerIds=_e.localizableLayerIds,this.brightness=_e.brightness,this.extraShadowCaster=!!_e.extraShadowCaster,this.tessellationStep=_e.tessellationStep,this.scaleFactor=_e.scaleFactor,this.worldview=_e.worldview,this.indoor=_e.indoor}parse(_e,Pe,Qe,Tt,kt,Dt){this.status="parsing",this.data=_e,this.collisionBoxArray=new i.b3;const Zt=new i.fm(Object.keys(_e.layers).sort()),Ft=new i.fn(this.tileID,this.promoteId);Ft.bucketLayerIDs=[];const Jt={},Ss=new i.fo(256,256),ps={featureIndex:Ft,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ss,availableImages:Qe,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const jn=this.indoor.indoorState.activeFloorsVisible,kn=function(yn,aa,so){const Po=function(Ki,pa){if(!Ki)return i.w("No source layers defined in indoor specification"),pa;if(Ki.size===0)return pa;const Zi=Ki.difference(pa);for(const ci of Zi)i.w(`Missing source layer required in indoor specification: ${ci}`);return pa.intersection(pa)}(aa.sourceLayers,new Set(Object.keys(yn.layers))),Pa=aa.indoorState,Fo=function(Ki,pa,Zi,ci){const Xn=new Set,Yi=new Set,Ll=new Set,Zl=new Map,fd={},dp=al=>{const nu=Zl.get(al)||new Set;for(const zc of Xn)if((Zl.get(zc)||new Set).has(al)||nu.has(zc))return!0;return!1};for(const al of pa){const nu=Ki.layers[al];if(nu)for(let zc=0;zc=Zi.maxzoom||Zi.visibility==="none")continue;B(pa,this.zoom,ps.brightness,Qe,this.worldview);const ci=Jt[Zi.id]=Zi.createBucket({index:Ft.bucketLayerIDs.length,layers:pa,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Po,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:Tt,worldview:this.worldview,localizable:Fo});Ft.bucketLayerIDs.push(pa.map(Yi=>i.B(Yi.id,Yi.scope)));let Xn=ci.prepare?ci.prepare():null;Xn!=null?(Xn=Xn.then(()=>ci.populate(Pa,ps,this.tileID.canonical,this.tileTransform)),ur.push(Xn)):ci.populate(Pa,ps,this.tileID.canonical,this.tileTransform)}}const cr=()=>{let jn,kn,yn,aa,so,Po;Ss.trim();const Pa={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},Fo=()=>{if(jn)return this.status="done",Dt(jn);if(this.extraShadowCaster)this.status="done",Dt(null,{buckets:Object.values(Jt).filter(pa=>!pa.isEmpty()),featureIndex:Ft,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:ps.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(kn&&yn&&aa){const pa=new _(kn),Zi=new Map;for(const[Yi,Ll]of yn.entries()){const{imagePosition:Zl}=i.fu(Yi,Ll,i.fv);Zi.set(Yi,Zl)}const ci={};for(const Yi in Jt){const Ll=Jt[Yi];Ll instanceof i.b4&&(B(Ll.layers,this.zoom,ps.brightness,Qe,this.worldview),ci[Yi]=i.fw(Ll,kn,pa.positions,yn,Zi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,so,this.worldview))}const Xn={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(kt,yn,so,()=>{Xn.iconsPending=!1,Ki(ci,pa,Xn)}),this.rasterizeIfNeeded(kt,aa,Po,()=>{Xn.patternsPending=!1,Ki(ci,pa,Xn)})}},Ki=(pa,Zi,ci,Xn)=>{if(ci.iconsPending||ci.patternsPending)return;const Yi=new i.fx(yn,aa,this.lut);for(const Ll in Jt){const Zl=Jt[Ll];if(Ll in pa)i.fy(Zl,pa[Ll],this.showCollisionBoxes,Qe,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,yn,Yi);else if(Zl.hasPattern&&(Zl instanceof i.ba||Zl instanceof i.bb||Zl instanceof i.ea)){B(Zl.layers,this.zoom,ps.brightness,Qe,this.worldview);const fd=Object.fromEntries(Yi.patternPositions);Zl.addFeatures(ps,this.tileID.canonical,fd,Qe,this.tileTransform,this.brightness)}}this.status="done",Dt(null,{buckets:Object.values(Jt).filter(Ll=>!Ll.isEmpty()),featureIndex:Ft,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Zi.image,lineAtlas:Ss,imageAtlas:Yi,brightness:ps.brightness})};if(!this.extraShadowCaster){const pa=i.fs(ps.glyphDependencies,Xn=>Object.keys(Xn).map(Number));Object.keys(pa).length?kt.send("getGlyphs",{uid:this.uid,stacks:pa},(Xn,Yi)=>{jn||(jn=Xn,kn=Yi,Fo())},void 0,!1,Pa):kn={};const Zi=Array.from(ps.iconDependencies.keys()).map(Xn=>i.I.parse(Xn));Zi.length?kt.send("getImages",{images:Zi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(Xn,Yi)=>{jn||(jn=Xn,yn=new Map,so=this.updateImageMapAndGetImageTaskQueue(yn,Yi,ps.iconDependencies),Fo())},void 0,!1,Pa):(yn=new Map,so=new Map);const ci=Array.from(ps.patternDependencies.keys()).map(Xn=>i.I.parse(Xn));ci.length?kt.send("getImages",{images:ci,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(Xn,Yi)=>{jn||(jn=Xn,aa=new Map,Po=this.updateImageMapAndGetImageTaskQueue(aa,Yi,ps.patternDependencies),Fo())},void 0,!1,Pa):(aa=new Map,Po=new Map)}if(ps.elevationFeatures&&ps.elevationFeatures.length>0){const pa=[];for(const ci of Object.values(Jt))if(ci instanceof i.bb){const Xn=ci.getUnevaluatedPortalGraph();Xn&&pa.push(Xn)}const Zi=i.ft.evaluate(pa);for(const ci of Object.values(Jt))if(ci instanceof i.bb){const Xn=_e.layers[Zt.decode(ci.sourceLayerIndex)];ci.setEvaluatedPortalGraph(Zi,Xn,this.tileID.canonical,ps.availableImages,ps.brightness)}}Fo()};ur.length>0?Promise.allSettled(ur).then(cr).catch(Dt):cr()}updateParameters(_e){this.scaleFactor=_e.scaleFactor,this.showCollisionBoxes=_e.showCollisionBoxes,this.projection=_e.projection,this.brightness=_e.brightness,this.tileTransform=i.aZ(_e.tileID.canonical,_e.projection),this.extraShadowCaster=_e.extraShadowCaster,this.lut=_e.lut,this.worldview=_e.worldview,this.indoor=_e.indoor}rasterizeIfNeeded(_e,Pe,Qe,Tt){Array.from(Pe.values()).some(kt=>kt.usvg)?this.rasterize(_e,Pe,Qe,Tt):Tt()}updateImageMapAndGetImageTaskQueue(_e,Pe,Qe){const Tt=new Map;for(const kt of Pe.keys()){const Dt=Qe.get(kt)||[];for(const Zt of Dt){const Ft=Zt.toString(),Jt=Pe.get(Zt.id.toString());Jt.usvg?Tt.has(Ft)||(Tt.set(Ft,Zt),_e.set(Ft,Object.assign({},Jt))):_e.set(Ft,Jt)}}return Tt}rasterize(_e,Pe,Qe,Tt){this.rasterizeTask=_e.send("rasterizeImages",{scope:this.scope,tasks:Qe},(kt,Dt)=>{if(!kt)for(const[Zt,Ft]of Dt.entries()){const Jt=Object.assign(Pe.get(Zt),{data:Ft});Pe.set(Zt,Jt)}Tt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function B(rt,_e,Pe,Qe,Tt){const kt=new i.ac(_e,{brightness:Pe,worldview:Tt});for(const Dt of rt)Dt.recalculate(kt,Qe)}class $ extends i.E{constructor(_e,Pe,Qe,Tt,kt,Dt,Zt){super(),this.actor=_e,this.layerIndex=Pe,this.availableImages=Qe,this.availableModels=Tt,this.loadVectorData=Dt||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(_e.scheduler),this.isSpriteLoaded=kt,this.scheduler=_e.scheduler,this.brightness=Zt}loadTile(_e,Pe){const Qe=_e.uid,Tt=_e&&_e.request,kt=Tt&&Tt.collectResourceTiming,Dt=this.loading[Qe]=new L(_e);Dt.abort=this.loadVectorData(_e,(Zt,Ft)=>{const Jt=!this.loading[Qe];if(delete this.loading[Qe],Dt.cancelRasterize(),Jt||Zt||!Ft)return Dt.status="done",Jt||(this.loaded[Qe]=Dt),Pe(Zt);const Ss=Ft.rawData,ps={},ur=i.aM(Ft.responseHeaders);ur&&ur.expires&&(ps.expires=ur.expires),ur&&ur.cacheControl&&(ps.cacheControl=ur.cacheControl),Dt.vectorTile=Ft.vectorTile||new i.fz(new i.bt(Ss));const Dr=()=>{Dt.parse(Dt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(cr,jn)=>{if(cr||!jn)return Pe(cr);const kn={};if(kt){const yn=d(Tt);yn.length>0&&(kn.resourceTiming=JSON.parse(JSON.stringify(yn)))}Pe(null,Object.assign({rawTileData:Ss.slice(0),responseHeaders:Ft.responseHeaders},jn,ps,kn))})};this.isSpriteLoaded?Dr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Dr,{type:"parseTile",isSymbolTile:_e.isSymbolTile,zoom:_e.tileZoom}):Dr()}),this.loaded=this.loaded||{},this.loaded[Qe]=Dt})}reloadTile(_e,Pe){const Qe=this.loaded,Tt=_e.uid;if(Qe&&Qe[Tt]){const kt=Qe[Tt];kt.updateParameters(_e);const Dt=(Zt,Ft)=>{const Jt=kt.reloadCallback;Jt&&(delete kt.reloadCallback,kt.parse(kt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Jt)),Pe(Zt,Ft)};kt.status==="parsing"?kt.reloadCallback=Dt:kt.status==="done"&&(kt.vectorTile?kt.parse(kt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Dt):Dt())}else Pe(null,void 0)}abortTile(_e,Pe){const Qe=_e.uid,Tt=this.loading[Qe];Tt&&(Tt.abort&&Tt.abort(),delete this.loading[Qe]),Pe()}removeTile(_e,Pe){const Qe=this.loaded,Tt=_e.uid;Qe&&Qe[Tt]&&delete Qe[Tt],Pe()}}class V{loadTile(_e,Pe){const{uid:Qe,encoding:Tt,rawImageData:kt,padding:Dt}=_e,Zt=ImageBitmap&&kt instanceof ImageBitmap?this.getImageData(kt,Dt):kt;Pe(null,new i.fA(Qe,Zt,Tt,Dt<1))}reloadTile(_e,Pe){Pe(null,null)}abortTile(_e,Pe){Pe()}removeTile(_e,Pe){Pe()}getImageData(_e,Pe){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(_e.width,_e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=_e.width,this.offscreenCanvas.height=_e.height,this.offscreenCanvasContext.drawImage(_e,0,0,_e.width,_e.height);const Qe=this.offscreenCanvasContext.getImageData(-Pe,-Pe,_e.width+2*Pe,_e.height+2*Pe);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Qe}}i.bs.setPbf(i.bt);class W{constructor(_e){this._mrt=new i.bs(_e.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=_e.uid,this.tileID=_e.tileID,this.source=_e.source}parse(_e,Pe){const Qe=this._mrt;this.status="parsing",this._entireBuffer=_e;try{Qe.parseHeader(_e),this._isHeaderLoaded=!0;const Tt=[];for(const kt in Qe.layers){const Dt=Qe.getLayer(kt),Zt=Dt.getDataRange(Dt.getBandList()),Ft=Qe.createDecodingTask(Zt),Jt=_e.slice(Zt.firstByte,Zt.lastByte+1),Ss=i.bs.performDecoding(Jt,Ft).then(ps=>Ft.complete(null,ps)).catch(ps=>Ft.complete(ps,null));Tt.push(Ss)}Promise.allSettled(Tt).then(()=>Pe(null,Qe)).catch(kt=>Pe(kt))}catch(Tt){Pe(Tt)}}}class G{constructor(_e){this.actor=_e,this.loading={},this.loaded={}}loadTile(_e,Pe){const Qe=_e.uid,Tt=_e.request,kt=this.loading[Qe]=new W(_e),{cancel:Dt}=i.bu(Tt,(Zt,Ft,Jt)=>{const Ss=!this.loading[Qe];if(delete this.loading[Qe],Ss||Zt||!Ft)return kt.status="done",Ss||(this.loaded[Qe]=kt),Pe(Zt);kt.parse(Ft,(ps,ur)=>{if(ps||!ur)return Pe(ps);Pe(null,ur,Jt)}),this.loaded[Qe]=kt});kt.abort=Dt}reloadTile(_e,Pe){Pe(null,void 0)}abortTile(_e,Pe){const Qe=_e.uid,Tt=this.loading[Qe];Tt&&(Tt.abort&&Tt.abort(),delete this.loading[Qe]),Pe()}removeTile(_e,Pe){const Qe=_e.uid;this.loaded[Qe]&&delete this.loaded[Qe],Pe()}decodeRasterArray(_e,Pe){i.bs.performDecoding(_e.buffer,_e.task).then(Qe=>Pe(null,Qe)).catch(Qe=>Pe(Qe))}}const J=i.fB.prototype.toGeoJSON;class ne{constructor(_e){this._feature=_e,this.extent=i.al,this.type=_e.type,this.properties=_e.tags,"id"in _e&&!isNaN(_e.id)&&(this.id=parseInt(_e.id,10))}loadGeometry(){if(this._feature.type===1){const _e=[];for(const Pe of this._feature.geometry)_e.push([new i.P(Pe[0],Pe[1])]);return _e}{const _e=[];for(const Pe of this._feature.geometry){const Qe=[];for(const Tt of Pe)Qe.push(new i.P(Tt[0],Tt[1]));_e.push(Qe)}return _e}}toGeoJSON(_e,Pe,Qe){return J.call(this,_e,Pe,Qe)}}class ie{constructor(_e,Pe){this.name=_e,this.extent=i.al,this.length=Pe.length,this._jsonFeatures=Pe}feature(_e){return new ne(this._jsonFeatures[_e])}}class ee{constructor(_e){this.layers={},this.extent=i.al;for(const Pe of Object.keys(_e))this.layers[Pe]=new ie(Pe,_e[Pe])}}const de=64/4096,oe=128;class ue{constructor(){this.features=new Map}clear(){this.features.clear()}load(_e=[],Pe){for(const Qe of _e){const Tt=Qe.id;if(Tt==null)continue;let kt=this.features.get(Tt);kt&&this.updateCache(kt,Pe),Qe.geometry?(kt=ge(Qe),this.updateCache(kt,Pe),this.features.set(Tt,kt)):this.features.delete(Tt),this.updateCache(kt,Pe)}}updateCache(_e,Pe){for(const{canonical:Qe,uid:Tt}of Object.values(Pe)){const{z:kt,x:Dt,y:Zt}=Qe;ce(_e,Math.pow(2,kt),Dt,Zt)&&delete Pe[Tt]}}getTile(_e,Pe,Qe){const Tt=Math.pow(2,_e),kt=[];for(const Dt of this.features.values())ce(Dt,Tt,Pe,Qe)&&kt.push(Se(Dt,Tt,Pe,Qe));return{features:kt}}getFeatures(){return[...this.features.values()]}}function ce({minX:rt,minY:_e,maxX:Pe,maxY:Qe},Tt,kt,Dt){return rt<(kt+1+de)/Tt&&_e<(Dt+1+de)/Tt&&Pe>(kt-de)/Tt&&Qe>(Dt-de)/Tt}function ge(rt){const{id:_e,geometry:Pe,properties:Qe}=rt;if(!Pe)return;if(Pe.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:Tt,coordinates:kt}=Pe,Dt={id:_e,type:1,geometry:[],tags:Qe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Zt=Dt.geometry;if(Tt==="Point")Te(kt,Zt,Dt);else if(Tt==="MultiPoint")for(const Ft of kt)Te(Ft,Zt,Dt);else if(Tt==="LineString")Dt.type=2,ve(kt,Zt,Dt);else if(Tt==="MultiLineString")Dt.type=2,ye(kt,Zt,Dt);else if(Tt==="Polygon")Dt.type=3,ye(kt,Zt,Dt,!0);else{if(Tt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Dt.type=3;for(const Ft of kt)ye(Ft,Zt,Dt,!0)}return Dt}function Te([rt,_e],Pe,Qe){const Tt=i.aF(rt);let kt=i.aJ(_e);kt=kt<0?0:kt>1?1:kt,Pe.push(Tt,kt),Qe.minX=Math.min(Qe.minX,Tt),Qe.minY=Math.min(Qe.minY,kt),Qe.maxX=Math.max(Qe.maxX,Tt),Qe.maxY=Math.max(Qe.maxY,kt)}function ve(rt,_e,Pe,Qe=!1,Tt=!1){const kt=[];for(const Dt of rt)Te(Dt,kt,Pe);_e.push(kt),Qe&&function(Dt,Zt){let Ft=0;for(let Jt=0,Ss=Dt.length,ps=Ss-2;Jt0===Zt)for(let Jt=0,Ss=Dt.length;Jt=Dt&&ps>=Dt||(Jt>=Dt?(Ss+=Math.round(cr*((Dt-Jt)/Dr)),Jt=Dt):ps>=Dt&&(ur=Ss+Math.round(cr*((Dt-Jt)/Dr)),ps=Dt),Ss>=Dt&&ur>=Dt||(Ss>=Dt?(Jt+=Math.round(Dr*((Dt-Ss)/cr)),Ss=Dt):ur>=Dt&&(ps=Jt+Math.round(Dr*((Dt-Ss)/cr)),ur=Dt),Zt&&Jt===Zt[Zt.length-1][0]&&Ss===Zt[Zt.length-1][1]||(Zt=[[Jt,Ss]],Tt.push(Zt)),Zt.push([ps,ur])))))}}function Ae(rt,_e,Pe,Qe,Tt){const kt=(Pe-de)/_e,Dt=(Qe-de)/_e,Zt=(Pe+1+de)/_e,Ft=(Qe+1+de)/_e;function Jt(ur,Dr){let cr=0;return urZt&&(cr|=2),DrFt&&(cr|=8),cr}let Ss=[];for(let ur=1;ur<=8;ur*=2){let Dr=rt[rt.length-2],cr=rt[rt.length-1],jn=!(Jt(Dr,cr)&ur);for(let kn=0;kn>31}function wt(rt,_e){const{geometry:Pe,type:Qe}=rt;let Tt=0,kt=0;if(Qe===1){_e.writeVarint(De(1,Pe.length));for(const Dt of Pe){const Zt=Dt[0]-Tt,Ft=Dt[1]-kt;_e.writeVarint(Ge(Zt)),_e.writeVarint(Ge(Ft)),Tt+=Zt,kt+=Ft}}else for(const Dt of Pe){_e.writeVarint(De(1,1));const Zt=Dt.length-(Qe===3?1:0);for(let Ft=0;Ftrt},he=Math.fround||(We=new Float32Array(1),rt=>(We[0]=+rt,We[0]));var We;const et=3,Ye=5,ke=6;class at{constructor(_e){this.options=Object.assign(Object.create(st),_e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(_e){const{log:Pe,minZoom:Qe,maxZoom:Tt}=this.options;Pe&&console.time("total time");const kt=`prepare ${_e.length} points`;Pe&&console.time(kt),this.points=_e;const Dt=[];for(let Ft=0;Ft<_e.length;Ft++){const Jt=_e[Ft];if(!Jt.geometry)continue;const[Ss,ps]=Jt.geometry.coordinates,ur=he(dt(Ss)),Dr=he(tt(ps));Dt.push(ur,Dr,1/0,Ft,-1,1),this.options.reduce&&Dt.push(0)}let Zt=this.trees[Tt+1]=this._createTree(Dt);Pe&&console.timeEnd(kt);for(let Ft=Tt;Ft>=Qe;Ft--){const Jt=+Date.now();Zt=this.trees[Ft]=this._createTree(this._cluster(Zt,Ft)),Pe&&console.log("z%d: %d clusters in %dms",Ft,Zt.numItems,+Date.now()-Jt)}return Pe&&console.timeEnd("total time"),this}getClusters(_e,Pe){let Qe=((_e[0]+180)%360+360)%360-180;const Tt=Math.max(-90,Math.min(90,_e[1]));let kt=_e[2]===180?180:((_e[2]+180)%360+360)%360-180;const Dt=Math.max(-90,Math.min(90,_e[3]));if(_e[2]-_e[0]>=360)Qe=-180,kt=180;else if(Qe>kt){const ps=this.getClusters([Qe,Tt,180,Dt],Pe),ur=this.getClusters([-180,Tt,kt,Dt],Pe);return ps.concat(ur)}const Zt=this.trees[this._limitZoom(Pe)],Ft=Zt.range(dt(Qe),tt(Dt),dt(kt),tt(Tt)),Jt=Zt.data,Ss=[];for(const ps of Ft){const ur=this.stride*ps;Ss.push(Jt[ur+Ye]>1?Fe(Jt,ur,this.clusterProps):this.points[Jt[ur+et]])}return Ss}getChildren(_e){const Pe=this._getOriginId(_e),Qe=this._getOriginZoom(_e),Tt="No cluster with the specified id.",kt=this.trees[Qe];if(!kt)throw new Error(Tt);const Dt=kt.data;if(Pe*this.stride>=Dt.length)throw new Error(Tt);const Zt=this.options.radius/(this.options.extent*Math.pow(2,Qe-1)),Ft=kt.within(Dt[Pe*this.stride],Dt[Pe*this.stride+1],Zt),Jt=[];for(const Ss of Ft){const ps=Ss*this.stride;Dt[ps+4]===_e&&Jt.push(Dt[ps+Ye]>1?Fe(Dt,ps,this.clusterProps):this.points[Dt[ps+et]])}if(Jt.length===0)throw new Error(Tt);return Jt}getLeaves(_e,Pe,Qe){const Tt=[];return this._appendLeaves(Tt,_e,Pe=Pe||10,Qe=Qe||0,0),Tt}getTile(_e,Pe,Qe){const Tt=this.trees[this._limitZoom(_e)],kt=Math.pow(2,_e),{extent:Dt,radius:Zt}=this.options,Ft=Zt/Dt,Jt=(Qe-Ft)/kt,Ss=(Qe+1+Ft)/kt,ps={features:[]};return this._addTileFeatures(Tt.range((Pe-Ft)/kt,Jt,(Pe+1+Ft)/kt,Ss),Tt.data,Pe,Qe,kt,ps),Pe===0&&this._addTileFeatures(Tt.range(1-Ft/kt,Jt,1,Ss),Tt.data,kt,Qe,kt,ps),Pe===kt-1&&this._addTileFeatures(Tt.range(0,Jt,Ft/kt,Ss),Tt.data,-1,Qe,kt,ps),ps.features.length?ps:null}getClusterExpansionZoom(_e){let Pe=this._getOriginZoom(_e)-1;for(;Pe<=this.options.maxZoom;){const Qe=this.getChildren(_e);if(Pe++,Qe.length!==1)break;_e=Qe[0].properties.cluster_id}return Pe}_appendLeaves(_e,Pe,Qe,Tt,kt){const Dt=this.getChildren(Pe);for(const Zt of Dt){const Ft=Zt.properties;if(Ft&&Ft.cluster?kt+Ft.point_count<=Tt?kt+=Ft.point_count:kt=this._appendLeaves(_e,Ft.cluster_id,Qe,Tt,kt):kt1;let Ss,ps,ur;if(Jt)Ss=it(Pe,Ft,this.clusterProps),ps=Pe[Ft],ur=Pe[Ft+1];else{const jn=this.points[Pe[Ft+et]];Ss=jn.properties;const[kn,yn]=jn.geometry.coordinates;ps=dt(kn),ur=tt(yn)}const Dr={type:1,geometry:[[Math.round(this.options.extent*(ps*kt-Qe)),Math.round(this.options.extent*(ur*kt-Tt))]],tags:Ss};let cr;cr=Jt||this.options.generateId?Pe[Ft+et]:this.points[Pe[Ft+et]].id,cr!==void 0&&(Dr.id=cr),Dt.features.push(Dr)}}_limitZoom(_e){return Math.max(this.options.minZoom,Math.min(Math.floor(+_e),this.options.maxZoom+1))}_cluster(_e,Pe){const{radius:Qe,extent:Tt,reduce:kt,minPoints:Dt}=this.options,Zt=Qe/(Tt*Math.pow(2,Pe)),Ft=_e.data,Jt=[],Ss=this.stride;for(let ps=0;psPe&&(kn+=Ft[aa+Ye])}if(kn>jn&&kn>=Dt){let yn,aa=ur*jn,so=Dr*jn,Po=-1;const Pa=(ps/Ss<<5)+(Pe+1)+this.points.length;for(const Fo of cr){const Ki=Fo*Ss;if(Ft[Ki+2]<=Pe)continue;Ft[Ki+2]=Pe;const pa=Ft[Ki+Ye];aa+=Ft[Ki]*pa,so+=Ft[Ki+1]*pa,Ft[Ki+4]=Pa,kt&&(yn||(yn=this._map(Ft,ps,!0),Po=this.clusterProps.length,this.clusterProps.push(yn)),kt(yn,this._map(Ft,Ki)))}Ft[ps+4]=Pa,Jt.push(aa/kn,so/kn,1/0,Pa,-1,kn),kt&&Jt.push(Po)}else{for(let yn=0;yn1)for(const yn of cr){const aa=yn*Ss;if(!(Ft[aa+2]<=Pe)){Ft[aa+2]=Pe;for(let so=0;so>5}_getOriginZoom(_e){return(_e-this.points.length)%32}_map(_e,Pe,Qe){if(_e[Pe+Ye]>1){const Dt=this.clusterProps[_e[Pe+ke]];return Qe?Object.assign({},Dt):Dt}const Tt=this.points[_e[Pe+et]].properties,kt=this.options.map(Tt);return Qe&&kt===Tt?Object.assign({},kt):kt}}function Fe(rt,_e,Pe){return{type:"Feature",id:rt[_e+et],properties:it(rt,_e,Pe),geometry:{type:"Point",coordinates:[(Qe=rt[_e],360*(Qe-.5)),ut(rt[_e+1])]}};var Qe}function it(rt,_e,Pe){const Qe=rt[_e+Ye],Tt=Qe>=1e4?`${Math.round(Qe/1e3)}k`:Qe>=1e3?Math.round(Qe/100)/10+"k":Qe,kt=rt[_e+ke],Dt=kt===-1?{}:Object.assign({},Pe[kt]);return Object.assign(Dt,{cluster:!0,cluster_id:rt[_e+et],point_count:Qe,point_count_abbreviated:Tt})}function dt(rt){return rt/360+.5}function tt(rt){const _e=Math.sin(rt*Math.PI/180),Pe=.5-.25*Math.log((1+_e)/(1-_e))/Math.PI;return Pe<0?0:Pe>1?1:Pe}function ut(rt){const _e=(180-360*rt)*Math.PI/180;return 360*Math.atan(Math.exp(_e))/Math.PI-90}function xt(rt,_e,Pe,Qe){let Tt=Qe;const kt=_e+(Pe-_e>>1);let Dt,Zt=Pe-_e;const Ft=rt[_e],Jt=rt[_e+1],Ss=rt[Pe],ps=rt[Pe+1];for(let ur=_e+3;urTt)Dt=ur,Tt=Dr;else if(Dr===Tt){const cr=Math.abs(ur-kt);crQe&&(Dt-_e>3&&xt(rt,_e,Dt,Qe),rt[Dt+2]=Tt,Pe-Dt>3&&xt(rt,Dt,Pe,Qe))}function _t(rt,_e,Pe,Qe,Tt,kt){let Dt=Tt-Pe,Zt=kt-Qe;if(Dt!==0||Zt!==0){const Ft=((rt-Pe)*Dt+(_e-Qe)*Zt)/(Dt*Dt+Zt*Zt);Ft>1?(Pe=Tt,Qe=kt):Ft>0&&(Pe+=Dt*Ft,Qe+=Zt*Ft)}return Dt=rt-Pe,Zt=_e-Qe,Dt*Dt+Zt*Zt}function qe(rt,_e,Pe,Qe){const Tt={id:rt??null,type:_e,geometry:Pe,tags:Qe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(_e==="Point"||_e==="MultiPoint"||_e==="LineString")Lt(Tt,Pe);else if(_e==="Polygon")Lt(Tt,Pe[0]);else if(_e==="MultiLineString")for(const kt of Pe)Lt(Tt,kt);else if(_e==="MultiPolygon")for(const kt of Pe)Lt(Tt,kt[0]);return Tt}function Lt(rt,_e){for(let Pe=0;Pe<_e.length;Pe+=3)rt.minX=Math.min(rt.minX,_e[Pe]),rt.minY=Math.min(rt.minY,_e[Pe+1]),rt.maxX=Math.max(rt.maxX,_e[Pe]),rt.maxY=Math.max(rt.maxY,_e[Pe+1])}function Rt(rt,_e,Pe,Qe){if(!_e.geometry)return;const Tt=_e.geometry.coordinates;if(Tt&&Tt.length===0)return;const kt=_e.geometry.type,Dt=Math.pow(Pe.tolerance/((1<0&&(Dt+=Qe?(Tt*Ss-Jt*kt)/2:Math.sqrt(Math.pow(Jt-Tt,2)+Math.pow(Ss-kt,2))),Tt=Jt,kt=Ss}const Zt=_e.length-3;_e[2]=1,xt(_e,0,Zt,Pe),_e[Zt+2]=1,_e.size=Math.abs(Dt),_e.start=0,_e.end=_e.size}function ss(rt,_e,Pe,Qe){for(let Tt=0;Tt1?1:Pe}function yt(rt,_e,Pe,Qe,Tt,kt,Dt,Zt){if(Qe/=_e,kt>=(Pe/=_e)&&Dt=Qe)return null;const Ft=[];for(const Jt of rt){const Ss=Jt.geometry;let ps=Jt.type;const ur=Tt===0?Jt.minX:Jt.minY,Dr=Tt===0?Jt.maxX:Jt.maxY;if(ur>=Pe&&Dr=Qe)continue;let cr=[];if(ps==="Point"||ps==="MultiPoint")bs(Ss,cr,Pe,Qe,Tt);else if(ps==="LineString")gr(Ss,cr,Pe,Qe,Tt,!1,Zt.lineMetrics);else if(ps==="MultiLineString")na(Ss,cr,Pe,Qe,Tt,!1);else if(ps==="Polygon")na(Ss,cr,Pe,Qe,Tt,!0);else if(ps==="MultiPolygon")for(const jn of Ss){const kn=[];na(jn,kn,Pe,Qe,Tt,!0),kn.length&&cr.push(kn)}if(cr.length){if(Zt.lineMetrics&&ps==="LineString"){for(const jn of cr)Ft.push(qe(Jt.id,ps,jn,Jt.tags));continue}ps!=="LineString"&&ps!=="MultiLineString"||(cr.length===1?(ps="LineString",cr=cr[0]):ps="MultiLineString"),ps!=="Point"&&ps!=="MultiPoint"||(ps=cr.length===3?"Point":"MultiPoint"),Ft.push(qe(Jt.id,ps,cr,Jt.tags))}}return Ft.length?Ft:null}function bs(rt,_e,Pe,Qe,Tt){for(let kt=0;kt=Pe&&Dt<=Qe&&za(_e,rt[kt],rt[kt+1],rt[kt+2])}}function gr(rt,_e,Pe,Qe,Tt,kt,Dt){let Zt=Br(rt);const Ft=Tt===0?go:Ia;let Jt,Ss,ps=rt.start;for(let kn=0;knPe&&(Ss=Ft(Zt,yn,aa,Po,Pa,Pe),Dt&&(Zt.start=ps+Jt*Ss)):Fo>Qe?Ki=Pe&&(Ss=Ft(Zt,yn,aa,Po,Pa,Pe),pa=!0),Ki>Qe&&Fo<=Qe&&(Ss=Ft(Zt,yn,aa,Po,Pa,Qe),pa=!0),!kt&&pa&&(Dt&&(Zt.end=ps+Jt*Ss),_e.push(Zt),Zt=Br(rt)),Dt&&(ps+=Jt)}let ur=rt.length-3;const Dr=rt[ur],cr=rt[ur+1],jn=Tt===0?Dr:cr;jn>=Pe&&jn<=Qe&&za(Zt,Dr,cr,rt[ur+2]),ur=Zt.length-3,kt&&ur>=3&&(Zt[ur]!==Zt[0]||Zt[ur+1]!==Zt[1])&&za(Zt,Zt[0],Zt[1],Zt[2]),Zt.length&&_e.push(Zt)}function Br(rt){const _e=[];return _e.size=rt.size,_e.start=rt.start,_e.end=rt.end,_e}function na(rt,_e,Pe,Qe,Tt,kt){for(const Dt of rt)gr(Dt,_e,Pe,Qe,Tt,kt,!1)}function za(rt,_e,Pe,Qe){rt.push(_e,Pe,Qe)}function go(rt,_e,Pe,Qe,Tt,kt){const Dt=(kt-_e)/(Qe-_e);return za(rt,kt,Pe+(Tt-Pe)*Dt,1),Dt}function Ia(rt,_e,Pe,Qe,Tt,kt){const Dt=(kt-Pe)/(Tt-Pe);return za(rt,_e+(Qe-_e)*Dt,kt,1),Dt}function nn(rt,_e){const Pe=[];for(let Qe=0;Qe0&&_e.size<(Tt?Dt:Qe))return void(Pe.numPoints+=_e.length/3);const Zt=[];for(let Ft=0;Ft<_e.length;Ft+=3)(Qe===0||_e[Ft+2]>Dt)&&(Pe.numSimplified++,Zt.push(_e[Ft],_e[Ft+1])),Pe.numPoints++;Tt&&function(Ft,Jt){let Ss=0;for(let ps=0,ur=Ft.length,Dr=ur-2;ps0===Jt)for(let ps=0,ur=Ft.length;ps24)throw new Error("maxZoom should be in the 0-24 range");if(Pe.promoteId&&Pe.generateId)throw new Error("promoteId and generateId cannot be used together.");let Tt=function(kt,Dt){const Zt=[];if(kt.type==="FeatureCollection")for(let Ft=0;Ft1&&console.time("creation"),Dr=this.tiles[ur]=Pr(_e,Pe,Qe,Tt,Jt),this.tileCoords.push({z:Pe,x:Qe,y:Tt}),Ss)){Ss>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Pe,Qe,Tt,Dr.numFeatures,Dr.numPoints,Dr.numSimplified),console.timeEnd("creation"));const pa=`z${Pe}`;this.stats[pa]=(this.stats[pa]||0)+1,this.total++}if(Dr.source=_e,kt==null){if(Pe===Jt.indexMaxZoom||Dr.numPoints<=Jt.indexMaxPoints)continue}else{if(Pe===Jt.maxZoom||Pe===kt)continue;if(kt!=null){const pa=kt-Pe;if(Qe!==Dt>>pa||Tt!==Zt>>pa)continue}}if(Dr.source=null,_e.length===0)continue;Ss>1&&console.time("clipping");const cr=.5*Jt.buffer/Jt.extent,jn=.5-cr,kn=.5+cr,yn=1+cr;let aa=null,so=null,Po=null,Pa=null,Fo=yt(_e,ps,Qe-cr,Qe+kn,0,Dr.minX,Dr.maxX,Jt),Ki=yt(_e,ps,Qe+jn,Qe+yn,0,Dr.minX,Dr.maxX,Jt);_e=null,Fo&&(aa=yt(Fo,ps,Tt-cr,Tt+kn,1,Dr.minY,Dr.maxY,Jt),so=yt(Fo,ps,Tt+jn,Tt+yn,1,Dr.minY,Dr.maxY,Jt),Fo=null),Ki&&(Po=yt(Ki,ps,Tt-cr,Tt+kn,1,Dr.minY,Dr.maxY,Jt),Pa=yt(Ki,ps,Tt+jn,Tt+yn,1,Dr.minY,Dr.maxY,Jt),Ki=null),Ss>1&&console.timeEnd("clipping"),Ft.push(aa||[],Pe+1,2*Qe,2*Tt),Ft.push(so||[],Pe+1,2*Qe,2*Tt+1),Ft.push(Po||[],Pe+1,2*Qe+1,2*Tt),Ft.push(Pa||[],Pe+1,2*Qe+1,2*Tt+1)}}getTile(_e,Pe,Qe){_e=+_e,Pe=+Pe,Qe=+Qe;const Tt=this.options,{extent:kt,debug:Dt}=Tt;if(_e<0||_e>24)return null;const Zt=1<<_e,Ft=li(_e,Pe=Pe+Zt&Zt-1,Qe);if(this.tiles[Ft])return lr(this.tiles[Ft],kt);Dt>1&&console.log("drilling down to z%d-%d-%d",_e,Pe,Qe);let Jt,Ss=_e,ps=Pe,ur=Qe;for(;!Jt&&Ss>0;)Ss--,ps>>=1,ur>>=1,Jt=this.tiles[li(Ss,ps,ur)];return Jt&&Jt.source?(Dt>1&&(console.log("found parent tile z%d-%d-%d",Ss,ps,ur),console.time("drilling down")),this.splitTile(Jt.source,Ss,ps,ur,_e,Pe,Qe),Dt>1&&console.timeEnd("drilling down"),this.tiles[Ft]?lr(this.tiles[Ft],kt):null):null}}function li(rt,_e,Pe){return 32*((1<Jt.tags&&"3d_elevation_id"in Jt.tags&&"source"in Jt.tags&&Jt.tags.source==="elevation",kt=Qe.features.filter(Jt=>Tt(Jt));let Dt={_geojsonTileLayer:Qe.features};kt.length>0&&(Dt={_geojsonTileLayer:Qe.features.filter(Jt=>!Tt(Jt)),hd_road_elevation:kt});const Zt=new ee(Dt),Ft=function(Jt){const Ss=new i.bt;for(const ps of Object.keys(Jt))Ss.writeMessage(3,Ee,{name:ps,features:Jt[ps]});return Ss.finish()}(Dt).buffer;_e(null,{vectorTile:Zt,rawData:Ft})}class Oi extends ${constructor(_e,Pe,Qe,Tt,kt,Dt,Zt){super(_e,Pe,Qe,Tt,kt,Or,Zt),Dt&&(this.loadGeoJSON=Dt),this._dynamicIndex=new ue}loadData(_e,Pe){const Qe=_e&&_e.request,Tt=Qe&&Qe.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(_e,(kt,Dt)=>{if(kt||!Dt)return Pe(kt);if(typeof Dt!="object")return Pe(new Error(`Input data given to '${_e.source}' is not a valid GeoJSON object.`));{try{if(_e.filter){const Ft=i.U(_e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Ft.result==="error")throw new Error(Ft.value.map(Jt=>`${Jt.key}: ${Jt.message}`).join(", "));Dt.features=Dt.features.filter(Jt=>Ft.value.evaluate({zoom:0},Jt))}_e.dynamic?(Dt.type==="Feature"&&(Dt={type:"FeatureCollection",features:[Dt]}),_e.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Dt.features,this.loaded),_e.cluster&&(Dt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=_e.cluster?new at(function({superclusterOptions:Ft,clusterProperties:Jt}){if(!Jt||!Ft)return Ft;const Ss={},ps={},ur={accumulated:null,zoom:0},Dr={properties:null},cr=Object.keys(Jt);for(const jn of cr){const[kn,yn]=Jt[jn],aa=i.U(yn),so=i.U(typeof kn=="string"?[kn,["accumulated"],["get",jn]]:kn);Ss[jn]=aa.value,ps[jn]=so.value}return Ft.map=jn=>{Dr.properties=jn;const kn={};for(const yn of cr)kn[yn]=Ss[yn].evaluate(ur,Dr);return kn},Ft.reduce=(jn,kn)=>{Dr.properties=kn;for(const yn of cr)ur.accumulated=jn[yn],jn[yn]=ps[yn].evaluate(ur,Dr)},Ft}(_e)).load(Dt.features):_e.dynamic?this._dynamicIndex:function(Ft,Jt){return new zi(Ft,Jt)}(Dt,_e.geojsonVtOptions)}catch(Ft){return Pe(Ft)}const Zt={};if(Tt){const Ft=d(Qe);Ft&&(Zt.resourceTiming={},Zt.resourceTiming[_e.source]=JSON.parse(JSON.stringify(Ft)))}Pe(null,Zt)}})}reloadTile(_e,Pe){const Qe=this.loaded;return Qe&&Qe[_e.uid]?_e.partial?Pe(null,void 0):super.reloadTile(_e,Pe):this.loadTile(_e,Pe)}loadGeoJSON(_e,Pe){if(_e.request)i.m(_e.request,Pe);else{if(typeof _e.data!="string")return Pe(new Error(`Input data given to '${_e.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return Pe(null,JSON.parse(_e.data))}catch{return Pe(new Error(`Input data given to '${_e.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(_e,Pe){try{Pe(null,this._geoJSONIndex.getClusterExpansionZoom(_e.clusterId))}catch(Qe){Pe(Qe)}}getClusterChildren(_e,Pe){try{Pe(null,this._geoJSONIndex.getChildren(_e.clusterId))}catch(Qe){Pe(Qe)}}getClusterLeaves(_e,Pe){try{Pe(null,this._geoJSONIndex.getLeaves(_e.clusterId,_e.limit,_e.offset))}catch(Qe){Pe(Qe)}}}class Rc{constructor(_e,Pe,Qe){this.tileID=new i.aQ(_e.tileID.overscaledZ,_e.tileID.wrap,_e.tileID.canonical.z,_e.tileID.canonical.x,_e.tileID.canonical.y),this.tileZoom=_e.tileZoom,this.uid=_e.uid,this.zoom=_e.zoom,this.canonical=_e.tileID.canonical,this.pixelRatio=_e.pixelRatio,this.tileSize=_e.tileSize,this.source=_e.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=_e.projection,this.brightness=Pe,this.worldview=Qe}parse(_e,Pe,Qe,Tt){this.status="parsing";const kt=new i.aQ(Qe.tileID.overscaledZ,Qe.tileID.wrap,Qe.tileID.canonical.z,Qe.tileID.canonical.x,Qe.tileID.canonical.y),Dt=[],Zt=Pe.familiesBySource[Qe.source],Ft=new i.fn(kt,Qe.promoteId);Ft.bucketLayerIDs=[],Ft.is3DTile=!0,i.fC(_e).then(Jt=>{if(!Jt)return Tt(new Error("Could not parse tile"));const Ss=Jt.json.extensionsUsed&&Jt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Jt.json.asset.extras&&Jt.json.asset.extras.MAPBOX_mesh_features,ps=Jt.json.extensionsUsed&&Jt.json.extensionsUsed.includes("EXT_meshopt_compression"),ur=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Dr in Zt)for(const cr of Zt[Dr]){const jn=cr[0];Ft.bucketLayerIDs.push(cr.map(aa=>i.B(aa.id,aa.scope))),jn.recalculate(ur,[]);const kn=i.fD(Jt,1/i.d7(Qe.tileID.canonical)),yn=new i.fE(cr,kn,kt,Ss,ps,this.brightness,Ft,this.worldview);Ss||(yn.needsUpload=!0),Dt.push(yn),yn.evaluate(jn)}this.status="done",Tt(null,{buckets:Dt,featureIndex:Ft,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Jt=>Tt(new Error(Jt.message)))}}class Co{constructor(_e,Pe,Qe,Tt,kt,Dt,Zt,Ft){this.actor=_e,this.layerIndex=Pe,this.availableImages=Qe,this.availableModels=Tt,this.brightness=Zt,this.loading={},this.loaded={},this.worldview=Ft}loadTile(_e,Pe){const Qe=_e.uid,Tt=this.loading[Qe]=new Rc(_e,this.brightness,this.worldview);i.bu(_e.request,(kt,Dt)=>{const Zt=!this.loading[Qe];return delete this.loading[Qe],Zt||kt?(Tt.status="done",Zt||(this.loaded[Qe]=Tt),Pe(kt)):Dt&&Dt.byteLength!==0?void Tt.parse(Dt,this.layerIndex,_e,(Ft,Jt)=>{Tt.status="done",this.loaded=this.loaded||{},this.loaded[Qe]=Tt,Ft||!Jt?Pe(Ft):Pe(null,Jt)}):(Tt.status="done",this.loaded[Qe]=Tt,Pe())})}reloadTile(_e,Pe){const Qe=this.loaded,Tt=_e.uid;if(Qe&&Qe[Tt]){const kt=Qe[Tt];kt.projection=_e.projection,kt.brightness=_e.brightness;const Dt=(Zt,Ft)=>{kt.reloadCallback&&(delete kt.reloadCallback,this.loadTile(_e,Pe)),Pe(Zt,Ft)};kt.status==="parsing"?kt.reloadCallback=Dt:kt.status==="done"&&this.loadTile(_e,Pe)}}abortTile(_e,Pe){const Qe=_e.uid;this.loading[Qe]&&delete this.loading[Qe],Pe()}removeTile(_e,Pe){const Qe=this.loaded,Tt=_e.uid;Qe&&Qe[Tt]&&delete Qe[Tt],Pe()}}class Fc{constructor(_e){this.self=_e,this.actor=new i.fG(_e,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:Oi,"raster-dem":V,"raster-array":G,"batched-model":Co},this.workerSources={},this.self.registerWorkerSource=(Pe,Qe)=>{if(this.workerSourceTypes[Pe])throw new Error(`Worker source with name "${Pe}" already registered.`);this.workerSourceTypes[Pe]=Qe},this.self.registerRTLTextPlugin=Pe=>{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=Pe.applyArabicShaping,i.fH.processBidirectionalText=Pe.processBidirectionalText,i.fH.processStyledBidirectionalText=Pe.processStyledBidirectionalText;for(const Qe of this.rtlPluginParsingListeners)Qe(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(_e,Pe,Qe){delete this.layerIndexes[_e],delete this.availableImages[_e],delete this.availableModels[_e],delete this.workerSources[_e],Qe()}checkIfReady(_e,Pe,Qe){Qe()}setReferrer(_e,Pe){this.referrer=Pe}spriteLoaded(_e,Pe){this.isSpriteLoaded[_e]||(this.isSpriteLoaded[_e]={});const{scope:Qe,isLoaded:Tt}=Pe;if(this.isSpriteLoaded[_e][Qe]=Tt,this.workerSources[_e]&&this.workerSources[_e][Qe])for(const kt in this.workerSources[_e][Qe]){const Dt=this.workerSources[_e][Qe][kt];for(const Zt in Dt){const Ft=Dt[Zt];Ft instanceof $&&(Ft.isSpriteLoaded=Tt,Ft.fire(new i.z("isSpriteLoaded")))}}}setImages(_e,Pe,Qe){this.availableImages[_e]||(this.availableImages[_e]={});const{scope:Tt,images:kt}=Pe;if(this.availableImages[_e][Tt]=kt,this.workerSources[_e]&&this.workerSources[_e][Tt]){for(const Dt in this.workerSources[_e][Tt]){const Zt=this.workerSources[_e][Tt][Dt];for(const Ft in Zt)Zt[Ft].availableImages=kt}Qe()}else Qe()}setModels(_e,{scope:Pe,models:Qe},Tt){if(this.availableModels[_e]||(this.availableModels[_e]={}),this.availableModels[_e][Pe]=Qe,this.workerSources[_e]&&this.workerSources[_e][Pe]){for(const kt in this.workerSources[_e][Pe]){const Dt=this.workerSources[_e][Pe][kt];for(const Zt in Dt)Dt[Zt].availableModels=Qe}Tt()}else Tt()}setProjection(_e,Pe){this.projections[_e]=i.cm(Pe)}setBrightness(_e,Pe,Qe){this.brightness=Pe,Qe()}setWorldview(_e,Pe,Qe){this.worldview=Pe,Qe()}setLayers(_e,Pe,Qe){this.getLayerIndex(_e,Pe.scope).replace(Pe.layers,Pe.options),Qe()}updateLayers(_e,Pe,Qe){this.getLayerIndex(_e,Pe.scope).update(Pe.layers,Pe.removedIds,Pe.options),Qe()}loadTile(_e,Pe,Qe){Pe.projection=this.projections[_e]||this.defaultProjection,this.getWorkerSource(_e,Pe.type,Pe.source,Pe.scope).loadTile(Pe,Qe)}decodeRasterArray(_e,Pe,Qe){this.getWorkerSource(_e,Pe.type,Pe.source,Pe.scope).decodeRasterArray(Pe,Qe)}reloadTile(_e,Pe,Qe){Pe.projection=this.projections[_e]||this.defaultProjection,this.getWorkerSource(_e,Pe.type,Pe.source,Pe.scope).reloadTile(Pe,Qe)}abortTile(_e,Pe,Qe){this.getWorkerSource(_e,Pe.type,Pe.source,Pe.scope).abortTile(Pe,Qe)}removeTile(_e,Pe,Qe){this.getWorkerSource(_e,Pe.type,Pe.source,Pe.scope).removeTile(Pe,Qe)}removeSource(_e,Pe,Qe){if(!(this.workerSources[_e]&&this.workerSources[_e][Pe.scope]&&this.workerSources[_e][Pe.scope][Pe.type]&&this.workerSources[_e][Pe.scope][Pe.type][Pe.source]))return;const Tt=this.workerSources[_e][Pe.scope][Pe.type][Pe.source];delete this.workerSources[_e][Pe.scope][Pe.type][Pe.source],Tt.removeSource!==void 0?Tt.removeSource(Pe,Qe):Qe()}loadWorkerSource(_e,Pe,Qe){try{this.self.importScripts(Pe.url),Qe()}catch(Tt){Qe(Tt)}}syncRTLPluginState(_e,Pe,Qe){if(i.fH.isParsed())Qe(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(Qe);else try{i.fH.setState(Pe);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()?Qe(null,!0):this.rtlPluginParsingListeners.push(Qe))}catch(Tt){Qe(Tt)}}setDracoUrl(_e,Pe){this.dracoUrl=Pe}getAvailableImages(_e,Pe){this.availableImages[_e]||(this.availableImages[_e]={});let Qe=this.availableImages[_e][Pe];return Qe||(Qe=[]),Qe}getAvailableModels(_e,Pe){this.availableModels[_e]||(this.availableModels[_e]={});let Qe=this.availableModels[_e][Pe];return Qe||(Qe={}),Qe}getLayerIndex(_e,Pe){this.layerIndexes[_e]||(this.layerIndexes[_e]={});let Qe=this.layerIndexes[_e][Pe];return Qe||(Qe=this.layerIndexes[_e][Pe]=new g,Qe.scope=Pe),Qe}getWorkerSource(_e,Pe,Qe,Tt){const kt=this.workerSources;return kt[_e]||(kt[_e]={}),kt[_e][Tt]||(kt[_e][Tt]={}),kt[_e][Tt][Pe]||(kt[_e][Tt][Pe]={}),this.isSpriteLoaded[_e]||(this.isSpriteLoaded[_e]={}),kt[_e][Tt][Pe][Qe]||(kt[_e][Tt][Pe][Qe]=new this.workerSourceTypes[Pe]({send:(Dt,Zt,Ft,Jt,Ss,ps)=>this.actor.send(Dt,Zt,Ft,_e,Ss,ps),scheduler:this.actor.scheduler},this.getLayerIndex(_e,Tt),this.getAvailableImages(_e,Tt),this.getAvailableModels(_e,Tt),this.isSpriteLoaded[_e][Tt],void 0,this.brightness,this.worldview)),kt[_e][Tt][Pe][Qe]}rasterizeImagesWorker(_e,Pe,Qe){const Tt=new Map;for(const[kt,{image:Dt,imageVariant:Zt}]of Pe.tasks.entries()){const Ft=this.imageRasterizer.rasterize(Zt,Dt,Pe.scope,_e);Tt.set(kt,Ft)}Qe(void 0,Tt)}removeRasterizedImages(_e,Pe,Qe){this.imageRasterizer.removeImagesFromCacheByIds(Pe.imageIds,Pe.scope,_e),Qe()}enforceCacheSizeLimit(_e,Pe){i.fJ(Pe)}getWorkerPerformanceMetrics(_e,Pe,Qe){Qe(void 0,void 0)}}return i.fF(self)&&(self.worker=new Fc(self)),Fc}),o(["./shared"],function(i){var d="3.17.0";const h={create:"create",load:"load",fullLoad:"fullLoad"},f={mark(N){performance.mark(N)},measure(N,u,x){performance.measure(N,u,x)}};function g(N){const u=N.name.split("?")[0];return i.a(u)&&u.includes("mapbox-gl.js")?"javascript":i.a(u)&&u.includes("mapbox-gl.css")?"css":i.b(u)?"fontRange":i.c(u)?"sprite":i.i(u)?"style":i.d(u)?"tilejson":"other"}var v,_={},j=function(){if(v)return _;function N(C){return!u(C)}function u(C){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var R,F,U=new Blob([""],{type:"text/javascript"}),K=URL.createObjectURL(U);try{F=new Worker(K),R=!0}catch{R=!1}return F&&F.terminate(),URL.revokeObjectURL(K),R}()?function(){var R=document.createElement("canvas");R.width=R.height=1;var F=R.getContext("2d");if(!F)return!1;var U=F.getImageData(0,0,1,1);return U&&U.width===R.width}()?(x[P=C&&C.failIfMajorPerformanceCaveat]===void 0&&(x[P]=function(R){var F,U=function(K){var te=document.createElement("canvas"),re=Object.create(N.webGLContextAttributes);return re.failIfMajorPerformanceCaveat=K,te.getContext("webgl2",re)}(R);if(!U)return!1;try{F=U.createShader(U.VERTEX_SHADER)}catch{return!1}return!(!F||U.isContextLost())&&(U.shaderSource(F,"void main() {}"),U.compileShader(F),U.getShaderParameter(F,U.COMPILE_STATUS)===!0)}(P)),x[P]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var P}v=1,_.supported=N,_.notSupportedReason=u;var x={};return N.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function w(N,u,x){const C=document.createElement(N);return u!=null&&(C.className=u),x&&x.appendChild(C),C}function k(N,u,x){const C=document.createElementNS("http://www.w3.org/2000/svg",N);for(const P of Object.keys(u))C.setAttributeNS(null,P,String(u[P]));return x&&x.appendChild(C),C}const M=typeof document<"u"?document.documentElement&&document.documentElement.style:null,S=M&&M.userSelect!==void 0?"userSelect":"WebkitUserSelect";let E;function D(){M&&S&&(E=M[S],M[S]="none")}function L(){M&&S&&(M[S]=E)}function B(N){N.preventDefault(),N.stopPropagation(),window.removeEventListener("click",B,!0)}function $(){window.addEventListener("click",B,!0),window.setTimeout(()=>{window.removeEventListener("click",B,!0)},0)}function V(N,u){const x=N.getBoundingClientRect();return J(N,x,u)}function W(N,u){const x=N.getBoundingClientRect(),C=[];for(let P=0;Pthis._skuTokenExpiresAt}transformRequest(u,x){return this._transformRequestFn&&this._transformRequestFn(u,x)||{url:u}}normalizeStyleURL(u,x){if(!i.h(u))return u;const C=oe(u);return C.params.push(`sdk=js-${d}`),C.path=`/styles/v1${C.path}`,this._makeAPIURL(C,this._customAccessToken||x)}normalizeGlyphsURL(u,x){if(!i.h(u))return u;const C=oe(u);return C.path=`/fonts/v1${C.path}`,this._makeAPIURL(C,this._customAccessToken||x)}normalizeModelURL(u,x){if(!i.h(u))return u;const C=oe(u);return C.path=`/models/v1${C.path}`,this._makeAPIURL(C,this._customAccessToken||x)}normalizeSourceURL(u,x,C,P){if(!i.h(u))return u;const R=oe(u);return R.path=`/v4/${R.authority}.json`,R.params.push("secure"),C&&R.params.push(`language=${C}`),P&&R.params.push(`worldview=${P}`),this._makeAPIURL(R,this._customAccessToken||x)}normalizeIconsetURL(u,x){const C=oe(u);return i.h(u)?(C.path=`/styles/v1${C.path}/iconset.pbf`,this._makeAPIURL(C,this._customAccessToken||x)):ue(C)}normalizeSpriteURL(u,x,C,P){const R=oe(u);return i.h(u)?(R.path=`/styles/v1${R.path}/sprite${x}${C}`,this._makeAPIURL(R,this._customAccessToken||P)):(R.path+=`${x}${C}`,ue(R))}normalizeTileURL(u,x,C){if(this._isSkuTokenExpired()&&this._createSkuToken(),u&&!i.h(u))return u;const P=oe(u);P.path=P.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${x||C&&P.authority!=="raster"&&C===512?"@2x":""}${i.k.supported?".webp":"$1"}`),P.authority==="raster"?P.path=`/${i.e.RASTER_URL_PREFIX}${P.path}`:P.authority==="rasterarrays"?P.path=`/${i.e.RASTERARRAYS_URL_PREFIX}${P.path}`:P.authority==="3dtiles"?P.path=`/${i.e.TILES3D_URL_PREFIX}${P.path}`:(P.path=P.path.replace(/^.+\/v4\//,"/"),P.path=`/${i.e.TILE_URL_VERSION}${P.path}`);const R=this._customAccessToken||function(F){for(const U of F){const K=U.match(/^access_token=(.*)$/);if(K)return K[1]}return null}(P.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&R&&this._skuToken&&P.params.push(`sku=${this._skuToken}`),this._makeAPIURL(P,R)}canonicalizeTileURL(u,x){const C=oe(u);if(!C.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!C.path.match(/\.[\w]+$/))return u;let P="mapbox://";C.path.match(/^\/raster\/v1\//)?P+=`raster/${C.path.replace(`/${i.e.RASTER_URL_PREFIX}/`,"")}`:C.path.match(/^\/rasterarrays\/v1\//)?P+=`rasterarrays/${C.path.replace(`/${i.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:P+=`tiles/${C.path.replace(`/${i.e.TILE_URL_VERSION}/`,"")}`;let R=C.params;return x&&(R=R.filter(F=>!F.match(/^access_token=/))),R.length&&(P+=`?${R.join("&")}`),P}canonicalizeTileset(u,x){const C=!!x&&i.h(x),P=[];for(const R of u.tiles||[])i.j(R)?P.push(this.canonicalizeTileURL(R,C)):P.push(R);return P}_makeAPIURL(u,x){const C="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",P=oe(i.e.API_URL);if(u.protocol=P.protocol,u.authority=P.authority,u.protocol==="http"){const R=u.params.indexOf("secure");R>=0&&u.params.splice(R,1)}if(P.path!=="/"&&(u.path=`${P.path}${u.path}`),!i.e.REQUIRE_ACCESS_TOKEN)return ue(u);if(x=x||i.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!x)throw new Error(`An API access token is required to use Mapbox GL. ${C}`);if(x[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${C}`)}return u.params=u.params.filter(R=>R.indexOf("access_token")===-1),u.params.push(`access_token=${x||""}`),ue(u)}}const de=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function oe(N){const u=N.match(de);if(!u)throw new Error("Unable to parse URL object");return{protocol:u[1],authority:u[2],path:u[3]||"/",params:u[4]?u[4].split("&"):[]}}function ue(N){const u=N.params.length?`?${N.params.join("&")}`:"";return`${N.protocol}://${N.authority}${N.path}${u}`}const ce="mapbox.eventData";function ge(N){if(!N)return null;const u=N.split(".");if(!u||u.length!==3)return null;try{return JSON.parse(i.l(u[1]))}catch{return null}}class Te{constructor(u){this.type=u,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(u){const x=ge(i.e.ACCESS_TOKEN);let C="";return C=x&&x.u?i.f(x.u):i.e.ACCESS_TOKEN||"",u?`${ce}.${u}:${C}`:`${ce}:${C}`}fetchEventData(){const u=i.s("localStorage"),x=this.getStorageKey(),C=this.getStorageKey("uuid"),P=this.getStorageKey("uuidTimestamp");if(u)try{const R=localStorage.getItem(x);R&&(this.eventData=JSON.parse(R));const F=localStorage.getItem(C);F&&(this.anonId=F);const U=localStorage.getItem(P);U&&(this.anonIdTimestamp=Number(U));const K=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(x,JSON.stringify(this.eventData)),F&&localStorage.setItem(P,F.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(u){}postEvent(u,x,C,P){if(!i.e.EVENTS_URL)return;const R=oe(i.e.EVENTS_URL);R.params.push(`access_token=${P||i.e.ACCESS_TOKEN||""}`);const F={event:this.type,created:new Date(u).toISOString()},U=x?Object.assign(F,x):F,K={url:ue(R),headers:{"Content-Type":"text/plain"},body:JSON.stringify([U])};this.pendingRequest=i.p(K,te=>{this.pendingRequest=null,C(te),this.saveEventData(),this.processRequests(P)})}queueRequest(u,x){this.queue.push(u),this.processRequests(x)}}class ve extends Te{constructor(u){super("metrics"),u&&(this.data=u)}postMetricsEvent(u){if(!i.e.EVENTS_URL||!u&&!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},u)}processRequests(u){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:x,payload:C}=this.queue.shift();this.postEvent(x,C,()=>{},u)}}const ye=new class extends Te{constructor(N){super("appUserTurnstile"),this._customAccessToken=N}postTurnstileEvent(N,u){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(N)&&N.some(x=>i.h(x)||i.j(x))&&this.queueRequest(Date.now(),u)}processRequests(N){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const u=ge(i.e.ACCESS_TOKEN),x=u?u.u:i.e.ACCESS_TOKEN;let C=x!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),C=!0);const P=this.queue.shift();if(this.eventData.lastSuccess){const R=new Date(this.eventData.lastSuccess),F=new Date(P),U=(P-this.eventData.lastSuccess)/864e5;C=C||U>=1||U<-1||R.getDate()!==F.getDate()}else C=!0;C?this.postEvent(P,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:ne,"enabled.telemetry":!1,userId:this.anonId},R=>{R||(this.eventData.lastSuccess=P,this.eventData.tokenU=x)},N):this.processRequests()}},Se=ye.postTurnstileEvent.bind(ye),Ke=new class extends Te{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(N,u,x,C){this.skuToken=u,this.errorCb=C,i.e.EVENTS_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:N,timestamp:Date.now()},x):this.errorCb(new Error(ie)))}processRequests(N){if(this.pendingRequest||this.queue.length===0)return;const{id:u,timestamp:x}=this.queue.shift();u&&this.success[u]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(x,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:ne,skuToken:this.skuToken,userId:this.anonId},C=>{C?this.errorCb(C):u&&(this.success[u]=!0)},N))}remove(){this.errorCb=null}},Ae=Ke.postMapLoadEvent.bind(Ke),Ee=new class extends Te{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(N){let u=this.mapInstanceIdMap.get(N);return u||(u=i.u(),this.mapInstanceIdMap.set(N,u)),u}getEventId(N){const u=this.eventIdPerMapInstanceMap.get(N)||0;return this.eventIdPerMapInstanceMap.set(N,u+1),u}postStyleLoadEvent(N,u){const{map:x,style:C,importedStyles:P}=u;if(!i.e.EVENTS_URL||!N&&!i.e.ACCESS_TOKEN)return;const R=this.getMapInstanceId(x),F={mapInstanceId:R,eventId:this.getEventId(R),style:C};P.length&&(F.importedStyles=P),this.queueRequest({timestamp:Date.now(),payload:F},N)}processRequests(N){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:u,payload:x}=this.queue.shift();this.postEvent(u,x,()=>{},N)}},He=Ee.postStyleLoadEvent.bind(Ee),Ue=new ve({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),De=Ue.postMetricsEvent.bind(Ue),Ge=new ve({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),wt=Ge.postMetricsEvent.bind(Ge),Ie=new class extends Te{constructor(){super("gljs.performance")}postPerformanceEvent(N,u){i.e.EVENTS_URL&&(N||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:u},N)}processRequests(N){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:u,performanceData:x}=this.queue.shift(),C=function(P){const R=performance.getEntriesByType("resource"),F=performance.getEntriesByType("mark"),U=function(fe){const Ne={};if(fe){for(const we in fe)if(we!=="other")for(const Re of fe[we]){const Le=`${we}ResolveRangeMin`,Ze=`${we}ResolveRangeMax`,nt=`${we}RequestCount`,Xe=`${we}RequestCachedCount`;Ne[Le]=Math.min(Ne[Le]||1/0,Re.startTime),Ne[Ze]=Math.max(Ne[Ze]||-1/0,Re.responseEnd);const Mt=gt=>{Ne[gt]===void 0&&(Ne[gt]=0),++Ne[gt]};Re.transferSize!==void 0&&Re.transferSize===0&&Mt(Xe),Mt(nt)}}return Ne}(function(fe,Ne){const we={};if(fe)for(const Re of fe){const Le=Ne(Re);we[Le]===void 0&&(we[Le]=[]),we[Le].push(Re)}return we}(R,g)),K=window.devicePixelRatio,te=navigator.connection||navigator.mozConnection||navigator.webkitConnection,re=te?te.effectiveType:void 0,pe={counters:[],metadata:[],attributes:[]},me=(fe,Ne,we)=>{we!=null&&fe.push({name:Ne,value:we.toString()})};for(const fe in U)me(pe.counters,fe,U[fe]);if(P.interactionRange[0]!==1/0&&P.interactionRange[1]!==-1/0&&(me(pe.counters,"interactionRangeMin",P.interactionRange[0]),me(pe.counters,"interactionRangeMax",P.interactionRange[1])),F)for(const fe of Object.values(h)){const Ne=F.find(we=>we.name===fe);Ne&&me(pe.counters,fe,Ne.startTime)}return me(pe.counters,"visibilityHidden",P.visibilityHidden),me(pe.attributes,"style",function(fe){if(fe)for(const Ne of fe){const we=Ne.name.split("?")[0];if(i.i(we)){const Re=we.split("/").slice(-2);if(Re.length===2)return`mapbox://styles/${Re[0]}/${Re[1]}`}}}(R)),me(pe.attributes,"terrainEnabled",P.terrainEnabled?"true":"false"),me(pe.attributes,"fogEnabled",P.fogEnabled?"true":"false"),me(pe.attributes,"projection",P.projection),me(pe.attributes,"zoom",P.zoom),me(pe.metadata,"devicePixelRatio",K),me(pe.metadata,"connectionEffectiveType",re),me(pe.metadata,"navigatorUserAgent",navigator.userAgent),me(pe.metadata,"screenWidth",window.screen.width),me(pe.metadata,"screenHeight",window.screen.height),me(pe.metadata,"windowWidth",window.innerWidth),me(pe.metadata,"windowHeight",window.innerHeight),me(pe.metadata,"mapWidth",P.width/K),me(pe.metadata,"mapHeight",P.height/K),me(pe.metadata,"webglRenderer",P.renderer),me(pe.metadata,"webglVendor",P.vendor),me(pe.metadata,"sdkVersion",d),me(pe.metadata,"sdkIdentifier","mapbox-gl-js"),pe}(x);for(const P of C.metadata);for(const P of C.counters);for(const P of C.attributes);this.postEvent(u,C,()=>{},N)}},st=Ie.postPerformanceEvent.bind(Ie),he=new class extends Te{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(N,u,x,C){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const P=oe(i.e.API_URL+i.e.SESSION_PATH);P.params.push(`sku=${u||""}`),P.params.push(`access_token=${C||i.e.ACCESS_TOKEN||""}`);const R={url:ue(P),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(R,F=>{this.pendingRequest=null,x(F),this.saveEventData(),this.processRequests(C)})}getSessionAPI(N,u,x,C){this.skuToken=u,this.errorCb=C,i.e.SESSION_PATH&&i.e.API_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:N,timestamp:Date.now()},x):this.errorCb(new Error(ie)))}processRequests(N){if(this.pendingRequest||this.queue.length===0)return;const{id:u,timestamp:x}=this.queue.shift();u&&this.success[u]||this.getSession(x,this.skuToken,C=>{C?this.errorCb(C):u&&(this.success[u]=!0)},N)}remove(){this.errorCb=null}},We=he.getSessionAPI.bind(he),et=new Set;function Ye(N,u){u?et.add(N):et.delete(N)}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(u,x){this._updatedSourceCaches[u]=x,this.setDirty()}discardSourceCacheUpdate(u){delete this._updatedSourceCaches[u]}updateLayer(u){const x=u.scope;this._updatedLayers[x]=this._updatedLayers[x]||new Set,this._updatedLayers[x].add(u.id),this.setDirty()}removeLayer(u){const x=u.scope;this._removedLayers[x]=this._removedLayers[x]||{},this._updatedLayers[x]=this._updatedLayers[x]||new Set,this._removedLayers[x][u.id]=u,this._updatedLayers[x].delete(u.id),this._updatedPaintProps.delete(u.fqid),this.setDirty()}getRemovedLayer(u){return this._removedLayers[u.scope]?this._removedLayers[u.scope][u.id]:null}discardLayerRemoval(u){this._removedLayers[u.scope]&&delete this._removedLayers[u.scope][u.id]}getLayerUpdatesByScope(){const u={};for(const x in this._updatedLayers)u[x]=u[x]||{},u[x].updatedIds=Array.from(this._updatedLayers[x].values());for(const x in this._removedLayers)u[x]=u[x]||{},u[x].removedIds=Object.keys(this._removedLayers[x]);return u}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(u){this._updatedPaintProps.add(u.fqid),this.setDirty()}getUpdatedImages(u){return this._updatedImages[u]?Array.from(this._updatedImages[u].values()):[]}updateImage(u,x){this._updatedImages[x]=this._updatedImages[x]||new Set,this._updatedImages[x].add(i.I.toString(u)),this.setDirty()}resetUpdatedImages(u){this._updatedImages[u]&&this._updatedImages[u].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function at(N){const{userImage:u}=N;return!!(u&&u.render&&u.render())&&(N.data.replace(new Uint8Array(u.data.buffer)),!0)}class Fe extends i.E{constructor(u){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=u,u!=="raster"&&i.r()&&(this.imageRasterizerDispatcher=new i.D(i.t(),this,"Image Rasterizer Worker",1))}addScope(u){this.loaded.set(u,!1),this.imageProviders.set(u,new Map),this.images.set(u,new Map),this.updatedImages.set(u,new Set),this.callbackDispatchedThisFrame.set(u,new Set),this.patterns.set(u,new Map),this.atlasImage.set(u,new i.q({width:1,height:1}))}removeScope(u){this.loaded.delete(u),this.imageProviders.delete(u),this.images.delete(u),this.updatedImages.delete(u),this.callbackDispatchedThisFrame.delete(u),this.patterns.delete(u),this.atlasImage.delete(u);const x=this.atlasTexture.get(u);x&&(x.destroy(),this.atlasTexture.delete(u))}addImageProvider(u,x){this.imageProviders.has(x)||this.imageProviders.set(x,new Map),this.imageProviders.get(x).set(u.id,u)}removeImageProvider(u,x){this.imageProviders.has(x)&&this.imageProviders.get(x).delete(u)}getPendingImageProviders(){const u=[];for(const x of this.imageProviders.values())for(const C of x.values())C.hasPendingRequests()&&u.push(C);return u}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new i.x),this._imageRasterizer}isLoaded(){for(const u of this.loaded.keys())if(!this.loaded.get(u))return!1;return!0}setLoaded(u,x){if(this.loaded.get(x)!==u&&(this.loaded.set(x,u),u)){for(const{ids:C,callback:P}of this.requestors)this._notify(C,x,P);this.requestors=[]}}hasImage(u,x){return!!this.getImage(u,x)}getImage(u,x){return this.images.get(x).get(u.toString())}addImage(u,x,C){this._validate(u,C)&&this.images.get(x).set(u.toString(),C)}_validate(u,x){let C=!0;return this._validateStretch(x.stretchX,x.data&&x.data.width)||(this.fire(new i.y(new Error(`Image "${u.name}" has invalid "stretchX" value`))),C=!1),this._validateStretch(x.stretchY,x.data&&x.data.height)||(this.fire(new i.y(new Error(`Image "${u.name}" has invalid "stretchY" value`))),C=!1),this._validateContent(x.content,x)||(this.fire(new i.y(new Error(`Image "${u.name}" has invalid "content" value`))),C=!1),C}_validateStretch(u,x){if(!u)return!0;let C=0;for(const P of u){if(P[0]i.I.from(x))}getImages(u,x,C){const P=[],R=[],F=this.imageProviders.get(x);for(const re of u){if(!re.iconsetId){P.push(re);continue}const pe=F.get(re.iconsetId);pe&&(this.getImage(re,x)?R.push(re):pe.addPendingRequest(re))}if(P.length===0)return void this._notify(R,x,C);let U=!0;const K=!!this.loaded.get(x),te=this.images.get(x);if(!K)for(const re of P)te.has(re.toString())||(U=!1);K||U?this._notify(P,x,C):this.requestors.push({ids:P,scope:x,callback:C})}rasterizeImages(u,x){const C=new Map,{tasks:P,scope:R}=u;for(const[F,U]of P.entries()){const K=this.getImage(U.id,R);K&&C.set(F,{image:K,imageVariant:U})}this._rasterizeImages(R,C,x)}_rasterizeImages(u,x,C){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:x,scope:u},C);else{const P=new Map;for(const[R,{image:F,imageVariant:U}]of x.entries())P.set(R,this.imageRasterizer.rasterize(U,F,u,0));C(void 0,P)}}getUpdatedImages(u){return this.updatedImages.get(u)||new Set}_notify(u,x,C){const P=this.images.get(x),R=new Map;for(const F of u){if(!P.get(F.toString())){if(F.iconsetId)continue;this.fire(new i.z("styleimagemissing",{id:F.name}))}const U=P.get(F.toString());if(!U){i.w(`Image "${F.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 K={data:U.usvg?null:U.data.clone(),pixelRatio:U.pixelRatio,sdf:U.sdf,usvg:U.usvg,version:U.version,stretchX:U.stretchX,stretchY:U.stretchY,content:U.content,hasRenderCallback:!!(U.userImage&&U.userImage.render)};U.usvg&&Object.assign(K,{width:U.icon.usvg_tree.width,height:U.icon.usvg_tree.height}),R.set(i.I.toString(F),K)}C(null,R)}getPixelSize(u){const{width:x,height:C}=this.atlasImage.get(u);return{width:x,height:C}}getPattern(u,x,C){const P=u.toString(),R=this.patterns.get(x),F=R.get(P),U=this.getImage(u,x);if(!U)return null;if(F){if(F.position.version===U.version)return F.position;F.position.version=U.version}else{if(U.usvg&&!U.data){const K=this.getPatternInFlightId(P,x);if(this.patternsInFlight.has(K))return null;this.patternsInFlight.add(K);const te=new i.A(u).scaleSelf(i.o.devicePixelRatio),re=new Map([[te.toString(),{image:U,imageVariant:te}]]);return this._rasterizeImages(x,re,(pe,me)=>this.storePatternImage(te,x,U,C,me)),null}this.storePattern(u,x,U)}return this._updatePatternAtlas(x,C),R.get(P).position}getPatternInFlightId(u,x){return i.B(u,x)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(u,x,C,P,R){const F=u.toString(),U=R?R.get(F):void 0;U&&(C.data=U,this.storePattern(u.id,x,C),this._updatePatternAtlas(x,P),this.patternsInFlight.delete(this.getPatternInFlightId(u.id.toString(),x)))}storePattern(u,x,C){const P={w:C.data.width+2*i.C,h:C.data.height+2*i.C,x:0,y:0},R=new i.F(P,C,i.C);this.patterns.get(x).set(u.toString(),{bin:P,position:R})}destroyAtlasTextures(){for(const u of this.atlasTexture.values())u&&u.destroy();this.atlasTexture.clear()}bind(u,x){const C=u.gl;let P=this.atlasTexture.get(x);P?this.dirty&&(P.update(this.atlasImage.get(x)),this.dirty=!1):(P=new i.T(u,this.atlasImage.get(x),C.RGBA8),this.atlasTexture.set(x,P)),P.bind(C.LINEAR,C.CLAMP_TO_EDGE)}_updatePatternAtlas(u,x){const C=this.patterns.get(u),P=Array.from(C.values()).map(({bin:te})=>te),{w:R,h:F}=i.G(P),U=this.atlasImage.get(u);U.resize({width:R||1,height:F||1});const K=this.images.get(u);for(const[te,{bin:re,position:pe}]of C.entries()){let me=pe.padding;const fe=re.x+me,Ne=re.y+me,we=K.get(te).data,Re=we.width,Le=we.height;me=me>1?me-1:me,i.q.copy(we,U,{x:0,y:0},{x:fe,y:Ne},{width:Re,height:Le},x),i.q.copy(we,U,{x:0,y:Le-me},{x:fe,y:Ne-me},{width:Re,height:me},x),i.q.copy(we,U,{x:0,y:0},{x:fe,y:Ne+Le},{width:Re,height:me},x),i.q.copy(we,U,{x:Re-me,y:0},{x:fe-me,y:Ne},{width:me,height:Le},x),i.q.copy(we,U,{x:0,y:0},{x:fe+Re,y:Ne},{width:me,height:Le},x),i.q.copy(we,U,{x:Re-me,y:Le-me},{x:fe-me,y:Ne-me},{width:me,height:me},x),i.q.copy(we,U,{x:0,y:Le-me},{x:fe+Re,y:Ne-me},{width:me,height:me},x),i.q.copy(we,U,{x:0,y:0},{x:fe+Re,y:Ne+Le},{width:me,height:me},x),i.q.copy(we,U,{x:Re-me,y:0},{x:fe-me,y:Ne+Le},{width:me,height:me},x)}this.dirty=!0}beginFrame(){for(const u of this.images.keys())this.callbackDispatchedThisFrame.set(u,new Set)}dispatchRenderCallbacks(u,x){const C=this.images.get(x);for(const P of u){if(this.callbackDispatchedThisFrame.get(x).has(P.toString()))continue;this.callbackDispatchedThisFrame.get(x).add(P.toString());const R=C.get(P.toString());at(R)&&this.updateImage(P,x,R)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function it(N){const u=N.value,x=N.valueSpec,C=N.style,P=N.styleSpec,R=N.key,F=N.arrayElementValidator||nn;if(!Array.isArray(u))return[new i.V(R,u,`array expected, ${i.K(u)} found`)];if(x.length&&u.length!==x.length)return[new i.V(R,u,`array length ${x.length} expected, length ${u.length} found`)];if(x["min-length"]&&u.lengthP)return[new i.V(u,x,`${x} is greater than the maximum value ${P}`)]}return[]}function tt(N){const u=N.key,x=N.value;if(!i.H(x))return[new i.V(u,x,`object expected, ${i.K(x)} found`)];const C=N.valueSpec,P=i.J(x.type);let R,F,U,K={};const te=P!=="categorical"&&x.property===void 0,re=!te,pe=function(we){const Re=we.stops;return Array.isArray(Re)&&Array.isArray(Re[0])&&i.H(Re[0][0])}(x),me=Qt({key:N.key,value:N.value,valueSpec:N.styleSpec.function,style:N.style,styleSpec:N.styleSpec,objectElementValidators:{stops:function(we){if(P==="identity")return[new i.V(we.key,we.value,'identity function may not have a "stops" property')];let Re=[];const Le=we.value;return Re=Re.concat(it({key:we.key,value:Le,valueSpec:we.valueSpec,style:we.style,styleSpec:we.styleSpec,arrayElementValidator:fe})),Array.isArray(Le)&&Le.length===0&&Re.push(new i.V(we.key,Le,"array must have at least one stop")),Re},default:function(we){return nn({key:we.key,value:we.value,valueSpec:C,style:we.style,styleSpec:we.styleSpec})}}});return P==="identity"&&te&&me.push(new i.V(N.key,N.value,'missing required property "property"')),P==="identity"||x.stops||me.push(new i.V(N.key,N.value,'missing required property "stops"')),P==="exponential"&&C.expression&&!i.M(C)&&me.push(new i.V(N.key,N.value,"exponential functions not supported")),N.styleSpec.$version>=8&&(re&&!i.N(C)?me.push(new i.V(N.key,N.value,"property functions not supported")):te&&!i.O(C)&&me.push(new i.V(N.key,N.value,"zoom functions not supported"))),P!=="categorical"&&!pe||x.property!==void 0||me.push(new i.V(N.key,N.value,'"property" property is required')),me;function fe(we){let Re=[];const Le=we.value,Ze=we.key;if(!Array.isArray(Le))return[new i.V(Ze,Le,`array expected, ${i.K(Le)} found`)];if(Le.length!==2)return[new i.V(Ze,Le,`array length 2 expected, length ${Le.length} found`)];if(pe){if(!i.H(Le[0]))return[new i.V(Ze,Le,`object expected, ${i.K(Le[0])} found`)];const nt=Le[0];if(nt.zoom===void 0)return[new i.V(Ze,Le,"object stop key must have zoom")];if(nt.value===void 0)return[new i.V(Ze,Le,"object stop key must have value")];const Xe=i.J(nt.zoom);if(typeof Xe!="number")return[new i.V(Ze,nt.zoom,"stop zoom values must be numbers")];if(U&&U>Xe)return[new i.V(Ze,nt.zoom,"stop zoom values must appear in ascending order")];Xe!==U&&(U=Xe,F=void 0,K={}),Re=Re.concat(Qt({key:`${Ze}[0]`,value:Le[0],valueSpec:{zoom:{}},style:we.style,styleSpec:we.styleSpec,objectElementValidators:{zoom:dt,value:Ne}}))}else Re=Re.concat(Ne({key:`${Ze}[0]`,value:Le[0],style:we.style,styleSpec:we.styleSpec},Le));return i.Q(i.S(Le[1]))?Re.concat([new i.V(`${Ze}[1]`,Le[1],"expressions are not allowed in function stops.")]):Re.concat(nn({key:`${Ze}[1]`,value:Le[1],valueSpec:C,style:we.style,styleSpec:we.styleSpec}))}function Ne(we,Re){const Le=i.K(we.value),Ze=i.J(we.value),nt=we.value!==null?we.value:Re;if(R){if(Le!==R)return[new i.V(we.key,nt,`${Le} stop domain type must match previous stop domain type ${R}`)]}else R=Le;if(Le!=="number"&&Le!=="string"&&Le!=="boolean"&&typeof Ze!="number"&&typeof Ze!="string"&&typeof Ze!="boolean")return[new i.V(we.key,nt,"stop domain value must be a number, string, or boolean")];if(Le!=="number"&&P!=="categorical"){let Xe=`number expected, ${Le} found`;return i.N(C)&&P===void 0&&(Xe+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(we.key,nt,Xe)]}return P!=="categorical"||Le!=="number"||typeof Ze=="number"&&isFinite(Ze)&&Math.floor(Ze)===Ze?P!=="categorical"&&Le==="number"&&typeof Ze=="number"&&typeof F=="number"&&F!==void 0&&Zenew i.V(`${N.key}${C.key}`,N.value,C.message));const x=u.value.expression||u.value._styleExpression.expression;if(N.expressionContext==="property"&&N.propertyKey==="text-font"&&!x.outputDefined())return[new i.V(N.key,N.value,`Invalid data expression for "${N.propertyKey}". Output values must be contained as literals within the expression.`)];if(N.expressionContext==="property"&&N.propertyType==="layout"&&!i.Z(x))return[new i.V(N.key,N.value,'"feature-state" data expressions are not supported with layout properties.')];if(N.expressionContext==="filter")return xt(x,N);if(N.expressionContext==="appearance")return _t(x,N);if(N.expressionContext&&N.expressionContext.indexOf("cluster")===0){if(!i.X(x,["zoom","feature-state"]))return[new i.V(N.key,N.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(N.expressionContext==="cluster-initial"&&!i.Y(x))return[new i.V(N.key,N.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function xt(N,u){const x=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(u.valueSpec&&u.valueSpec.expression)for(const P of u.valueSpec.expression.parameters)x.delete(P);if(x.size===0)return[];const C=[];return N instanceof i._&&x.has(N.name)?[new i.V(u.key,u.value,`["${N.name}"] expression is not supported in a filter for a ${u.object.type} layer with id: ${u.object.id}`)]:(N.eachChild(P=>{C.push(...xt(P,u))}),C)}function _t(N,u){const x=new Set;if(u.valueSpec&&u.valueSpec.expression)for(const P of u.valueSpec.expression.parameters)x.add(P);if(x.size===0)return[];const C=[];return N instanceof i._&&!x.has(N.name)?[new i.V(u.key,u.value,`["${N.name}"] is not an allowed parameter`)]:(N.eachChild(P=>{C.push(..._t(P,u))}),C)}function qe(N){const u=N.key,x=N.value,C=N.valueSpec,P=[];return Array.isArray(C.values)?C.values.indexOf(i.J(x))===-1&&P.push(new i.V(u,x,`expected one of [${C.values.join(", ")}], ${JSON.stringify(x)} found`)):Object.keys(C.values).indexOf(i.J(x))===-1&&P.push(new i.V(u,x,`expected one of [${Object.keys(C.values).join(", ")}], ${JSON.stringify(x)} found`)),P}function Lt(N){return i.a2(i.S(N.value))?ut(Object.assign({},N,{expressionContext:"filter",valueSpec:N.styleSpec[`filter_${N.layerType||"fill"}`]})):Rt(N)}function Rt(N){const u=N.value,x=N.key;if(!Array.isArray(u))return[new i.V(x,u,`array expected, ${i.K(u)} found`)];if(u.length<1)return[new i.V(x,u,"filter array must have at least 1 element")];const C=N.styleSpec;let P=qe({key:`${x}[0]`,value:u[0],valueSpec:C.filter_operator});const R=()=>{u.length>=2&&(i.a0(u[1])||P.push(new i.V(`${x}[1]`,u[1],`string expected, ${i.K(u[1])} found`)));for(let F=2;F":case">=":u.length>=2&&i.J(u[1])==="$type"&&P.push(new i.V(x,u,`"$type" cannot be use with operator "${u[0]}"`)),u.length!==3&&P.push(new i.V(x,u,`filter array for operator "${u[0]}" must have 3 elements`)),R();break;case"==":case"!=":u.length!==3&&P.push(new i.V(x,u,`filter array for operator "${u[0]}" must have 3 elements`)),R();break;case"in":case"!in":R();break;case"any":case"all":case"none":for(let F=1;F{te in x&&u.push(new i.V(C,x[te],`"${te}" is prohibited for ref layers`))}),P.layers.forEach(te=>{i.J(te.id)===U&&(K=te)}),K?K.ref?u.push(new i.V(C,x.ref,"ref cannot reference another ref layer")):F=i.J(K.type):typeof U=="string"&&u.push(new i.V(C,x.ref,`ref layer "${U}" not found`))}else if(F!=="background"&&F!=="sky"&&F!=="slot")if(x.source)if(i.a0(x.source)){const K=P.sources&&P.sources[x.source],te=K&&i.J(K.type);K?te==="vector"&&F==="raster"?u.push(new i.V(C,x.source,`layer "${x.id}" requires a raster source`)):te==="raster"&&F!=="raster"?u.push(new i.V(C,x.source,`layer "${x.id}" requires a vector source`)):te!=="vector"||x["source-layer"]?te==="raster-dem"&&F!=="hillshade"?u.push(new i.V(C,x.source,"raster-dem source can only be used with layer type 'hillshade'.")):te!=="raster-array"||["raster","raster-particle"].includes(F)?F==="line"&&x.paint&&(x.paint["line-gradient"]||x.paint["line-trim-offset"])&&te==="geojson"&&!K.lineMetrics?u.push(new i.V(C,x,`layer "${x.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):F==="raster-particle"&&te!=="raster-array"&&u.push(new i.V(C,x.source,`layer "${x.id}" requires a 'raster-array' source.`)):u.push(new i.V(C,x.source,"raster-array source can only be used with layer type 'raster'.")):u.push(new i.V(C,x,`layer "${x.id}" must specify a "source-layer"`)):u.push(new i.V(C,x.source,`source "${x.source}" not found`))}else u.push(new i.V(`${C}.source`,x.source,'"source" must be a string'));else u.push(new i.V(C,x,'missing required property "source"'));return u=u.concat(Qt({key:C,value:x,valueSpec:R.layer,style:N.style,styleSpec:N.styleSpec,objectElementValidators:{"*":()=>[],type:()=>nn({key:`${C}.type`,value:x.type,valueSpec:R.layer.type,style:N.style,styleSpec:N.styleSpec,object:x,objectKey:"type"}),filter:K=>Lt(Object.assign({layerType:F},K)),layout:K=>Qt({layer:x,key:K.key,value:K.value,valueSpec:{},style:K.style,styleSpec:K.styleSpec,objectElementValidators:{"*":te=>ss(Object.assign({layerType:F},te))}}),paint:K=>Qt({layer:x,key:K.key,value:K.value,valueSpec:{},style:K.style,styleSpec:K.styleSpec,objectElementValidators:{"*":te=>Xt(Object.assign({layerType:F,layer:x},te))}}),appearances(K){const te=it({key:K.key,value:K.value,valueSpec:K.valueSpec,style:K.style,styleSpec:K.styleSpec,arrayElementValidator:me=>function(fe){const{key:Ne,layer:we,layerType:Re}=fe,Le=i.J(fe.value),Ze=i.J(Le.name),nt=i.J(Le.condition),Xe=Qt({key:Ne,value:Le,valueSpec:fe.styleSpec.appearance,style:fe.style,styleSpec:fe.styleSpec,objectElementValidators:{condition:Mt=>function(gt){const jt=[];return jt.push(...ut({key:gt.key,value:gt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),jt}(Object.assign({layer:we,layerType:Re},Mt)),properties:Mt=>function(gt){const jt=[],{styleSpec:ft,layer:ht,layerType:At}=gt,Ut=ft[`paint_${At}`],Bt=ft[`layout_${At}`],ts=gt.object[gt.objectKey];for(const rs in ts){const ms=rs in Ut?"paint":rs in Bt?"layout":void 0;if(!ms){jt.push(new i.V(gt.key,rs,`unknown property "${rs}" for layer type "${At}"`));continue}const Ds=Object.assign({},gt,{key:`${gt.key}.${rs}`,object:ts,objectKey:rs,layer:ht,layerType:At,value:ts[rs],valueSpec:ms==="paint"?Ut[rs]:Bt[rs]});jt.push(...Kt(Ds,ms))}return jt}(Object.assign({layer:we,layerType:Re},Mt))}});return Ze!=="hidden"&&nt===void 0&&Xe.push(new i.V(fe.key,"name",'Appearance with name different than "hidden" must have a condition')),Xe}(Object.assign({layerType:F,layer:x},me))}),re=Array.isArray(K.value)?K.value:[],pe=new Set;return re.forEach((me,fe)=>{const Ne=i.J(me.name);if(Ne)if(pe.has(Ne)){const we=i.J(x.id);te.push(new i.V(K.key,Ne,`Duplicated appearance name "${Ne}" for layer "${we}"`))}else pe.add(Ne)}),te}}})),u}function fr({key:N,value:u}){return i.a0(u)?[]:[new i.V(N,u,`string expected, ${i.K(u)} found`)]}const yt={promoteId:function N({key:u,value:x}){if(i.a0(x))return fr({key:u,value:x});if(Array.isArray(x)){const P=[],R=i.S(x),F=i.U(R);return F.result==="error"&&F.value.forEach(U=>{P.push(new i.V(`${u}${U.key}`,null,`${U.message}`))}),i.X(F.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"])||P.push(new i.V(`${u}`,null,"promoteId expression should be only feature dependent")),P}if(!i.H(x))return[new i.V(u,x,`string, expression or object expected, "${i.K(x)}" found`)];const C=[];for(const P in x)C.push(...N({key:`${u}.${P}`,value:x[P]}));return C}};function bs(N){const u=N.value,x=N.key,C=N.styleSpec,P=N.style;if(!i.H(u))return[new i.V(x,u,`object expected, ${i.K(u)} found`)];if(!("type"in u))return[new i.V(x,u,'"type" is required')];const R=i.J(u.type);let F=[];switch(["vector","raster","raster-dem","raster-array"].includes(R)&&("url"in u||"tiles"in u||F.push(new i.a3(x,u,'Either "url" or "tiles" is required.'))),R){case"vector":case"raster":case"raster-dem":case"raster-array":return F=F.concat(Qt({key:x,value:u,valueSpec:C[`source_${R.replace("-","_")}`],style:N.style,styleSpec:C,objectElementValidators:yt})),F;case"geojson":if(F=Qt({key:x,value:u,valueSpec:C.source_geojson,style:P,styleSpec:C,objectElementValidators:yt}),"cluster"in u&&"clusterProperties"in u){if(!i.H(u.clusterProperties))return[new i.V(`${x}.clusterProperties`,u,`object expected, ${i.K(u)} found`)];for(const U in u.clusterProperties){const K=u.clusterProperties[U];if(!Array.isArray(K))return[new i.V(`${x}.clusterProperties.${U}`,K,"array expected")];const[te,re]=K,pe=typeof te=="string"?[te,["accumulated"],["get",U]]:te;F.push(...ut({key:`${x}.${U}.map`,value:re,expressionContext:"cluster-map"})),F.push(...ut({key:`${x}.${U}.reduce`,value:pe,expressionContext:"cluster-reduce"}))}}return F;case"video":return Qt({key:x,value:u,valueSpec:C.source_video,style:P,styleSpec:C});case"image":return Qt({key:x,value:u,valueSpec:C.source_image,style:P,styleSpec:C});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 qe({key:`${x}.type`,value:u.type,valueSpec:{values:gr(C)}})}}function gr(N){return N.source.reduce((u,x)=>{const C=N[x];return C.type.type==="enum"&&(u=u.concat(Object.keys(C.type.values||{}))),u},[])}function Br(N){const u=N.value,x=N.styleSpec,C=x.light,P=N.style;if(u===void 0)return[];if(!i.H(u))return[new i.V("light",u,`object expected, ${i.K(u)} found`)];let R=[];for(const F in u){const U=F.match(/^(.*)-transition$/),K=F.match(/^(.*)-use-theme$/);R=R.concat(K&&C[K[1]]?nn({key:F,value:u[F],valueSpec:{type:"string"},style:P,styleSpec:x}):U&&C[U[1]]&&C[U[1]].transition?nn({key:F,value:u[F],valueSpec:x.transition,style:P,styleSpec:x}):C[F]?nn({key:F,value:u[F],valueSpec:C[F],style:P,styleSpec:x}):[new i.V(F,u[F],`unknown property "${F}"`)])}return R}function na(N){const u=N.value;if(!u)return[];const x=N.key;if(!i.H(u))return[new i.V(x,u,`object expected, ${i.K(u)} found`)];let C=[];const P=N.styleSpec,R=P["light-3d"],F=N.style,U=N.style.lights;for(const re of["type","id"])if(!(re in u))return C=C.concat([new i.V(x,u,`missing property "${re}"`)]),C;if(!i.a0(u.type))return C=C.concat([new i.V(`${x}.type`,u.type,"string expected")]),C;if(U)for(let re=0;re[],array:it,boolean:function(N){const u=N.value,x=N.key;return i.$(u)?[]:[new i.V(x,u,`boolean expected, ${i.K(u)} found`)]},number:dt,color:function({key:N,value:u}){return i.a0(u)?i.a1.parseCSSColor(u)===null?[new i.V(N,u,`color expected, "${u}" found`)]:[]:[new i.V(N,u,`color expected, ${i.K(u)} found`)]},enum:qe,filter:Lt,function:tt,layer:fs,object:Qt,source:bs,model:i.a7,light:Br,"light-3d":na,terrain:za,fog:go,string:fr,formatted:function(N){return fr(N).length===0?[]:ut(N)},resolvedImage:function(N){return fr(N).length===0?[]:ut(N)},projection:function(N){const u=N.value,x=N.styleSpec,C=x.projection,P=N.style;if(i.H(u)){let R=[];for(const F in u)R=R.concat(nn({key:F,value:u[F],valueSpec:C[F],style:P,styleSpec:x}));return R}return i.a0(u)?[]:[new i.V("projection",u,`object or string expected, ${i.K(u)} found`)]},import:function(N){const u=N.key,{value:x,styleSpec:C}=N;if(!i.H(x))return[new i.V(u,x,"import must be an object")];const{data:P,...R}=x;Object.defineProperty(R,"__line__",{value:x.__line__,enumerable:!1});let F=Qt(Object.assign({},N,{value:R,valueSpec:C.import}));return i.J(R.id)===""&&F.push(new i.V(`${N.key}.id`,R,"import id can't be an empty string")),P&&(F=F.concat(Vr(P,C,{key:`${N.key}.data`}))),F},iconset:function(N){const u=N.value,x=N.key,C=N.styleSpec,P=N.style;if(!i.H(u))return[new i.V(x,u,"object expected")];if(!u.type)return[new i.V(x,u,'"type" is required')];const R=i.J(u.type);let F=[];if(F=F.concat(Qt({key:x,value:u,valueSpec:C[`iconset_${R}`],style:P,styleSpec:C})),function(U,K){return!(U!=="source"||!K.source)}(R,u)){const U=P.sources&&P.sources[u.source],K=U&&i.J(U.type);U?K!=="raster-array"&&F.push(new i.V(x,u.source,`iconset cannot be used with a source of type ${String(K)}, it only be used with a "raster-array" source type`)):F.push(new i.V(x,u.source,`source "${u.source}" not found`))}return F}};function nn(N,u=!1){const x=N.value,C=N.valueSpec,P=N.styleSpec;if(C.expression){if(i.a4(i.J(x)))return tt(N);if(i.Q(i.S(x)))return ut(N)}if(C.type&&Ia[C.type]){const R=Ia[C.type](N);return u===!0&&R.length>0&&Array.isArray(N.value)?ut(N):R}return Qt(Object.assign({},N,{valueSpec:C.type?P[C.type]:C}))}function Qt(N){const u=N.key,x=N.value,C=N.valueSpec||{},P=N.objectElementValidators||{},R=N.style,F=N.styleSpec;if(!i.H(x))return[new i.V(u,x,`object expected, ${i.K(x)} found`)];let U=[];for(const K in x){const te=K.split(".")[0];let re;P[te]?re=P[te]:C[te]?re=nn:P["*"]?re=P["*"]:C["*"]&&(re=nn),re?U=U.concat(re({key:(u&&`${u}.`)+K,value:x[K],valueSpec:C[te]||C["*"],style:R,styleSpec:F,object:x,objectKey:K},x)):U.push(new i.a3(u,x[K],`unknown property "${K}"`))}for(const K in C){if(P[K])continue;const te=C[K];te.required&&te.default===void 0&&x[K]===void 0&&U.push(new i.V(u,x,`missing required property "${K}"`))}return U}function lr({key:N,value:u}){const x=fr({key:N,value:u});if(x.length)return x;const C=u;return C.indexOf("{fontstack}")===-1&&x.push(new i.V(N,u,'"glyphs" url must include a "{fontstack}" token')),C.indexOf("{range}")===-1&&x.push(new i.V(N,u,'"glyphs" url must include a "{range}" token')),x}function Vr(N,u=i.a6,x={}){return Qt({key:x.key||"",value:N,valueSpec:Object.assign(u.$root,{"*":{type:"*"}}),styleSpec:u,style:N,objectElementValidators:{glyphs:lr}})}function Pr(N,u=i.a6){return Pe(Vr(N,u))}const on=N=>Pe(bs(N)),cs=N=>Pe(Br(N)),ka=N=>Pe(na(N)),zi=N=>Pe(za(N)),li=N=>Pe(go(N)),Or=N=>Pe(function(u){const x=u.value,C=u.style,P=u.styleSpec,R=P.snow;if(x===void 0)return[];if(!i.H(x))return[new i.V("snow",x,`object expected, ${i.K(x)} found`)];let F=[];for(const U in x){const K=U.match(/^(.*)-transition$/);F=F.concat(K&&R[K[1]]&&R[K[1]].transition?nn({key:U,value:x[U],valueSpec:P.transition,style:C,styleSpec:P}):R[U]?nn({key:U,value:x[U],valueSpec:R[U],style:C,styleSpec:P}):[new i.a3(U,x[U],`unknown property "${U}"`)])}return F}(N)),Oi=N=>Pe(function(u){const x=u.value,C=u.style,P=u.styleSpec,R=P.rain;if(x===void 0)return[];if(!i.H(x))return[new i.V("rain",x,`object expected, ${i.K(x)} found`)];let F=[];for(const U in x){const K=U.match(/^(.*)-transition$/);F=F.concat(K&&R[K[1]]&&R[K[1]].transition?nn({key:U,value:x[U],valueSpec:P.transition,style:C,styleSpec:P}):R[U]?nn({key:U,value:x[U],valueSpec:R[U],style:C,styleSpec:P}):[new i.a3(U,x[U],`unknown property "${U}"`)])}return F}(N)),Rc=N=>Pe(fs(N)),Co=N=>Pe(Lt(N)),Fc=N=>Pe(Xt(N)),rt=N=>Pe(ss(N)),_e=N=>Pe(i.a7(N));function Pe(N){return N.slice().sort((u,x)=>u.line&&x.line?u.line-x.line:0)}function Qe(N,u){let x=!1;if(u&&u.length)for(const C of u)C instanceof i.a3?i.w(C.message):(N.fire(new i.y(new Error(C.message))),x=!0);return x}const Tt=i.a6.light;let kt;class Dt extends i.E{constructor(u,x="flat"){super(),this._transitionable=new i.a8(kt||(kt=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(u,x),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(u,x,C={}){this._validate(cs,u,C)||(this._transitionable.setTransitionOrValue(u),this.id=x)}updateTransitions(u){this._transitioning=this._transitionable.transitioned(u,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(u){this.properties=this._transitioning.possiblyEvaluate(u)}_validate(u,x,C){return(!C||C.validate!==!1)&&Qe(this,u.call(Pr,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Zt=i.a6.terrain;let Ft=class extends i.E{constructor(N,u,x,C,P){super(),this.scope=x,this._transitionable=new i.a8(new i.a9({source:new i.aa(Zt.source),exaggeration:new i.aa(Zt.exaggeration)}),x,C),this._transitionable.setTransitionOrValue(N,C),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=u,this.worldview=P}get(){return this._transitionable.serialize()}set(N,u){this._transitionable.setTransitionOrValue(N,u)}updateTransitions(N){this._transitioning=this._transitionable.transitioned(N,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(N){this.properties=this._transitioning.possiblyEvaluate(N)}getExaggeration(N){return this._transitioning.possiblyEvaluate(new i.ac(N,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const N=this._transitionable._values.exaggeration;if(!N)return null;const u=N.value.expression;if(!u)return null;let x=-1,C=-1,P=1;for(const R of u.zoomStops)P=u.evaluate(new i.ac(R,{worldview:this.worldview})),P>.01?(x=R,C=-1):C=R;return P<.01&&x>0&&C>x?[x,C]:null}isZoomDependent(){const N=this._transitionable._values.exaggeration;return N!=null&&N.value!=null&&N.value.expression!=null&&N.value.expression instanceof i.ad}};const Jt=45,Ss=65,ps=.05;function ur(N,u,x,C){const P=i.ah(Jt,Ss,x),[R,F]=Dr(N,C);let U=1-Math.min(1,Math.exp((u-R)/(F-R)*-6));return U*=U*U,U=Math.min(1,1.00747*U),U*P*N.alpha}function Dr(N,u){const x=.5/Math.tan(.5*u);return[N.range[0]+x,N.range[1]+x]}function cr(N,u,x,C,P){const R=i.af([],[u,x,C],P.mercatorFogMatrix);return ur(N,i.ag(R),P.pitch,P._fov)}function jn(N,u,x,C,P,R,F){const U=[[x,C,0],[P,C,0],[P,R,0],[x,R,0]];let K=Number.MAX_VALUE,te=-Number.MAX_VALUE;for(const re of U){const pe=i.af([],re,u),me=i.ag(pe);K=Math.min(K,me),te=Math.max(te,me)}return[ur(N,K,F.pitch,F._fov),ur(N,te,F.pitch,F._fov)]}const kn=i.a6.fog;class yn extends i.E{constructor(u,x,C,P){super();const R=new i.a9({range:new i.aa(kn.range),color:new i.aa(kn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(kn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(kn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(kn["horizon-blend"]),"star-intensity":new i.aa(kn["star-intensity"]),"vertical-range":new i.aa(kn["vertical-range"])});this._transitionable=new i.a8(R,C,new Map(P)),this.set(u,P),this._transitioning=this._transitionable.untransitioned(),this._transform=x,this.properties=new i.ai(R),this.scope=C}get state(){const u=this._transform,x=u.projection.name==="globe",C=i.aj(u.zoom),P=this.properties.get("range"),R=[.5,3];return{range:x?[i.ak(R[0],P[0],C),i.ak(R[1],P[1],C)]:P,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(u,x,C={}){if(this._validate(li,u,C))return;const P=Object.assign({},u);for(const R of Object.keys(kn))P[R]===void 0&&(P[R]=kn[R].default);this._options=P,this._transitionable.setTransitionOrValue(this._options,x)}getOpacity(u){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,Ss,u))*x.a}getOpacityAtLatLng(u,x){return this._transform.projection.supportsFog?function(C,P,R){const F=i.ae.fromLngLat(P),U=R.elevation?R.elevation.getAtPointOrZero(F):0;return cr(C,F.x,F.y,U,R)}(this.state,u,x):0}getOpacityForTile(u){if(!this._transform.projection.supportsFog)return[1,1];const x=this._transform.calculateFogTileMatrix(u.toUnwrapped());return jn(this.state,x,0,0,i.al,i.al,this._transform)}getOpacityForBounds(u,x,C,P,R){return this._transform.projection.supportsFog?jn(this.state,u,x,C,P,R,this._transform):[1,1]}getFovAdjustedRange(u){return this._transform.projection.supportsFog?Dr(this.state,u):[0,1]}isVisibleOnFrustum(u){if(!this._transform.projection.supportsFog)return!1;const x=[4,5,6,7];for(const C of x){const P=u.points[C];let R;if(P[2]>=0)R=P;else{const F=u.points[C-4];R=i.am(F,P,F[2]/(F[2]-P[2]))}if(cr(this.state,R[0],R[1],0,this._transform)>=ps)return!0}return!1}updateConfig(u){this._transitionable.setTransitionOrValue(this._options,new Map(u))}updateTransitions(u){this._transitioning=this._transitionable.transitioned(u,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(u){this.properties=this._transitioning.possiblyEvaluate(u)}_validate(u,x,C){return(!C||C.validate!==!1)&&Qe(this,u.call(Pr,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let aa,so,Po,Pa,Fo=class extends i.E{constructor(N,u,x,C){super();const P=aa||(aa=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(P,x,new Map(C)),this.set(N,C),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(P),this.scope=x}get state(){const N=this.properties.get("opacity"),u=this.properties.get("color"),x=this.properties.get("direction"),C=i.an(x[0]),P=-Math.max(i.an(x[1]),.01),R=[Math.cos(C)*Math.cos(P),Math.sin(C)*Math.cos(P),Math.sin(P)],F=this.properties.get("vignette"),U=this.properties.get("vignette-color");return U.a=F,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(u.r,u.g,u.b,u.a*N),direction:R,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:U}}get(){return this._transitionable.serialize()}set(N,u,x={}){if(this._validate(Or,N,x))return;const C=Object.assign({},N),P=i.a6.snow;for(const R of Object.keys(P))C[R]===void 0&&(C[R]=P[R].default);this._options=C,this._transitionable.setTransitionOrValue(this._options,u)}updateConfig(N){this._transitionable.setTransitionOrValue(this._options,new Map(N))}updateTransitions(N){this._transitioning=this._transitionable.transitioned(N,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(N){this.properties=this._transitioning.possiblyEvaluate(N)}_validate(N,u,x){return(!x||x.validate!==!1)&&Qe(this,N.call(Pr,Object.assign({value:u,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},Ki=class extends i.E{constructor(N,u,x,C){super();const P=so||(so=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(P,x,new Map(C)),this.set(N,C),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(P),this.scope=x}get state(){const N=this.properties.get("opacity"),u=this.properties.get("color"),x=this.properties.get("direction"),C=i.an(x[0]),P=-Math.max(i.an(x[1]),.01),R=[Math.cos(C)*Math.cos(P),Math.sin(C)*Math.cos(P),Math.sin(P)],F=this.properties.get("vignette-color");return F.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(u.r,u.g,u.b,u.a*N),direction:R,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:F}}get(){return this._transitionable.serialize()}set(N,u,x={}){if(this._validate(Oi,N,x))return;const C=Object.assign({},N),P=i.a6.rain;for(const R of Object.keys(P))C[R]===void 0&&(C[R]=P[R].default);this._options=C,this._transitionable.setTransitionOrValue(this._options,u)}updateConfig(N){this._transitionable.setTransitionOrValue(this._options,new Map(N))}updateTransitions(N){this._transitioning=this._transitionable.transitioned(N,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(N){this.properties=this._transitioning.possiblyEvaluate(N)}_validate(N,u,x){return(!x||x.validate!==!1)&&Qe(this,N.call(Pr,Object.assign({value:u,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class pa extends i.E{constructor(u,x,C,P){super(),this.scope=C,this._options=u,this.properties=new i.ai(x),this._transitionable=new i.a8(x,C,new Map(P)),this._transitionable.setTransitionOrValue(u.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(u){this._transitionable.setTransitionOrValue(this._options.properties,new Map(u))}updateTransitions(u){this._transitioning=this._transitionable.transitioned(u,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(u){this.properties=this._transitioning.possiblyEvaluate(u)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(u,x){this._options=u,this._transitionable.setTransitionOrValue(u.properties,x)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}class Zi{constructor(u,x,C){this.screenBounds=u,this.cameraPoint=C.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=x,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,C)}static createFromScreenPoints(u,x){let C,P;if(u instanceof i.P||typeof u[0]=="number"){const R=i.P.convert(u);C=[R],P=x.isPointAboveHorizon(R)}else{const R=i.P.convert(u[0]),F=i.P.convert(u[1]),U=R.add(F)._div(2);C=[R,F],P=i.aq(R,F).every(K=>x.isPointAboveHorizon(K))&&x.isPointAboveHorizon(U)}return new Zi(C,P,x)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(u){return i.aq(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],u)}bufferedCameraGeometry(u){const x=this.screenBounds[0],C=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],P=i.aq(x,C,0,!1);return this.cameraPoint.y>C.y&&(this.cameraPoint.x>x.x&&this.cameraPoint.x=C.x?P[2]=this.cameraPoint:this.cameraPoint.x<=x.x&&(P[3]=this.cameraPoint)),i.ar(P,u)}bufferedCameraGeometryGlobe(u){const x=this.screenBounds[0],C=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],P=i.aq(x,C,u),R=this.cameraPoint.clone();switch(3*((R.y>x.y)+(R.y>C.y))+((R.x>x.x)+(R.x>C.x))){case 0:P[0]=R,P[4]=R.clone();break;case 1:P.splice(1,0,R);break;case 2:P[1]=R;break;case 3:P.splice(4,0,R);break;case 5:P.splice(2,0,R);break;case 6:P[3]=R;break;case 7:P.splice(3,0,R);break;case 8:P[2]=R}return P}containsTile(u,x,C,P=0){const R=Math.max(u.queryPadding,u.evaluateQueryRenderedFeaturePadding())/x._pixelsPerMercatorPixel+1,F=C?this._bufferedCameraMercator(R,x):this._bufferedScreenMercator(R,x);let U=u.tileID.wrap+(F.unwrapped?P:0);const K=F.polygon.map(Re=>i.as(u.tileTransform,Re,U));if(!i.at(K,0,0,i.al,i.al))return;U=u.tileID.wrap+(this.screenGeometryMercator.unwrapped?P:0);const te=this.screenGeometryMercator.polygon.map(Re=>i.au(u.tileTransform,Re,U)),re=te.map(Re=>new i.P(Re[0],Re[1])),pe=x.getFreeCameraOptions().position||new i.ae(0,0,0),me=i.au(u.tileTransform,pe,U),fe=te.map(Re=>{const Le=i.av(Re,Re,me);return i.aw(Le,Le),new i.ax(me,Le)}),Ne=i.ay(u,1,x.zoom)*x._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:re,tilespaceRays:fe,bufferedTilespaceGeometry:K,bufferedTilespaceBounds:(we=i.az(K),we.min.x=i.aA(we.min.x,0,i.al),we.min.y=i.aA(we.min.y,0,i.al),we.max.x=i.aA(we.max.x,0,i.al),we.max.y=i.aA(we.max.y,0,i.al),we),tile:u,tileID:u.tileID,pixelToTileUnitsFactor:Ne};var we}_bufferedScreenMercator(u,x){const C=Yi(u);if(this._screenRaycastCache[C])return this._screenRaycastCache[C];{let P;return P=x.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(u),x):{polygon:this.bufferedScreenGeometry(u).map(R=>x.pointCoordinate3D(R)),unwrapped:!0},this._screenRaycastCache[C]=P,P}}_bufferedCameraMercator(u,x){const C=Yi(u);if(this._cameraRaycastCache[C])return this._cameraRaycastCache[C];{let P;return P=x.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(u),x):{polygon:this.bufferedCameraGeometry(u).map(R=>x.pointCoordinate3D(R)),unwrapped:!0},this._cameraRaycastCache[C]=P,P}}_projectAndResample(u,x){const C=function(R,F){const U=i.aB([],F.pixelMatrix,F.globeMatrix),K=[0,-i.aD,0,1],te=[0,i.aD,0,1],re=[0,0,0,1];i.aC(K,K,U),i.aC(te,te,U),i.aC(re,re,U);const pe=new i.P(K[0]/K[3],K[1]/K[3]),me=new i.P(te[0]/te[3],te[1]/te[3]),fe=i.aE(R,pe)&&K[3]1?ci(R.slice(0,Re),F):[],nt=Renew i.P(Xn(jt.x),jt.y)),nt=nt.map(jt=>new i.P(Xn(jt.x),jt.y));const Xe=[...Ze];Xe.length===0&&Xe.push(nt[nt.length-1]);const Mt=i.ak(Xe[Xe.length-1].y,(nt.length===0?Ze[0]:nt[0]).y,Le);let gt;return gt=fe?[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)],Xe.push(...gt),nt.length===0?Xe.push(Ze[0]):Xe.push(...nt),{polygon:Xe.map(jt=>new i.ae(jt.x,jt.y)),unwrapped:!1}}(u,x);if(C)return C;const P=function(R,F){let U=!1,K=-1/0,te=0;for(let pe=0;peK&&(K=R[pe].x,te=pe);for(let pe=0;pe.5&&(fe.x{pe.x-=1}),{polygon:R,unwrapped:U}}(ci(u,x).map(R=>new i.P(Xn(R.x),R.y)),x);return{polygon:P.polygon.map(R=>new i.ae(R.x,R.y)),unwrapped:P.unwrapped}}}function ci(N,u){return i.aG(N,x=>{const C=u.pointCoordinate3D(x);x.x=C.x,x.y=C.y},1/256)}function Xn(N){return N<0?1+N%1:N%1}function Yi(N){return 100*N|0}function Ll(N,u,x,C,P){const R=function(U,K){if(U)return P(U);if(K){if(N.url&&K.tiles&&N.tiles&&delete N.tiles,K.variants){if(!Array.isArray(K.variants))return P(new Error("variants must be an array"));for(const re of K.variants){if(re==null||typeof re!="object"||re.constructor!==Object)return P(new Error("variant must be an object"));if(!Array.isArray(re.capabilities))return P(new Error("capabilities must be an array"));if(re.capabilities.length===1&&re.capabilities[0]==="meshopt"){K=Object.assign(K,re);break}}}const te=i.aH(Object.assign({},K,N),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);te.tiles=u.canonicalizeTileset(te,N.url),P(null,te)}},F=function(U,K,te){if(!U)return null;if(!K&&!te)return U;te=te||U.worldview_default;const re=Object.values(U.language||{});if(re.length===0)return null;const pe=Object.values(U.worldview||{});if(pe.length===0)return null;const me=re.every(Ne=>Ne===K),fe=pe.every(Ne=>Ne===te);return me&&fe?U:K in(U.language_options||{})||te in(U.worldview_options||{})?null:U.language_options&&U.worldview_options?U:null}(N.data,x,C);return F?i.o.frame(()=>R(null,F)):N.url?i.m(u.transformRequest(u.normalizeSourceURL(N.url,null,x,C),i.R.Source),R):i.o.frame(()=>{const{data:U,...K}=N;R(null,K)})}function Zl(N,u){const x=Math.pow(2,u.z),C=Math.floor(i.aF(N.getWest())*x),P=Math.floor(i.aJ(N.getNorth())*x),R=Math.ceil(i.aF(N.getEast())*x),F=Math.ceil(i.aJ(N.getSouth())*x);return u.x>=C&&u.x=P&&u.ythis.maxzoom||u.z{if(this._tileJSONRequest=null,this._loaded=!0,P)x&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${x}`),C&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${C}`),this.fire(new i.y(P));else if(R){if(Object.assign(this,R),this.hasWorldviews=!!R.worldview_options,R.worldview_default&&(this.worldviewDefault=R.worldview_default),R.vector_layers){this.vectorLayers=R.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const F of R.vector_layers)this.vectorLayerIds.push(F.id),R.worldview&&R.worldview[F.source]&&this.localizableLayerIds.add(F.id)}this.tileBounds=fd.fromTileJSON(R),Se(R.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"}))}u&&u(P)})}loaded(){return this._loaded}hasTile(u){return!this.tileBounds||this.tileBounds.contains(u.canonical)}onAdd(u){this.map=u,this.load()}reload(){this.cancelTileJSONRequest();const u=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(u))}setTiles(u){return this._options.tiles=u,this.reload(),this}setUrl(u){return this.url=u,this._options.url=u,this.reload(),this}onRemove(u){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(u,x){const C=u.tileID.canonical.url(this.tiles,this.scheme),P=this.map._requestManager.normalizeTileURL(C),R=this.map._requestManager.transformRequest(P,i.R.Tile),F=this.map.style?this.map.style.getLut(this.scope):null,U=F?{image:F.image.clone()}:null,K={request:R,data:void 0,uid:u.uid,tileID:u.tileID,tileZoom:u.tileZoom,zoom:u.tileID.overscaledZ,maxZoom:this.maxzoom,lut:U,tileSize:this.tileSize*u.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:u.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:u.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(C)&&(K.localizableLayerIds=this.localizableLayerIds),K.request.collectResourceTiming=this._collectResourceTiming,u.actor&&u.state!=="expired")u.state==="loading"?u.reloadCallback=x:u.request=u.actor.send("reloadTile",K,te.bind(this));else if(u.actor=this._tileWorkers[P]=this._tileWorkers[P]||this.dispatcher.getActor(),this.dispatcher.ready)u.request=u.actor.send("loadTile",K,te.bind(this),void 0,!0);else{const re=i.aL.call({deduped:this._deduped},K,(pe,me)=>{if(pe||!me)te.call(this,pe);else{const fe=i.aM(me.responseHeaders);K.data={rawData:me.rawData.slice(0),expires:fe.expires,cacheControl:fe.cacheControl},u.actor&&u.actor.send("loadTile",K,te.bind(this),void 0,!0)}},!0);u.request={cancel:re}}function te(re,pe){return delete u.request,u.aborted?x(null):re&&re instanceof i.aN&&re.status!==404?x(re):(pe&&pe.resourceTiming&&(u.resourceTiming=pe.resourceTiming),this.map._refreshExpiredTiles&&pe&&u.setExpiryData(pe),u.loadVectorData(pe,this.map.painter),i.aO(this.dispatcher),x(null,pe),void(u.reloadCallback&&(this.loadTile(u,u.reloadCallback),u.reloadCallback=null)))}}abortTile(u){u.request&&(u.request.cancel(),delete u.request),u.actor&&u.actor.send("abortTile",{uid:u.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(u,x){u.actor&&u.actor.send("removeTile",{uid:u.uid,type:this.type,source:this.id,scope:this.scope}),u.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class al extends i.E{constructor(u,x,C,P){super(),this.id=u,this.dispatcher=C,this.setEventedParent(P),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(u){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const x=this.map.getWorldview();this._tileJSONRequest=Ll(this._options,this.map._requestManager,null,x,(C,P)=>{this._tileJSONRequest=null,this._loaded=!0,C?this.fire(new i.y(C)):P&&(Object.assign(this,P),P.raster_layers&&(this.rasterLayers=P.raster_layers,this.rasterLayerIds=this.rasterLayers.map(R=>R.id)),this.tileBounds=fd.fromTileJSON(P),Se(P.tiles),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),u&&u(C)})}loaded(){return this._loaded}onAdd(u){this.map=u,this.load()}reload(){this.cancelTileJSONRequest();const u=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(u))}setTiles(u){return this._options.tiles=u,this.reload(),this}setUrl(u){return this.url=u,this._options.url=u,this.reload(),this}onRemove(u){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(u){return!this.tileBounds||this.tileBounds.contains(u.canonical)}loadTile(u,x){const C=i.o.devicePixelRatio>=2,P=this.map._requestManager.normalizeTileURL(u.tileID.canonical.url(this.tiles,this.scheme),C,this.tileSize);u.request=i.n(this.map._requestManager.transformRequest(P,i.R.Tile),(R,F,U)=>{if(delete u.request,u.aborted)return u.state="unloaded",x(null);if(R)return u.state="errored",x(R);if(!F)return x(null);const K=i.aM(U);this.map._refreshExpiredTiles&&u.setExpiryData(K),u.setTexture(F,this.map.painter),u.state="loaded",i.aO(this.dispatcher),x(null)})}abortTile(u,x){u.request&&(u.request.cancel(),delete u.request),x&&x()}unloadTile(u,x){u.texture&&u.texture instanceof i.T?(u.destroy(!1),u.texture&&u.texture instanceof i.T&&this.map.painter.saveTileTexture(u.texture)):u.destroy(),x&&x()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function nu([N,u],x,C,{scaled:P=!0}={}){const{tileSize:R,buffer:F}=C,{x:U,y:K,z:te}=x;if(!isFinite(U)||!isFinite(K)||!isFinite(te))throw new Error("Invalid MRT header");const re=2**te,pe=re*i.aF(N),me=re*i.aJ(u);return function([fe,Ne],we,{scaled:Re=!0}={}){if(!we)throw new Error("bandView is undefined");const{data:Le,tileSize:Ze,buffer:nt,offset:Xe,scale:Mt,dimension:gt}=we;if(fe<-nt||fe>Ze+nt||Ne<-nt||Ne>Ze+nt)throw new Error(`Point (${fe}, ${Ne}) out of bounds for tileSize=${Ze}, buffer=${nt}`);const jt=(Ne+nt)*(Ze+2*nt)+(fe+nt);if(new Uint32Array(Le.buffer)[jt]===4294967295)return null;let ft=[];ft=Re?[]:new we.data.constructor(gt);for(let ht=0;ht{if(delete u.request,u.aborted)return u.state="unloaded",x(null);if(U)return U.name==="AbortError"?void 0:(u.state="errored",x(U));if(this.map._refreshExpiredTiles&&K){const re=i.aM(te);u.setExpiryData(re)}if(this.partial&&u.state!=="expired")u.state="empty";else if(!this.partial){if(!K)return x(null);u.state="loaded",u._isHeaderLoaded=!0,u._mrt=K}x(null)};u.request=this.partial?u.fetchHeader(void 0,F.bind(this)):u.actor.send("loadTile",R,F.bind(this),void 0,!0)}abortTile(u){u.request&&(u.request.cancel(),delete u.request),u.actor&&u.actor.send("abortTile",{uid:u.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(u,x){const C=u.texturePerLayer;if(u.flushAllQueues(),C.size){u.destroy(!1);for(const P of C.values())this.map.painter.saveTileTexture(P)}else u.destroy()}prepareTile(u,x,C,P){u._isHeaderLoaded&&(u.state!=="empty"&&(u.state="reloading"),u.fetchBandForRender(x,C,P,(R,F)=>{if(R)return u.state="errored",this.fire(new i.y(R)),void this.triggerRepaint(u);F&&(u._isHeaderLoaded=!0,u.setTexturePerLayer(C,F,this.map.painter),u.state="loaded",this.triggerRepaint(u))}))}getInitialBand(u){if(!this.rasterLayers)return 0;const x=this.rasterLayers.find(({id:R})=>R===u),C=x&&x.fields,P=C&&C.bands&&C.bands;return P?P[0]:0}getTextureDescriptor(u,x,C){if(!u)return;const P=x.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!P)return;let R=null;x instanceof i.aR?R=x.paint.get("raster-array-band"):x instanceof i.aS&&(R=x.paint.get("raster-particle-array-band"));const F=R||this.getInitialBand(P);if(F==null)return;if(!u.textureDescriptorPerLayer.get(x.id))return void this.prepareTile(u,P,x.id,F);if(u.updateNeeded(x.id,F)&&!C)return;const U=u.textureDescriptorPerLayer.get(x.id);return Object.assign({},U,{texture:u.texturePerLayer.get(x.id)})}getImages(u,x){const C=new Map;for(const P of u)for(const R of x){const[F,U]=R.split("/"),K=P.getLayer(F);if(!K||!K.hasBand(U)||!K.hasDataForBand(U))continue;const{bytes:te,tileSize:re,buffer:pe}=K.getBandView(U),me=re+2*pe,fe={data:new i.q({width:me,height:me},te),pixelRatio:2,sdf:!1,usvg:!1,version:0};C.set(R,fe)}return C}queryRasterArrayValueByBandId(u,x,C){const P=x._mrt;return new Promise(R=>{const F={},U=new Set;for(const[K,te]of Object.entries(P.layers)){if(C.layerName&&K!==C.layerName)continue;const re={};F[K]=re;for(const{bands:pe}of te.dataIndex)for(const me of pe)C.bands&&!C.bands.includes(me)||(U.add(i.B(K,me)),x.fetchBand(K,null,me,fe=>{i.o.frame(()=>{re[me]=fe?null:nu([u.lng,u.lat],P,te.getBandView(me)),U.delete(i.B(K,me)),U.size===0&&R(F)})},!1))}U.size===0&&R(F)})}_loadTileForQuery(u,x){if(this._loadTileLoaded[u.uid])return void x(null,u._mrt);if(this._loadTilePending[u.uid])return void this._loadTilePending[u.uid].push(x);this._loadTilePending[u.uid]=[x];const C=this.map._requestManager.normalizeTileURL(u.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),P=this.map._requestManager.transformRequest(C,i.R.Tile);u.actor.send("loadTile",{request:P,uid:u.uid,tileID:u.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(R,F,U)=>{if(R)return this._loadTilePending[u.uid].forEach(K=>K(R,null)),void delete this._loadTilePending[u.uid];if(!F)return this._loadTilePending[u.uid].forEach(K=>K(null,null)),void delete this._loadTilePending[u.uid];if(this.map._refreshExpiredTiles&&F){const K=i.aM(U);u.setExpiryData(K)}u._mrt=F,u._isHeaderLoaded=!0,u.state="loaded",this._loadTilePending[u.uid].forEach(K=>K(null,F)),this._loadTileLoaded[u.uid]=!0,delete this._loadTilePending[u.uid]},void 0,!0)}queryRasterArrayValueByAllBands(u,x,C){return new Promise((P,R)=>{this._loadTileForQuery(x,(F,U)=>{F?R(F):P(U?this.queryRasterArrayValueByBandId(u,x,C):null)})})}queryRasterArrayValue(u,x){const C=i.aT.convert(u),P=this.findLoadedParent(C);return P&&P._mrt?x.bands||!this.partial?this.queryRasterArrayValueByBandId(C,P,x):this.queryRasterArrayValueByAllBands(C,P,x):Promise.resolve(null)}findLoadedParent(u){const x=i.ae.fromLngLat(u,this.map.transform.tileSize),C=this.maxzoom+1,P=1<0&&(U[new i.aQ(N.overscaledZ,P,u.z,C,u.y-1).key]={backfilled:!1},U[new i.aQ(N.overscaledZ,N.wrap,u.z,u.x,u.y-1).key]={backfilled:!1},U[new i.aQ(N.overscaledZ,F,u.z,R,u.y-1).key]={backfilled:!1}),u.y+1{if(this._loaded=!0,this._pendingLoad=null,C)this.fire(new i.y(C));else{const R={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&P&&P.resourceTiming&&P.resourceTiming[this.id]&&(R.resourceTiming=P.resourceTiming[this.id]),N&&(this._partialReload=!0),this.fire(new i.z("data",R)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(N),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const N=i.B(this.id,this.scope);this.map.style.clearSource(N),this._updateWorkerData()}loadTile(N,u){const x=N.actor?"reloadTile":"loadTile";N.actor=this.actor;const C=this.map.style?this.map.style.getLut(this.scope):null,P=C?{image:C.image.clone()}:null,R=this._partialReload,F={type:this.type,uid:N.uid,tileID:N.tileID,tileZoom:N.tileZoom,zoom:N.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:P,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:N.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:R,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};N.request=this.actor.send(x,F,(U,K)=>R&&!K?(N.state="loaded",u(null)):(delete N.request,N.destroy(!1),N.aborted?u(null):U?u(U):(N.loadVectorData(K,this.map.painter,x==="reloadTile"),u(null))),void 0,x==="loadTile")}abortTile(N){N.request&&(N.request.cancel(),delete N.request),N.aborted=!0}unloadTile(N,u){this.actor.send("removeTile",{uid:N.uid,type:this.type,source:this.id,scope:this.scope}),N.destroy()}onRemove(N){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(N,u,x,C){super(N,u,x,C),this.roundZoom=!0,this.type="video",this.options=u}load(){this._loaded=!1;const N=this.options;this.urls=[];for(const u of N.urls)this.urls.push(this.map._requestManager.transformRequest(u,i.R.Source).url);i.aV(this.urls,(u,x)=>{this._loaded=!0,u?this.fire(new i.y(u)):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(N){if(this.video){const u=this.video.seekable;Nu.end(0)?this.fire(new i.y(new i.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${u.start(0)} and ${u.end(0)}-second mark.`))):this.video.currentTime=N}}getVideo(){return this.video}onAdd(N){this.map||(this.map=N,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 N=this.map.painter.context,u=N.gl;this.texture?this.video.paused||(this.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE),u.texSubImage2D(u.TEXTURE_2D,0,0,0,u.RGBA,u.UNSIGNED_BYTE,this.video)):(this.texture=new i.T(N,this.video,u.RGBA8),this.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(N)}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(N,u,x,C){super(),this.type="batched-model",this.id=N,this.tileSize=512,this._options=u,this.tiles=this._options.tiles,this.maxzoom=u.maxzoom||19,this.minzoom=u.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=x,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(C)}onAdd(N){this.map=N,this.load()}reload(){this.cancelTileJSONRequest();const N=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(N))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(N){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const u=Array.isArray(this.map._language)?this.map._language.join():this.map._language,x=this.map.getWorldview();this._tileJSONRequest=Ll(this._options,this.map._requestManager,u,x,(C,P)=>{this._tileJSONRequest=null,this._loaded=!0,C?(u&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${u}`),x&&x.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${x}`),this.fire(new i.y(C))):P&&(Object.assign(this,P),P.bounds&&(this.tileBounds=new fd(P.bounds,this.minzoom,this.maxzoom)),Se(P.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"}))),N&&N(C)})}hasTransition(){return!1}hasTile(N){return!this.tileBounds||this.tileBounds.contains(N.canonical)}loaded(){return this._loaded}loadTile(N,u){const x=this.map._requestManager.normalizeTileURL(N.tileID.canonical.url(this.tiles,this.scheme)),C={request:this.map._requestManager.transformRequest(x,i.R.Tile),data:void 0,uid:N.uid,tileID:N.tileID,tileZoom:N.tileZoom,zoom:N.tileID.overscaledZ,tileSize:this.tileSize*N.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:N.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(N.actor&&N.state!=="expired")if(N.state==="loading")N.reloadCallback=u;else{if(N.buckets){const R=Object.values(N.buckets);for(const F of R)F.dirty=!0;return void(N.state="loaded")}N.request=N.actor.send("reloadTile",C,P.bind(this))}else N.actor=this.dispatcher.getActor(),N.request=N.actor.send("loadTile",C,P.bind(this),void 0,!0);function P(R,F){return N.aborted?u(null):R&&R.status!==404?u(R):(this.map._refreshExpiredTiles&&F&&N.setExpiryData(F),N.loadModelData(F,this.map.painter),N.state="loaded",void u(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(N,u,x,C){super(N,u,x,C),u.coordinates?Array.isArray(u.coordinates)&&u.coordinates.length===4&&!u.coordinates.some(P=>!Array.isArray(P)||P.length!==2||P.some(R=>typeof R!="number"))||this.fire(new i.y(new i.V(`sources.${N}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${N}`,null,'missing required property "coordinates"'))),u.animate&&typeof u.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${N}`,null,'optional "animate" property must be a boolean value'))),u.canvas?typeof u.canvas=="string"||u.canvas instanceof HTMLCanvasElement||this.fire(new i.y(new i.V(`sources.${N}`,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.${N}`,null,'missing required property "canvas"'))),this.options=u,this.animate=u.animate===void 0||u.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(N){this.map=N,this.load(),this.canvas&&this.animate&&this.play()}onRemove(N){this.pause()}prepare(){let N=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,N=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,N=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const u=this.map.painter.context;this.texture?!N&&!this._playing||this.texture instanceof i.aW||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.T(u,this.canvas,u.gl.RGBA8,{premultiply:!0}),this._prepareData(u)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const N of[this.canvas.width,this.canvas.height])if(isNaN(N)||N<=0)return!0;return!1}},custom:class extends i.E{constructor(N,u,x,C){super(),this.id=N,this.type="custom",this._dataType="raster",this._dispatcher=x,this._implementation=u,this.setEventedParent(C),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 fd(this._implementation.bounds,this.minzoom,this.maxzoom)),u.update=this._update.bind(this),u.clearTiles=this._clearTiles.bind(this),u.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,i.aH(u,["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(N){this.map=N,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(N),this.load()}onRemove(N){this._implementation.onRemove&&this._implementation.onRemove(N)}hasTile(N){if(this._implementation.hasTile){const{x:u,y:x,z:C}=N.canonical;return this._implementation.hasTile({x:u,y:x,z:C})}return!this.tileBounds||this.tileBounds.contains(N.canonical)}loadTile(N,u){const{x,y:C,z:P}=N.tileID.canonical,R=new AbortController;N.request=Promise.resolve(this._implementation.loadTile({x,y:C,z:P},{signal:R.signal})).then((function(F){return delete N.request,N.aborted?(N.state="unloaded",u(null)):F===void 0?(N.state="errored",u(null)):F===null?(this.loadTileData(N,{width:this.tileSize,height:this.tileSize,data:null}),N.state="loaded",u(null)):function(U){return U instanceof ImageData||U instanceof HTMLCanvasElement||U instanceof ImageBitmap||U instanceof HTMLImageElement}(F)?(this.loadTileData(N,F),N.state="loaded",void u(null)):(N.state="errored",u(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(F=>{F.name!=="AbortError"&&(N.state="errored",u(F))}),N.request.cancel=()=>R.abort()}loadTileData(N,u){N.setTexture(u,this.map.painter)}unloadTile(N,u){if(N.texture&&N.texture instanceof i.T?(N.destroy(!1),N.texture&&N.texture instanceof i.T&&this.map.painter.saveTileTexture(N.texture)):N.destroy(),this._implementation.unloadTile){const{x,y:C,z:P}=N.tileID.canonical;this._implementation.unloadTile({x,y:C,z:P})}u&&u()}abortTile(N,u){N.request&&N.request.cancel&&(N.request.cancel(),delete N.request),u&&u()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(N=>({x:N.canonical.x,y:N.canonical.y,z:N.canonical.z}))}_clearTiles(){const N=i.B(this.id,this.scope);this.map.style.clearSource(N)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},il=function(N,u,x,C){const P=new Lh[u.type](N,u,x,C);if(P.id!==N)throw new Error(`Expected Source id to be ${N} instead of ${P.id}`);return i.aY(["load","abort","unload","serialize","prepare"],P),P};function df(N,u,x=""){return`${x}:${u.id||""}:${u.layer.id}:${function(C){if("layerId"in C)return`layer:${C.layerId}`;{const{featuresetId:P,importId:R}=C;return`featureset:${P}${R?`:import:${R}`:""}`}}(N.target)}`}function Lg(N,u,x,C=""){if(N.uniqueFeatureID){const P=df(N,u,C);if(x.has(P))return!0;x.add(P)}return!1}function A0(N,u,x,C,P=!1){const R=u.sourceCache.transform,F=u.sourceCache.tilesIn(N,u.has3DLayers,P);F.sort(ym);const U=[];for(const K of F){const te=K.tile.queryRenderedFeatures(u,K,x,C,R,P);Object.keys(te).length&&U.push({wrappedTileID:K.tile.tileID.wrapped().key,queryResults:te})}for(const K in u.layers){const te=u.layers[K];if(te.styleLayer){const re=te.styleLayer.queryRenderedFeatures(N,u.sourceCache,C);Object.keys(re).length&&U.push({wrappedTileID:0,queryResults:re})}}return U.length===0?{}:function(K){const te={},re={};for(const pe of K){const me=pe.queryResults,fe=pe.wrappedTileID,Ne=re[fe]=re[fe]||{};for(const we in me){const Re=me[we],Le=Ne[we]=Ne[we]||{},Ze=te[we]=te[we]||[];for(const nt of Re)Le[nt.featureIndex]||(Le[nt.featureIndex]=!0,Ze.push(nt))}}return te}(U)}function E0(N,u,x,C,P,R){const F={},U=C.queryRenderedSymbols(N),K=[];for(const te of Object.keys(U).map(Number))K.push(P[te]);K.sort(ym);for(const te of K){const re=te.featureIndex.lookupSymbolFeatures(U[te.bucketInstanceId],te.bucketIndex,te.sourceLayerIndex,u,x,R);for(const pe in re){const me=F[pe]=F[pe]||[],fe=re[pe];fe.sort((Ne,we)=>{const Re=te.featureSortOrder;if(Re){const Le=Re.indexOf(Ne.featureIndex);return Re.indexOf(we.featureIndex)-Le}return we.featureIndex-Ne.featureIndex});for(const Ne of fe)me.push(Ne)}}return F}function I0(N,u){const x=N.getRenderableIds().map(R=>N.getTileByID(R)),C=[],P={};for(let R=0;Ru.getLayer(R)).filter(Boolean);if(P.length!==0){C.layers=P,C.stateDependentLayerIds&&(C.stateDependentLayers=C.stateDependentLayerIds.map(R=>P.filter(F=>F.id===R)[0]));for(const R of P)x[R.fqid]=C}}return x}const gd=32,ku=33,Bc=new Uint16Array(8184);for(let N=0;N<2046;N++){let u=N+2,x=0,C=0,P=0,R=0,F=0,U=0;for(1&u?P=R=F=gd:x=C=U=gd;(u>>=1)>1;){const te=x+P>>1,re=C+R>>1;1&u?(P=x,R=C,x=F,C=U):(x=P,C=R,P=F,R=U),F=te,U=re}const K=4*N;Bc[K+0]=x,Bc[K+1]=C,Bc[K+2]=P,Bc[K+3]=R}const xd=new Uint16Array(2178),Jo=new Uint8Array(1089),Qu=new Uint16Array(1089);function vm(N){return N===0?-.03125:N===32?.03125:0}const au={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 uf{constructor(u,x,C,P,R,F){this.tileID=u,this.uid=i.b2(),this.uses=0,this.tileSize=x,this.tileZoom=C,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=R,P&&P.style&&(this._lastUpdatedBrightness=P.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",P&&P.transform&&(this.projection=P.transform.projection),this.worldview=F,this._hasAppearances=null}registerFadeDuration(u){const x=u+this.timeAdded;xC)P=!1;else if(x)if(this.expirationTimeC.appearances&&C.appearances.length>0))return!0;return!1}updateBuckets(u,x){if(!this.latestFeatureIndex||!u.style)return;const C=u.style.listImages(),P=u.style.getBrightness();for(const R in this.buckets){if(!u.style.hasLayer(R))continue;const F=this.buckets[R],U=F.layers[0],K=U.sourceLayer||"_geojsonTileLayer",te=u.style.getLayerSourceCache(U);let re={};te&&(re=te._state.getState(K,void 0));const pe=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},me=Object.keys(re).length>0&&!x;F.hasAppearances=F.layers.some(we=>we.appearances&&we.appearances.length>0);const fe=me?F.stateDependentLayers:F.layers;if(me&&F.stateDependentLayers.length!==0||x){const we=this.latestFeatureIndex.loadVTLayers();F.update(re,we[K],C,pe,fe,x,P)}if(me&&F.stateDependentLayers.length!==0||x||F.hasAppearances){const we={zoom:u.transform.zoom,pitch:u.transform.pitch,brightness:u.style.getBrightness()||0,worldview:u.worldview};F.updateAppearances(this.tileID.canonical,re,C,we)}(F instanceof i.ba||F instanceof i.bb)&&u._terrain&&u._terrain.enabled&&te&&F.uploadPending()&&u._terrain._clearRenderCacheForTile(te.id,this.tileID);const Ne=u&&u.style&&u.style.getOwnLayer(R);Ne&&(this.queryPadding=Math.max(this.queryPadding,Ne.queryRadius(F)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;Re--){const Le=4*Re,Ze=Bc[Le+0],nt=Bc[Le+1],Xe=Bc[Le+2],Mt=Bc[Le+3],gt=Ze+Xe>>1,jt=nt+Mt>>1,ft=gt+jt-nt,ht=jt+Ze-gt,At=nt*ku+Ze,Ut=Mt*ku+Xe,Bt=jt*ku+gt,ts=Math.hypot((xd[2*At+0]+xd[2*Ut+0])/2-xd[2*Bt+0],(xd[2*At+1]+xd[2*Ut+1])/2-xd[2*Bt+1])>=16;Jo[Bt]=Jo[Bt]||(ts?1:0),Re<1022&&(Jo[Bt]=Jo[Bt]||Jo[(nt+ht>>1)*ku+(Ze+ft>>1)]||Jo[(Mt+ht>>1)*ku+(Xe+ft>>1)])}const pe=new i.b1,me=new i.b0;let fe=0;function Ne(Re,Le){const Ze=Le*ku+Re;return Qu[Ze]===0&&(pe.emplaceBack(xd[2*Ze+0],xd[2*Ze+1],Re*i.al/gd,Le*i.al/gd),Qu[Ze]=++fe),Qu[Ze]-1}function we(Re,Le,Ze,nt,Xe,Mt){const gt=Re+Ze>>1,jt=Le+nt>>1;if(Math.abs(Re-Xe)+Math.abs(Le-Mt)>1&&Jo[jt*ku+gt])we(Xe,Mt,Re,Le,gt,jt),we(Ze,nt,Xe,Mt,gt,jt);else{const ft=Ne(Re,Le),ht=Ne(Ze,nt),At=Ne(Xe,Mt);me.emplaceBack(ft,ht,At)}}return we(0,0,gd,gd,gd,0),we(gd,gd,0,0,0,gd),{vertices:pe,indices:me}}(this.tileID.canonical,x);P=F.vertices,R=F.indices}else{P=new i.b1,R=new i.b0;for(const{x:U,y:K}of C)P.emplaceBack(U,K,0,0);const F=i.bh(P.int16.subarray(0,4*P.length),void 0,4);for(let U=0;U0&&(K=i.bl(new Float64Array(16),x.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(u,P,x,F,K,U),this._makeGlobeTileDebugTextBuffer(u,P,x,F,K,U)}_globePoint(u,x,C,P,R,F,U){let K=i.bm(u,x,C);if(F){const te=1<.5?fe=-1:me<-.5&&(fe=1);let Ne=(u/i.al+C.x)/te+fe,we=(x/i.al+C.y)/te;Ne=(Ne-re)*P._pixelsPerMercatorPixel+re,we=(we-pe)*P._pixelsPerMercatorPixel+pe;const Re=[Ne*P.worldSize,we*P.worldSize,0];i.af(Re,Re,F),K=i.bn(K,Re,U)}return i.af(K,K,R)}_makeGlobeTileDebugBorderBuffer(u,x,C,P,R,F){const U=new i.bd,K=new i.be,te=new i.bo,re=(me,fe,Ne,we,Re)=>{const Le=(Ne-me)/(Re-1),Ze=(we-fe)/(Re-1),nt=U.length;for(let Xe=0;Xepe*fe+Ne;for(let fe=0;fe{if(R)x(R);else try{const K=C.getHeaderLength(F);if(K>u)return void(this.request=this.fetchHeader(K,x));C.parseHeader(F),this._isHeaderLoaded=!0;let te=0;for(const re of Object.values(C.layers))te=Math.max(te,re.dataIndex[re.dataIndex.length-1].lastByte);F.byteLength>=te&&(this.entireBuffer=F),x(null,this.entireBuffer||F,U)}catch(K){x(K)}}),this.request}fetchBandForRender(u,x,C,P){this.fetchBand(u,x,C,R=>{if(R)return void P(R);this.updateTextureDescriptor(u,x,C);const F=this.textureDescriptorPerLayer.get(x);P(null,F?F.img:null)})}fetchBand(u,x,C,P,R=!0){const F=this._mrt;if(!this._isHeaderLoaded||!F)return void P(new Error("Tile header is not ready"));const U=this.actor;if(!U)return void P(new Error("Can't fetch tile band without an actor"));let K;const te=i.B(String(C),i.B(this.tileID.key,u));let re=this._taskQueue.get(te);re?re.add(P):(re=new Set,re.add(P),this._taskQueue.set(te,re));const pe=(we,Re)=>{K.complete(we,Re),we?P(we):(re.forEach(Le=>Le(null,Re)),this._taskQueue.delete(te))},me=(we,Re)=>{if(we)return P(we);const Le=U.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:Re,task:K},pe,void 0,!0);if(x!==null){const Ze=this._workQueuePerLayer.get(x)||[];Ze.push(()=>{Le&&Le.cancel(),K.cancel()}),this._workQueuePerLayer.has(x)||this._workQueuePerLayer.set(x,Ze)}};let fe;try{fe=F.getLayer(u)}catch(we){if(this.state==="reloading")return;throw we}if(!fe)return void P(new Error(`Unknown sourceLayer "${u}"`));if(fe.hasDataForBand(C))return re.forEach(we=>we(null,null)),void this._taskQueue.delete(te);const Ne=fe.getDataRange([C]);if(K=F.createDecodingTask(Ne),!K||K.tasks.length)if(x!==null&&this.flushQueues(x),this.entireBuffer)me(null,this.entireBuffer.slice(Ne.firstByte,Ne.lastByte+1));else{const we=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Ne.firstByte}-${Ne.lastByte}`}}),Re=i.bu(we,me);if(x!==null){const Le=this._fetchQueuePerLayer.get(x)||[];Le.push(()=>{Re.cancel(),K.cancel()}),this._fetchQueuePerLayer.has(x)||this._fetchQueuePerLayer.set(x,Le)}}}updateNeeded(u,x){return(!this.textureDescriptorPerLayer.get(u)||this.textureDescriptorPerLayer.get(u).band!==x||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(u,x,C){if(!this._mrt)return;const P=this._mrt.getLayer(u);if(!P||!P.hasBand(C)||!P.hasDataForBand(C))return;const{bytes:R,tileSize:F,buffer:U,offset:K,scale:te}=P.getBandView(C),re=F+2*U,pe=new i.q({width:re,height:re},R),me=this.texturePerLayer.get(x);me&&me instanceof i.T&&me.update(pe,{premultiply:!1}),this.textureDescriptorPerLayer.set(x,{layer:u,band:C,img:pe,buffer:U,offset:K,tileSize:F,format:P.pixelFormat,mix:[te,256*te,65536*te,16777216*te]})}destroy(u=!1){if(super.destroy(u),delete this._mrt,!u)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 Qx{constructor(u,x){this.max=u,this.onRemove=x,this.reset()}reset(){for(const u in this.data)for(const x of this.data[u])x.timeout&&clearTimeout(x.timeout),this.onRemove(x.value);return this.data={},this.order=[],this}add(u,x,C){const P=u.wrapped().key;this.data[P]===void 0&&(this.data[P]=[]);const R={value:x,timeout:void 0};if(C!==void 0&&(R.timeout=setTimeout(()=>{this.remove(u,R)},C)),this.data[P].push(R),this.order.push(P),this.order.length>this.max){const F=this._getAndRemoveByKey(this.order[0]);F&&this.onRemove(F)}return this}has(u){return u.wrapped().key in this.data}getAndRemove(u){return this.has(u)?this._getAndRemoveByKey(u.wrapped().key):null}_getAndRemoveByKey(u){const x=this.data[u].shift();return x.timeout&&clearTimeout(x.timeout),this.data[u].length===0&&delete this.data[u],this.order.splice(this.order.indexOf(u),1),x.value}getByKey(u){const x=this.data[u];return x?x[0].value:null}get(u){return this.has(u)?this.data[u.wrapped().key][0].value:null}remove(u,x){if(!this.has(u))return this;const C=u.wrapped().key,P=x===void 0?0:this.data[C].indexOf(x),R=this.data[C][P];return this.data[C].splice(P,1),R.timeout&&clearTimeout(R.timeout),this.data[C].length===0&&delete this.data[C],this.onRemove(R.value),this.order.splice(this.order.indexOf(C),1),this}setMaxSize(u){for(this.max=u;this.order.length>this.max;){const x=this._getAndRemoveByKey(this.order[0]);x&&this.onRemove(x)}return this}filter(u){const x=[];for(const C in this.data)for(const P of this.data[C])u(P.value)||x.push(P);for(const C of x)this.remove(C.value.tileID,C)}}class hf{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(u,x,C){const P=String(x);if(this.stateChanges[u]=this.stateChanges[u]||{},this.stateChanges[u][P]=this.stateChanges[u][P]||{},Object.assign(this.stateChanges[u][P],C),this.deletedStates[u]===null){this.deletedStates[u]={};for(const R in this.state[u])R!==P&&(this.deletedStates[u][R]=null)}else if(this.deletedStates[u]&&this.deletedStates[u][P]===null){this.deletedStates[u][P]={};for(const R in this.state[u][P])C[R]||(this.deletedStates[u][P][R]=null)}else for(const R in C)this.deletedStates[u]&&this.deletedStates[u][P]&&this.deletedStates[u][P][R]===null&&delete this.deletedStates[u][P][R]}removeFeatureState(u,x,C){if(this.deletedStates[u]===null)return;const P=String(x);if(this.deletedStates[u]=this.deletedStates[u]||{},C&&x!==void 0)this.deletedStates[u][P]!==null&&(this.deletedStates[u][P]=this.deletedStates[u][P]||{},this.deletedStates[u][P][C]=null);else if(x!==void 0)if(this.stateChanges[u]&&this.stateChanges[u][P])for(C in this.deletedStates[u][P]={},this.stateChanges[u][P])this.deletedStates[u][P][C]=null;else this.deletedStates[u][P]=null;else this.deletedStates[u]=null}getState(u,x){const C=this.state[u]||{},P=this.stateChanges[u]||{},R=this.deletedStates[u];if(R===null)return{};if(x!==void 0){const U=String(x),K=Object.assign({},C[U],P[U]);if(R){const te=R[x];if(te===null)return{};for(const re in te)delete K[re]}return K}const F=Object.assign({},C,P);if(R)for(const U in R)delete F[U];return F}initializeTileState(u,x){u.refreshFeatureState(x)}coalesceChanges(u,x){const C={};for(const P in this.stateChanges){this.state[P]=this.state[P]||{};const R={};for(const F in this.stateChanges[P])this.state[P][F]||(this.state[P][F]={}),Object.assign(this.state[P][F],this.stateChanges[P][F]),R[F]=this.state[P][F];C[P]=R}for(const P in this.deletedStates){this.state[P]=this.state[P]||{};const R={};if(this.deletedStates[P]===null)for(const F in this.state[P])R[F]={},this.state[P][F]={};else for(const F in this.deletedStates[P]){if(this.deletedStates[P][F]===null)this.state[P][F]={};else if(this.state[P][F])for(const U of Object.keys(this.deletedStates[P][F]))delete this.state[P][F][U];R[F]=this.state[P][F]}C[P]=C[P]||{},Object.assign(C[P],R)}if(this.stateChanges={},this.deletedStates={},Object.keys(C).length!==0)for(const P in u)u[P].refreshFeatureState(x)}}class Dd extends i.E{constructor(u,x,C){super(),this.id=u,this._onlySymbols=C,x.on("data",P=>{P.dataType==="source"&&P.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&P.dataType==="source"&&P.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),x.on("error",()=>{this._sourceErrored=!0}),this._source=x,this._tiles={},this._cache=new Qx(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 hf,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(u){this.map=u,this._minTileCacheSize=this._minTileCacheSize===void 0&&u?u._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&u?u._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const u in this._tiles)if(!this._tiles[u].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const u=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,u&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(u,x){return u.isSymbolTile=this._onlySymbols,u.isExtraShadowCaster=this._shadowCasterTiles[u.tileID.key],this._source.loadTile(u,x)}_unloadTile(u){if(this._source.unloadTile)return this._source.unloadTile(u)}_abortTile(u){if(this._source.abortTile)return this._source.abortTile(u)}serialize(){return this._source.serialize()}prepare(u){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const x in this._tiles){const C=this._tiles[x];C.upload(u,this.map?this.map.painter:void 0),C.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(u=>u.tileID).sort(L0).map(u=>u.key)}getRenderableIds(u,x){const C=[];for(const P in this._tiles)this._isIdRenderable(+P,u,x)&&C.push(this._tiles[P]);return u?C.sort((P,R)=>{const F=P.tileID,U=R.tileID,K=new i.P(F.canonical.x,F.canonical.y)._rotate(this.transform.angle),te=new i.P(U.canonical.x,U.canonical.y)._rotate(this.transform.angle);return F.overscaledZ-U.overscaledZ||te.y-K.y||te.x-K.x}).map(P=>P.tileID.key):C.map(P=>P.tileID).sort(L0).map(P=>P.key)}hasRenderableParent(u){const x=this.findLoadedParent(u,0);return!!x&&this._isIdRenderable(x.tileID.key)}_isIdRenderable(u,x,C){return this._tiles[u]&&this._tiles[u].hasData()&&!this._coveredTiles[u]&&(x||!this._tiles[u].holdingForFade())&&(C||!this._shadowCasterTiles[u])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const u in this._tiles)this._tiles[u].state!=="errored"&&this._reloadTile(+u,"reloading")}}_reloadTile(u,x){const C=this._tiles[u];C&&(C.state!=="loading"&&(C.state=x),this._loadTile(C,this._tileLoaded.bind(this,C,u,x)))}_tileLoaded(u,x,C,P,R){if(P){if(u.state="errored",P.status!==404)this._source.fire(new i.y(P,{tile:u}));else{if(this._source.fire(new i.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:u})),!(u.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const U=this.map.painter.terrain;this.update(this.transform,U.getScaledDemTileSize(),!0),U.resetTileLookupCache(this.id)}else this.update(this.transform)}return}u.timeAdded=i.o.now(),C==="expired"&&(u.refreshedUponExpiration=!0),this._setTileReloadTimer(x,u),this._source.type==="raster-dem"&&u.dem&&this._backfillDEM(u),this._state.initializeTileState(u,this.map?this.map.painter:null);let F=new Map;R&&R.responseHeaders&&(F=R.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:u,coord:u.tileID,sourceCacheId:this.id,responseHeaders:F}))}_backfillDEM(u){const x=this.getRenderableIds();for(let P=0;P1||(Math.abs(F)>1&&(Math.abs(F+K)===1?F+=K:Math.abs(F-K)===1&&(F-=K)),R.dem&&P.dem&&(P.dem.backfillBorder(R.dem,F,U),P.neighboringTiles&&P.neighboringTiles[te]&&(P.neighboringTiles[te].backfilled=!0)))}}getTile(u){return this.getTileByID(u.key)}getTileByID(u){return this._tiles[u]}_retainLoadedChildren(u,x,C,P){for(const R in this._tiles){let F=this._tiles[R];if(P[R]||!F.hasData()||F.tileID.overscaledZ<=x||F.tileID.overscaledZ>C)continue;let U=F.tileID;for(;F&&F.tileID.overscaledZ>x+1;){const te=F.tileID.scaledTo(F.tileID.overscaledZ-1);F=this._tiles[te.key],F&&F.hasData()&&(U=te)}let K=U;for(;K.overscaledZ>x;)if(K=K.scaledTo(K.overscaledZ-1),u[K.key]){P[U.key]=U;break}}}findLoadedParent(u,x){if(u.key in this._loadedParentTiles){const C=this._loadedParentTiles[u.key];return C&&C.tileID.overscaledZ>=x?C:null}for(let C=u.overscaledZ-1;C>=x;C--){const P=u.scaledTo(C),R=this._getLoadedTile(P);if(R)return R}}_getLoadedTile(u){const x=this._tiles[u.key];return x&&x.hasData()?x:this._cache.getByKey(this._source.reparseOverscaled?u.wrapped().key:u.canonical.key)}updateCacheSize(u,x){x=x||this._source.tileSize;const C=Math.ceil(u.width/x)+1,P=Math.ceil(u.height/x)+1,R=Math.floor(C*P*5),F=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,R):R,U=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,F):F;this._cache.setMaxSize(U)}handleWrapJump(u){const x=Math.round((u-(this._prevLng===void 0?u:this._prevLng))/360);if(this._prevLng=u,x){const C={};for(const P in this._tiles){const R=this._tiles[P];R.tileID=R.tileID.unwrapTo(R.tileID.wrap+x),C[R.tileID.key]=R}this._tiles=C;for(const P in this._timers)clearTimeout(this._timers[P]),delete this._timers[P];for(const P in this._tiles)this._setTileReloadTimer(+P,this._tiles[P])}}update(u,x,C,P,R){if(this.transform=u,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!C)return;this.updateCacheSize(u,x),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const F=this._source.type==="batched-model";let U,K=this._source.maxzoom;const te=this.map&&this.map.painter?this.map.painter._terrain:null;if(te&&te.sourceCache===this&&te.attenuationRange()){const me=te.attenuationRange()[0],fe=Math.floor(me)-Math.log2(te.getDemUpscale());K>fe&&(K=fe)}if(this.used||this.usedForTerrain){if(this._source.tileID)U=u.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=u.clone();me.tileCoverLift=this.tileCoverLift,U=me.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:K,roundZoom:this._source.roundZoom&&!C,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:F}),this._source.minzoom<=1&&u.projection.name==="globe"&&(U.push(new i.aQ(1,0,1,0,0)),U.push(new i.aQ(1,0,1,1,0)),U.push(new i.aQ(1,0,1,0,1)),U.push(new i.aQ(1,0,1,1,1)))}else if(U=u.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:K,roundZoom:this._source.roundZoom&&!C,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:F}),this._source.hasTile){const me=this._source.hasTile.bind(this._source);U=U.filter(fe=>me(fe))}}else U=[];if(U.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!up(this._source.type)){const me=u.coveringZoomLevel({tileSize:x||this._source.tileSize,roundZoom:this._source.roundZoom&&!C}),fe=Math.min(me,this._source.maxzoom);if(F){const Ne=u.extendTileCover(U,fe);for(const we of Ne)U.push(we)}else if(R){const Ne=u.extendTileCoverToNearPlane(U,this.transform.getFrustum(fe),fe);for(const we of Ne)U.push(we)}else if(this.castsShadows&&P){const Ne=u.extendTileCover(U,fe,P,16);for(const we of Ne)this._shadowCasterTiles[we.key]=!0,U.push(we)}}const re=this._updateRetainedTiles(U);if(up(this._source.type)&&U.length!==0){const me={},fe={},Ne=Object.keys(re);for(const Re of Ne){const Le=re[Re],Ze=this._tiles[Re];if(!Ze||Ze.fadeEndTime&&Ze.fadeEndTime<=i.o.now())continue;const nt=this.findLoadedParent(Le,Math.max(Le.overscaledZ-Dd.maxOverzooming,this._source.minzoom));nt&&(this._addTile(nt.tileID),me[nt.tileID.key]=nt.tileID),fe[Re]=Le}const we=U[U.length-1].overscaledZ;for(const Re in this._tiles){const Le=this._tiles[Re];if(re[Re]||!Le.hasData())continue;let Ze=Le.tileID;for(;Ze.overscaledZ>we;){Ze=Ze.scaledTo(Ze.overscaledZ-1);const nt=this._tiles[Ze.key];if(nt&&nt.hasData()&&fe[Ze.key]){re[Re]=Le.tileID;break}}}for(const Re in me)re[Re]||(this._coveredTiles[Re]=!0,re[Re]=me[Re])}for(const me in re)this._tiles[me].clearFadeHold();const pe=i.bv(this._tiles,re);for(const me of pe){const fe=this._tiles[me];fe.hasSymbolBuckets&&!fe.holdingForFade()?fe.setHoldDuration(this.map._fadeDuration):fe.hasSymbolBuckets&&!fe.symbolFadeFinished()||this._removeTile(+me)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const u in this._tiles)this._tiles[u].holdingForFade()&&this._removeTile(+u)}_updateRetainedTiles(u){const x={};if(u.length===0)return x;const C={},P=u.reduce((te,re)=>Math.min(te,re.overscaledZ),1/0),R=u[0].overscaledZ,F=Math.max(R-Dd.maxOverzooming,this._source.minzoom),U=Math.max(R+Dd.maxUnderzooming,this._source.minzoom),K={};for(const te of u){const re=this._addTile(te);x[te.key]=te,re.hasData()||P=this._source.maxzoom){const me=te.children(this._source.maxzoom)[0],fe=this.getTile(me);if(fe&&fe.hasData()){x[me.key]=me;continue}}else{const me=te.children(this._source.maxzoom);if(x[me[0].key]&&x[me[1].key]&&x[me[2].key]&&x[me[3].key])continue}let pe=re.wasRequested();for(let me=te.overscaledZ-1;me>=F;--me){const fe=te.scaledTo(me);if(C[fe.key]||(C[fe.key]=!0,re=this.getTile(fe),!re&&pe&&(re=this._addTile(fe)),re&&(x[fe.key]=fe,pe=re.wasRequested(),re.hasData())))break}}return x}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const u in this._tiles){const x=[];let C,P=this._tiles[u].tileID;for(;P.overscaledZ>0;){if(P.key in this._loadedParentTiles){C=this._loadedParentTiles[P.key];break}x.push(P.key);const R=P.scaledTo(P.overscaledZ-1);if(C=this._getLoadedTile(R),C)break;P=R}for(const R of x)this._loadedParentTiles[R]=C}}_addTile(u){let x=this._tiles[u.key];if(x)return x.isExtraShadowCaster!==!0||this._shadowCasterTiles[u.key]||this._reloadTile(u.key,"reloading"),x;x=this._cache.getAndRemove(u),x&&(this._setTileReloadTimer(u.key,x),x.tileID=u,this._state.initializeTileState(x,this.map?this.map.painter:null),this._cacheTimers[u.key]&&(clearTimeout(this._cacheTimers[u.key]),delete this._cacheTimers[u.key],this._setTileReloadTimer(u.key,x)));const C=!!x;if(!C){const P=this.map?this.map.painter:null,R=this._source.tileSize*u.overscaleFactor();x=this._source.type==="raster-array"?new P0(u,R,this.transform.tileZoom,P,this._isRaster):new uf(u,R,this.transform.tileZoom,P,this._isRaster,this._source.worldview),this._loadTile(x,this._tileLoaded.bind(this,x,u.key,x.state))}return x.uses++,this._tiles[u.key]=x,C||this._source.fire(new i.z("dataloading",{tile:x,coord:x.tileID,dataType:"source"})),x}_setTileReloadTimer(u,x){u in this._timers&&(clearTimeout(this._timers[u]),delete this._timers[u]);const C=x.getExpiryTimeout();C&&(this._timers[u]=setTimeout(()=>{this._reloadTile(u,"expired"),delete this._timers[u]},C))}_removeTile(u){const x=this._tiles[u];x&&(x.uses--,delete this._tiles[u],this._timers[u]&&(clearTimeout(this._timers[u]),delete this._timers[u]),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 u in this._tiles)this._removeTile(+u);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(u,x,C){const P=[],R=this.transform;if(!R)return P;const F=R.projection.name==="globe",U=i.aF(R.center.lng);for(const K in this._tiles){const te=this._tiles[K];if(C&&te.clearQueryDebugViz(),te.holdingForFade())continue;let re;if(F){const pe=te.tileID.canonical;if(pe.z===0){const me=[Math.abs(i.aA(U,...Ju(pe,-1))-U),Math.abs(i.aA(U,...Ju(pe,1))-U)];re=[0,2*me.indexOf(Math.min(...me))-1]}else{const me=[Math.abs(i.aA(U,...Ju(pe,-1))-U),Math.abs(i.aA(U,...Ju(pe,0))-U),Math.abs(i.aA(U,...Ju(pe,1))-U)];re=[me.indexOf(Math.min(...me))-1]}}else re=[0];for(const pe of re){const me=u.containsTile(te,R,x,pe);me&&P.push(me)}}return P}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(u){return this._getRenderableCoordinates(u)}_getRenderableCoordinates(u,x){const C=this.getRenderableIds(u,x).map(R=>this._tiles[R].tileID),P=this.transform.projection.name==="globe";for(const R of C)R.projMatrix=this.transform.calculateProjMatrix(R.toUnwrapped()),R.expandedProjMatrix=P?this.transform.calculateProjMatrix(R.toUnwrapped(),!1,!0):R.projMatrix;return C}sortCoordinatesByDistance(u){const x=u.slice(),C=this.transform._camera.position,P=this.transform._camera.forward(),R={};for(const F of x){const U=1/(1<R[F.key]-R[U.key]),x}hasTransition(){if(this._source.hasTransition())return!0;if(up(this._source.type))for(const u in this._tiles){const x=this._tiles[u];if(x.fadeEndTime!==void 0&&x.fadeEndTime>=i.o.now())return!0}return!1}setFeatureState(u,x,C){this._state.updateState(u=u||"_geojsonTileLayer",x,C)}removeFeatureState(u,x,C){this._state.removeFeatureState(u=u||"_geojsonTileLayer",x,C)}getFeatureState(u,x){return this._state.getState(u=u||"_geojsonTileLayer",x)}setDependencies(u,x,C){const P=this._tiles[u];P&&P.setDependencies(x,C)}reloadTilesForDependencies(u,x){for(const C in this._tiles)this._tiles[C].hasDependency(u,x)&&this._reloadTile(+C,"reloading");this._cache.filter(C=>!C.hasDependency(u,x))}_preloadTiles(u,x){if(!this._sourceLoaded){const K=()=>{this._sourceLoaded&&(this._source.off("data",K),this._preloadTiles(u,x))};return void this._source.on("data",K)}const C=new Map,P=Array.isArray(u)?u:[u],R=this.map.painter.terrain,F=this.usedForTerrain&&R?R.getScaledDemTileSize():this._source.tileSize;for(const K of P){const te=K.coveringTiles({tileSize:F,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const re of te)C.set(re.key,re);this.usedForTerrain&&K.updateElevation(!1)}const U=Array.from(C.values());i.bw(U,(K,te)=>{const re=new uf(K,this._source.tileSize*K.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(re,pe=>{this._source.type==="raster-dem"&&re.dem&&this._backfillDEM(re),te(pe,re)})},x)}}function L0(N,u){const x=Math.abs(2*N.wrap)-+(N.wrap<0),C=Math.abs(2*u.wrap)-+(u.wrap<0);return N.overscaledZ-u.overscaledZ||C-x||u.canonical.y-N.canonical.y||u.canonical.x-N.canonical.x}function up(N){return N==="raster"||N==="image"||N==="video"||N==="custom"}function Ju(N,u){const x=1<0:C.type==="building"?P=!C.isHidden(u)&&C.paint.get("building-opacity")>0:C.type==="model"&&(P=!C.isHidden(u)&&C.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!P&&x.visible,x.visible=P}}updateZOffset(u,x){this.currentBuildingBuckets=[];for(const P of this.layers){const R=P.layer,F=this.style.getLayerSourceCache(R);let U=1;R.type==="fill-extrusion"?U=P.visible?R.paint.get("fill-extrusion-vertical-scale"):0:R.type==="building"&&(U=P.visible?R.paint.get("building-vertical-scale"):0);let K=F?F.getTile(x):null;if(!K&&F)for(const te in F._tiles){const re=F._tiles[te];if(x.canonical.isChildOf(re.tileID.canonical)){K=re;break}}this.currentBuildingBuckets.push({bucket:K?K.getBucket(R):null,tileID:K?K.tileID:x,verticalScale:U})}u.hasAnyZOffset=!1;let C=!1;for(let P=0;P{C in u&&(x[C]=u[C])}),x}function Jx(N){N=N.slice();const u=Object.create(null);for(let x=0;x0?(P-F)/U:0;return this.points[R].mult(1-K).add(this.points[x].mult(K))}}class vn{constructor(u,x,C){const P=this.boxCells=[],R=this.circleCells=[];this.xCellCount=Math.ceil(u/C),this.yCellCount=Math.ceil(x/C);for(let F=0;Fthis.width||P<0||x>this.height)return!R&&[];const U=[];if(u<=0&&x<=0&&this.width<=C&&this.height<=P){if(R)return!0;for(let K=0;K0:U}_queryCircle(u,x,C,P,R){const F=u-C,U=u+C,K=x-C,te=x+C;if(U<0||F>this.width||te<0||K>this.height)return!P&&[];const re=[];return this._forEachCell(F,K,U,te,this._queryCellCircle,re,{hitTest:P,circle:{x:u,y:x,radius:C},seenUids:{box:{},circle:{}}},R),P?re.length>0:re}query(u,x,C,P,R){return this._query(u,x,C,P,!1,R)}hitTest(u,x,C,P,R){return this._query(u,x,C,P,!0,R)}hitTestCircle(u,x,C,P){return this._queryCircle(u,x,C,!0,P)}_queryCell(u,x,C,P,R,F,U,K){const te=U.seenUids,re=this.boxCells[R];if(re!==null){const me=this.bboxes;for(const fe of re)if(!te.box[fe]){te.box[fe]=!0;const Ne=4*fe;if(u<=me[Ne+2]&&x<=me[Ne+3]&&C>=me[Ne+0]&&P>=me[Ne+1]&&(!K||K(this.boxKeys[fe]))){if(U.hitTest)return F.push(!0),!0;F.push({key:this.boxKeys[fe],x1:me[Ne],y1:me[Ne+1],x2:me[Ne+2],y2:me[Ne+3]})}}}const pe=this.circleCells[R];if(pe!==null){const me=this.circles;for(const fe of pe)if(!te.circle[fe]){te.circle[fe]=!0;const Ne=3*fe;if(this._circleAndRectCollide(me[Ne],me[Ne+1],me[Ne+2],u,x,C,P)&&(!K||K(this.circleKeys[fe]))){if(U.hitTest)return F.push(!0),!0;{const we=me[Ne],Re=me[Ne+1],Le=me[Ne+2];F.push({key:this.circleKeys[fe],x1:we-Le,y1:Re-Le,x2:we+Le,y2:Re+Le})}}}}}_queryCellCircle(u,x,C,P,R,F,U,K){const te=U.circle,re=U.seenUids,pe=this.boxCells[R];if(pe!==null){const fe=this.bboxes;for(const Ne of pe)if(!re.box[Ne]){re.box[Ne]=!0;const we=4*Ne;if(this._circleAndRectCollide(te.x,te.y,te.radius,fe[we+0],fe[we+1],fe[we+2],fe[we+3])&&(!K||K(this.boxKeys[Ne])))return F.push(!0),!0}}const me=this.circleCells[R];if(me!==null){const fe=this.circles;for(const Ne of me)if(!re.circle[Ne]){re.circle[Ne]=!0;const we=3*Ne;if(this._circlesCollide(fe[we],fe[we+1],fe[we+2],te.x,te.y,te.radius)&&(!K||K(this.circleKeys[Ne])))return F.push(!0),!0}}}_forEachCell(u,x,C,P,R,F,U,K){const te=this._convertToXCellCoord(u),re=this._convertToYCellCoord(x),pe=this._convertToXCellCoord(C),me=this._convertToYCellCoord(P);for(let fe=te;fe<=pe;fe++)for(let Ne=re;Ne<=me;Ne++)if(R.call(this,u,x,C,P,this.xCellCount*Ne+fe,F,U,K))return}_convertToXCellCoord(u){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(u*this.xScale)))}_convertToYCellCoord(u){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(u*this.yScale)))}_circlesCollide(u,x,C,P,R,F){const U=P-u,K=R-x,te=C+F;return te*te>U*U+K*K}_circleAndRectCollide(u,x,C,P,R,F,U){const K=(F-P)/2,te=Math.abs(u-(P+K));if(te>K+C)return!1;const re=(U-R)/2,pe=Math.abs(x-(R+re));if(pe>re+C)return!1;if(te<=K||pe<=re)return!0;const me=te-K,fe=pe-re;return me*me+fe*fe<=C*C}}const fa={unknown:0,flipRequired:1,flipNotRequired:2},Qn=Math.tan(85*Math.PI/180);function La(N,u,x,C,P,R,F){const U=i.bC();if(x)if(R.name==="globe"){const K=i.bD(P,u);i.aB(U,U,K)}else{const K=i.bE([],F);U[0]=K[0],U[1]=K[1],U[4]=K[2],U[5]=K[3],C||i.bB(U,U,P.angle)}else i.aB(U,P.labelPlaneMatrix,N);return U}function _m(N,u,x,C,P,R,F){const U=La(N,u,x,C,P,R,F);return R.name==="globe"&&x||(U[2]=U[6]=U[10]=U[14]=0),U}function Nu(N,u,x,C,P,R,F){if(x){if(R.name==="globe"){const U=La(N,u,x,C,P,R,F);return i.bl(U,U),i.aB(U,N,U),U}{const U=i.bz(N),K=i.bA([]);return K[0]=F[0],K[1]=F[1],K[4]=F[2],K[5]=F[3],i.aB(U,U,K),C||i.bB(U,U,-P.angle),U}}return P.glCoordMatrix}function Yl(N,u,x,C){const P=[N,u,x,1];x?i.aC(P,P,C):Er(P,P,C);const R=P[3];return P[0]/=R,P[1]/=R,P[2]/=R,P}function Da(N,u){return Math.min(.5+N/u*.5,1.5)}function FN(N,u){const x=N[0]/N[3],C=N[1]/N[3];return x>=-u[0]&&x<=u[0]&&C>=-u[1]&&C<=u[1]}function gL(N,u,x,C,P,R,F,U,K,te,re=1){const pe=x.transform,me=C?N.textSizeData:N.iconSizeData,fe=i.bK(me,x.transform.zoom,re),Ne=pe.projection.name==="globe",we=[256/x.width*2+1,256/x.height*2+1],Re=C?N.text.dynamicLayoutVertexArray:N.icon.dynamicLayoutVertexArray;Re.clear();let Le=null;Ne&&(Le=C?N.text.globeExtVertexArray:N.icon.globeExtVertexArray);const Ze=N.lineVertexArray,nt=C?N.text.placedSymbolArray:N.icon.placedSymbolArray,Xe=x.transform.width/x.transform.height;let Mt,gt=!1;for(let jt=0;jtMath.abs(x)?{useVertical:!0}:N===i.bL.vertical?C>0?{needsFlipping:!0}:null:u!==fa.unknown&&function(P,R){return P===0||Math.abs(R/P)>Qn}(x,C)?u===fa.flipRequired?{needsFlipping:!0}:null:x<0?{needsFlipping:!0}:null}function gM(N,u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re,Le,Ze,nt){const Xe=u/24,Mt=N.lineOffsetX*Xe,gt=N.lineOffsetY*Xe,{lineStartIndex:jt,glyphStartIndex:ft,numGlyphs:ht,segment:At,writingMode:Ut,flipState:Bt}=N,ts=jt+N.lineLength,rs=ms=>{if(re){const[is,es,ks]=ms.up,Gs=te.length;i.bN(re,Gs+0,is,es,ks),i.bN(re,Gs+1,is,es,ks),i.bN(re,Gs+2,is,es,ks),i.bN(re,Gs+3,is,es,ks)}const[Ds,Yt,Pt]=ms.point;i.bO(te,Ds,Yt,Pt,ms.angle)};if(ht>1){const ms=xL(Xe,U,Mt,gt,x,pe,me,N,K,R,fe,we,!1,Re,Le,Ze,nt);if(!ms)return{notEnoughRoom:!0};if(C&&!x){let[Ds,Yt,Pt]=ms.first.point,[is,es,ks]=ms.last.point;[Ds,Yt]=Yl(Ds,Yt,Pt,F),[is,es]=Yl(is,es,ks,F);const Gs=Jr(Ut,Bt,(is-Ds)*Ne,es-Yt);if(N.flipState=Gs&&Gs.needsFlipping?fa.flipRequired:fa.flipNotRequired,Gs)return Gs}rs(ms.first);for(let Ds=ft+1;Ds0?is:Dh(me,Pt,Ds,1,P,void 0,Re,Le.canonical),ks=Jr(Ut,Bt,(es[0]-Ds[0])*Ne,es[1]-Ds[1]);if(N.flipState=ks&&ks.needsFlipping?fa.flipRequired:fa.flipNotRequired,ks)return ks}const ms=O0(Xe*U.getoffsetX(ft),Mt,gt,x,pe,me,At,jt,ts,K,R,fe,we,!1,!1,Re,Le,Ze,nt);if(!ms)return{notEnoughRoom:!0};rs(ms)}return{}}function j_(N,u,x,C,P){const{x:R,y:F,z:U}=C.projectTilePoint(N.x,N.y,u);if(!P)return Yl(R,F,U,x);const[K,te,re]=P.getElevation(N,P.elevation,P.elevationFeature);return Yl(R+K,F+te,U+re,x)}function Dh(N,u,x,C,P,R,F,U){const K=j_(N.sub(u)._unit()._add(N),U,P,F,R);return i.av(K,x,K),i.aw(K,K),i.bH(K,x,K,C)}function O0(N,u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re,Le,Ze){const nt=C?N-u:N+u;let Xe=nt>0?1:-1,Mt=0;C&&(Xe*=-1,Mt=Math.PI),Xe<0&&(Mt+=Math.PI);let gt=U+F+(Xe>0?0:1)|0,jt=P,ft=P,ht=0,At=0;const Ut=Math.abs(nt),Bt=[],ts=[];let rs=R,ms=rs,Ds=i.bF([]);const Yt=()=>Dh(ms,rs,ft,Ut-ht+1,re,me,we,Re.canonical);for(;ht+At<=Ut;){if(gt+=Xe,gt=K)return null;if(ft=jt,ms=rs,Bt.push(ft),fe&&ts.push(ms),rs=new i.P(te.getx(gt),te.gety(gt)),jt=pe[gt],!jt){const yr=j_(rs,Re.canonical,re,we,me);jt=yr[3]>0?pe[gt]=yr:Yt()}ht+=At;const Os=i.av([],jt,ft),wr=i.bG(ft,jt);if(x&&wr>0&&At>0&&i.bJ(Ds,Os)/(At*wr)0,nt),jt=te*gt.perspectiveRatio,ft=(C.x1*x+U.x-C.padding)*jt+gt.point.x,ht=(C.y1*x+U.y-C.padding)*jt+gt.point.y,At=(C.x2*x+U.x+C.padding)*jt+gt.point.x,Ut=(C.y2*x+U.y+C.padding)*jt+gt.point.y,Bt=gt.perspectiveRatio<=.55||gt.occluded;return!this.isInsideGrid(ft,ht,At,Ut)||!K&&this.grid.hitTest(ft,ht,At,Ut,pe)||Bt?{box:[],offscreen:!1,occluded:gt.occluded}:{box:[ft,ht,At,Ut],offscreen:this.isOffscreen(ft,ht,At,Ut),occluded:!1}}placeCollisionCircles(u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re){const Le=[],Ze=this.transform.elevation,nt=u.getProjection(),Xe=u.elevationType==="road",Mt=!!Ze||Xe,gt=i.bV.getAtTileOffsetFunc(Re,this.transform.center.lat,this.transform.worldSize,nt),jt=new i.P(C.tileAnchorX,C.tileAnchorY),ft=new i.P(C.tileAnchorX,C.tileAnchorY);let{x:ht,y:At,z:Ut}=nt.projectTilePoint(ft.x,ft.y,Re.canonical),Bt=null;if(Mt){const wr=Xe?u.getElevationFeatureForText(P):null;Bt={getElevation:gt,elevation:Ze,elevationFeature:wr};const[yr,ir,hr]=gt(jt,Ze,wr);ht+=yr,At+=ir,Ut+=hr}const ts=nt.name==="globe",rs=this.projectAndGetPerspectiveRatio(K,ht,At,Ut,Re,ts||!!Ze||this.transform.pitch>0,nt),{perspectiveRatio:ms}=rs,Ds=(me?U/ms:U*ms)/i.bY,Yt=Yl(ht,At,Ut,te),Pt=C.lineOffsetX*Ds,is=C.lineOffsetY*Ds,es=i.an(u.layers[0].layout.get("text-max-angle")),ks=Math.cos(es),Gs=rs.signedDistanceFromCamera>0?xL(Ds,F,Pt,is,Xe&&C.flipState===1,Yt,ft,C,R,te,{},Mt&&!me?Bt:null,me&&Mt,nt,Re,me,ks):null;let dr=!1,qs=!1,Os=!0;if(Gs&&!rs.occluded){const wr=.5*Ne*ms+we,yr=new i.P(-100,-100),ir=new i.P(this.screenRightBoundary,this.screenBottomBoundary),hr=new dn,{first:Fr,last:_n}=Gs,ia=Fr.path.length;let Oa=[];for(let un=ia-1;un>=1;un--)Oa.push(Fr.path[un]);for(let un=1;un<_n.path.length;un++)Oa.push(_n.path[un]);const Nr=2.5*wr;re&&(Oa=Oa.map(([un,Ba,ii],Ja)=>(Mt&&!ts&&(ii=gt(Jaun[3]<=0)&&(Oa=[]));let Ca=[];if(Oa.length>0){let un=1/0,Ba=-1/0,ii=1/0,Ja=-1/0;for(const Na of Oa)un=Math.min(un,Na[0]),ii=Math.min(ii,Na[1]),Ba=Math.max(Ba,Na[0]),Ja=Math.max(Ja,Na[1]);Ba>=yr.x&&un<=ir.x&&Ja>=yr.y&&ii<=ir.y&&(Ca=[Oa.map(Na=>new i.P(Na[0],Na[1]))],(unir.x||iiir.y)&&(Ca=i.bW(Ca,yr.x,yr.y,ir.x,ir.y)))}for(const un of Ca){hr.reset(un,.25*wr);let Ba=0;Ba=hr.length<=.5*wr?1:Math.ceil(hr.paddedLength/Nr)+1;for(let ii=0;ii0?(i.aC(K,K,u),this.fogState&&R&&U.name!=="globe"&&(te=function(me,fe,Ne,we,Re,Le){const Ze=Le.calculateFogTileMatrix(Re),nt=[fe,Ne,we];return i.af(nt,nt,Ze),ur(me,i.ag(nt),Le.pitch,Le._fov)}(this.fogState,x,C,P,R.toUnwrapped(),this.transform)>.9)):Er(K,K,u);const re=K[3];return{point:new i.P((K[0]/re+1)/2*this.transform.width+ga,(-K[1]/re+1)/2*this.transform.height+ga),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(U)/re*.5,1.5),signedDistanceFromCamera:re,occluded:F&&K[2]>re||te}}isOffscreen(u,x,C,P){return C=this.screenRightBoundary||Pthis.screenBottomBoundary}isInsideGrid(u,x,C,P){return C>=0&&u=0&&xC.collisionGroupID===x}}return this.collisionGroups[u]}}function Jc(N,u,x,C,P){const{horizontalAlign:R,verticalAlign:F}=i.c1(N),U=-(R-.5)*u,K=-(F-.5)*x,te=i.c2(N,C);return new i.P(U+te[0]*P,K+te[1]*P)}function Ko(N,u,x,C,P){const R=new i.P(N,u);return x&&R._rotate(C?P:-P),R}class Wle{constructor(u,x,C,P,R,F){this.transform=u.clone(),this.projection=u.projection.name,this.collisionIndex=new ai(this.transform,R),this.buildingIndex=F,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=x,this.retainedQueryData={},this.collisionGroups=new N_(C),this.collisionCircleArrays={},this.prevPlacement=P,P&&(P.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(u,x,C,P,R=1){const F=C.getBucket(x),U=C.latestFeatureIndex;if(!F||!U||x.fqid!==F.layerIds[0])return;const K=F.layers[0].layout,te=F.layers[0].paint,re=C.collisionBoxArray,pe=Math.pow(2,this.transform.zoom-C.tileID.overscaledZ),me=C.tileSize/i.al,fe=C.tileID.toUnwrapped();this.transform.setProjection(F.projection);const Ne=(we=C.tileID,Re=F.getProjection(),Le=this.transform,Re.name===this.projection?Le.calculateProjMatrix(we.toUnwrapped()):Nt(Le,Re,we));var we,Re,Le;const Ze=K.get("text-pitch-alignment")==="map",nt=K.get("text-rotation-alignment")==="map";x.compileFilter(x.options);const Xe=x.dynamicFilter(),Mt=x.dynamicFilterNeedsFeature(),gt=this.transform.calculatePixelsToTileUnitsMatrix(C),jt=_m(Ne,C.tileID.canonical,Ze,nt,this.transform,F.getProjection(),gt);let ft=null;const ht=F.getProjection().createInversionMatrix(this.transform,C.tileID.canonical);if(Ze){const Pt=Nu(Ne,C.tileID.canonical,Ze,nt,this.transform,F.getProjection(),gt);ft=i.aB([],this.transform.labelPlaneMatrix,Pt)}let At=null;Xe&&C.latestFeatureIndex&&(At={unwrappedTileID:fe,dynamicFilter:Xe,dynamicFilterNeedsFeature:Mt}),this.retainedQueryData[F.bucketInstanceId]=new k_(F.bucketInstanceId,U,F.sourceLayerIndex,F.index,C.tileID);const[Ut,Bt]=F.layers[0].layout.get("text-size-scale-range"),ts=i.aA(R,Ut,Bt),[rs,ms]=K.get("icon-size-scale-range"),Ds=i.aA(R,rs,ms),Yt={bucket:F,layout:K,paint:te,posMatrix:Ne,invMatrix:ht,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:jt,labelToScreenMatrix:ft,clippingData:At,scale:pe,textPixelRatio:me,holdingForFade:C.holdingForFade(),collisionBoxArray:re,partiallyEvaluatedTextSize:i.bK(F.textSizeData,this.transform.zoom,ts),partiallyEvaluatedIconSize:i.bK(F.iconSizeData,this.transform.zoom,Ds),collisionGroup:this.collisionGroups.get(F.sourceID),latestFeatureIndex:C.latestFeatureIndex};if(P)for(const Pt of F.sortKeyRanges){const{sortKey:is,symbolInstanceStart:es,symbolInstanceEnd:ks}=Pt;u.push({sortKey:is,symbolInstanceStart:es,symbolInstanceEnd:ks,parameters:Yt})}else u.push({symbolInstanceStart:0,symbolInstanceEnd:F.symbolInstances.length,parameters:Yt})}attemptAnchorPlacement(u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re,Le,Ze,nt,Xe,Mt){const{textOffset0:gt,textOffset1:jt,crossTileID:ft}=we,ht=[gt,jt],At=Jc(u,F,U,ht,K),Ut=this.collisionIndex.placeCollisionBox(Le,K,x,C,P,R,Ko(At.x,At.y,te,re,this.transform.angle),Ne,pe,me,fe.predicate);if(nt){const Bt=Le.getSymbolInstanceIconSize(Mt,this.transform.zoom,we.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Le,Bt,nt,C,P,R,Ko(At.x,At.y,te,re,this.transform.angle),Ne,pe,me,fe.predicate).box.length===0)return}if(Ut.box.length>0){let Bt;return this.prevPlacement&&this.prevPlacement.variableOffsets[ft]&&this.prevPlacement.placements[ft]&&this.prevPlacement.placements[ft].text&&(Bt=this.prevPlacement.variableOffsets[ft].anchor),this.variableOffsets[ft]={textOffset:ht,width:F,height:U,anchor:u,textScale:K,prevAnchor:Bt},this.markUsedJustification(Le,u,we,Ze),Le.allowVerticalPlacement&&(this.markUsedOrientation(Le,Ze,we),this.placedOrientations[ft]=Ze),{shift:At,placedGlyphBoxes:Ut}}}placeLayerBucketPart(u,x,C,P,R=1){const{bucket:F,layout:U,paint:K,posMatrix:te,textLabelPlaneMatrix:re,labelToScreenMatrix:pe,clippingData:me,textPixelRatio:fe,mercatorCenter:Ne,invMatrix:we,holdingForFade:Re,collisionBoxArray:Le,partiallyEvaluatedTextSize:Ze,partiallyEvaluatedIconSize:nt,collisionGroup:Xe,latestFeatureIndex:Mt}=u.parameters,gt=U.get("text-optional"),jt=U.get("icon-optional"),ft=U.get("text-allow-overlap"),ht=U.get("icon-allow-overlap"),At=U.get("text-rotation-alignment")==="map",Ut=U.get("icon-rotation-alignment")==="map",Bt=U.get("text-pitch-alignment")==="map",ts=K.get("symbol-z-offset"),rs=U.get("symbol-elevation-reference")==="sea",ms=U.get("symbol-placement"),[Ds,Yt]=U.get("text-size-scale-range"),[Pt,is]=U.get("icon-size-scale-range"),es=i.aA(R,Ds,Yt),ks=i.aA(R,Pt,is),Gs=U.get("text-variable-anchor"),dr=At&&ms!=="point",qs=Ut&&ms!=="point",Os=Gs&&F.hasTextData(),wr=F.hasIconTextFit()&&Os&&F.hasIconData();this.transform.setProjection(F.projection);const yr=Os||dr,ir=qs||wr;let hr=ft&&(ht||!F.hasIconData()||jt),Fr=ht&&(ft||!F.hasTextData()||gt);const _n=!ts.isConstant();!F.collisionArrays&&Le&&F.deserializeCollisionBoxes(Le),C&&P&&F.updateCollisionDebugBuffers(this.transform.zoom,Le,es,ks);const ia=(Nr,Ca,un)=>{const{crossTileID:Ba,numVerticalGlyphVertices:ii}=Nr;let Ja=null;if(me&&me.dynamicFilterNeedsFeature||_n){const yo=this.retainedQueryData[F.bucketInstanceId];Ja=Mt.loadFeature({featureIndex:Nr.featureIndex,bucketIndex:yo.bucketIndex,sourceLayerIndex:yo.sourceLayerIndex,layoutVertexArrayOffset:0});const Mo=Ja.properties?Ja.properties.worldview:null;if(F.localizable&&F.worldview&&typeof Mo=="string")if(Mo==="all")Ja.properties.$localized=!0;else{if(!Mo.split(",").includes(F.worldview))return;Ja.properties.$localized=!0,Ja.properties.worldview=F.worldview}}if(me&&!(0,me.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:F.worldview},Ja,this.retainedQueryData[F.bucketInstanceId].tileID.canonical,new i.P(Nr.tileAnchorX,Nr.tileAnchorY),this.transform.calculateDistanceTileData(me.unwrappedTileID)))return this.placements[Ba]=new Ka(!1,!1,!1,!0),void x.add(Ba);const Na=ts.evaluate(Ja,{});if(x.has(Ba))return;if(Re)return void(this.placements[Ba]=new Ka(!1,!1,!1));let Mn=!1,Fa=!1,co=!0,$i=!1,$a=!1,ya=null,Tn={box:null,offscreen:null,occluded:null},Ei={box:null},jo=null,no=null,pi=null,$d=0,$c=0,cl=0;un.textFeatureIndex?$d=un.textFeatureIndex:Nr.useRuntimeCollisionCircles&&($d=Nr.featureIndex),un.verticalTextFeatureIndex&&($c=un.verticalTextFeatureIndex);const td=F.elevationFeatures?F.elevationFeatures[Nr.elevationFeatureIndex]:void 0,sd=yo=>{yo.tileID=this.retainedQueryData[F.bucketInstanceId].tileID;const Mo=this.transform.elevation;yo.elevation=rs?Na:Na+i.bV.getAtTileOffset(yo.tileID,new i.P(yo.tileAnchorX,yo.tileAnchorY),Mo,td),yo.elevation+=Nr.zOffset},gc=un.textBox;if(gc){sd(gc);const yo=fi=>{let zo=i.bL.horizontal;if(F.allowVerticalPlacement&&!fi&&this.prevPlacement){const uo=this.prevPlacement.placedOrientations[Ba];uo&&(this.placedOrientations[Ba]=uo,zo=uo,this.markUsedOrientation(F,zo,Nr))}return zo},Mo=(fi,zo)=>{if(F.allowVerticalPlacement&&ii>0&&un.verticalTextBox){for(const uo of F.writingModes)if(uo===i.bL.vertical?(Tn=zo(),Ei=Tn):Tn=fi(),Tn&&Tn.box&&Tn.box.length)break}else Tn=fi()};if(Gs){let fi=Gs;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ba]){const ao=this.prevPlacement.variableOffsets[Ba];fi.indexOf(ao.anchor)>0&&(fi=fi.filter(qh=>qh!==ao.anchor),fi.unshift(ao.anchor))}const zo=(ao,qh,J_)=>{const Cm=F.getSymbolInstanceTextSize(Ze,Nr,this.transform.zoom,Ca),eb=(ao.x2-ao.x1)*Cm+2*ao.padding,iv=(ao.y2-ao.y1)*Cm+2*ao.padding,wp=Nr.hasIconTextFit&&!ht?qh:null;wp&&sd(wp);let Sf={box:[],offscreen:!1,occluded:!1};const ov=ft?2*fi.length:fi.length;for(let Xg=0;Xg=fi.length,Nr,Ca,F,J_,wp,Ze,nt);if(Cf&&(Sf=Cf.placedGlyphBoxes,Sf&&Sf.box&&Sf.box.length)){Mn=!0,ya=Cf.shift;break}}return Sf};Mo(()=>zo(gc,un.iconBox,i.bL.horizontal),()=>{const ao=un.verticalTextBox;return ao&&sd(ao),F.allowVerticalPlacement&&!(Tn&&Tn.box&&Tn.box.length)&&ii>0&&ao?zo(ao,un.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Tn&&(Mn=Tn.box,co=Tn.offscreen,$i=Tn.occluded);const uo=yo(!(!Tn||!Tn.box));if(!Mn&&this.prevPlacement){const ao=this.prevPlacement.variableOffsets[Ba];ao&&(this.variableOffsets[Ba]=ao,this.markUsedJustification(F,ao.anchor,Nr,uo))}}else{const fi=(zo,uo)=>{const ao=F.getSymbolInstanceTextSize(Ze,Nr,this.transform.zoom,Ca),qh=this.collisionIndex.placeCollisionBox(F,ao,zo,Ne,we,yr,new i.P(0,0),ft,fe,te,Xe.predicate);return qh&&qh.box&&qh.box.length&&(this.markUsedOrientation(F,uo,Nr),this.placedOrientations[Ba]=uo),qh};Mo(()=>fi(gc,i.bL.horizontal),()=>{const zo=un.verticalTextBox;return F.allowVerticalPlacement&&ii>0&&zo?(sd(zo),fi(zo,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),yo(!!(Tn&&Tn.box&&Tn.box.length))}}if(jo=Tn,Mn=jo&&jo.box&&jo.box.length>0,co=jo&&jo.offscreen,$i=jo&&jo.occluded,Nr.useRuntimeCollisionCircles){const yo=Nr.centerJustifiedTextSymbolIndex>=0?Nr.centerJustifiedTextSymbolIndex:Nr.verticalPlacedTextSymbolIndex,Mo=F.text.placedSymbolArray.get(yo),fi=i.bM(F.textSizeData,Ze,Mo),zo=U.get("text-padding");no=this.collisionIndex.placeCollisionCircles(F,ft,Mo,yo,F.lineVertexArray,F.glyphOffsetArray,fi,te,re,pe,C,Bt,Xe.predicate,Nr.collisionCircleDiameter*fi/i.bY,zo,this.retainedQueryData[F.bucketInstanceId].tileID),Mn=ft||no.circles.length>0&&!no.collisionDetected,co=co&&no.offscreen,$i=no.occluded}if(un.iconFeatureIndex&&(cl=un.iconFeatureIndex),un.iconBox){const yo=Mo=>{sd(Mo);const fi=Nr.hasIconTextFit&&ya?Ko(ya.x,ya.y,At,Bt,this.transform.angle):new i.P(0,0),zo=F.getSymbolInstanceIconSize(nt,this.transform.zoom,Nr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(F,zo,Mo,Ne,we,ir,fi,ht,fe,te,Xe.predicate)};Ei&&Ei.box&&Ei.box.length&&un.verticalIconBox?(pi=yo(un.verticalIconBox),Fa=pi.box.length>0):(pi=yo(un.iconBox),Fa=pi.box.length>0),co=co&&pi.offscreen,$a=pi.occluded}const nh=gt||Nr.numHorizontalGlyphVertices===0&&ii===0,Uh=jt||Nr.numIconVertices===0;if(nh||Uh?Uh?nh||(Fa=Fa&&Mn):Mn=Fa&&Mn:Fa=Mn=Fa&&Mn,Mn&&jo&&jo.box&&this.collisionIndex.insertCollisionBox(jo.box,U.get("text-ignore-placement"),F.bucketInstanceId,Ei&&Ei.box&&$c?$c:$d,Xe.ID),Fa&&pi&&this.collisionIndex.insertCollisionBox(pi.box,U.get("icon-ignore-placement"),F.bucketInstanceId,cl,Xe.ID),no&&(Mn&&this.collisionIndex.insertCollisionCircles(no.circles,U.get("text-ignore-placement"),F.bucketInstanceId,$d,Xe.ID),C)){const yo=F.bucketInstanceId;let Mo=this.collisionCircleArrays[yo];Mo===void 0&&(Mo=this.collisionCircleArrays[yo]=new zN);for(let fi=0;fi=0;--Ca){const un=Nr[Ca];ia(F.symbolInstances.get(un),un,F.collisionArrays[un])}F.hasAnyZOffset&&i.w(`${F.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(F.hasAnyZOffset){const Nr=F.getSortedIndexesByZOffset();for(let Ca=0;Ca=0&&(u.text.placedSymbolArray.get(R).crossTileID=pe>=0&&R!==pe?0:te),F>=0&&(u.text.placedSymbolArray.get(F).crossTileID=pe>=0&&F!==pe?0:te),U>=0&&(u.text.placedSymbolArray.get(U).crossTileID=pe>=0&&U!==pe?0:te),K>=0&&(u.text.placedSymbolArray.get(K).crossTileID=pe>=0&&K!==pe?0:te)}markUsedOrientation(u,x,C){const P=x===i.bL.horizontal||x===i.bL.horizontalOnly?x:0,R=x===i.bL.vertical?x:0,{leftJustifiedTextSymbolIndex:F,centerJustifiedTextSymbolIndex:U,rightJustifiedTextSymbolIndex:K,verticalPlacedTextSymbolIndex:te}=C,re=u.text.placedSymbolArray;F>=0&&(re.get(F).placedOrientation=P),U>=0&&(re.get(U).placedOrientation=P),K>=0&&(re.get(K).placedOrientation=P),te>=0&&(re.get(te).placedOrientation=R)}commit(u){this.commitTime=u,this.zoomAtLastRecencyCheck=this.transform.zoom;const x=this.prevPlacement;let C=!1;this.prevZoomAdjustment=x?x.zoomAdjustment(this.transform.zoom):0;const P=x?x.symbolFadeChange(u):1,R=x?x.opacities:{},F=x?x.variableOffsets:{},U=x?x.placedOrientations:{};for(const K in this.placements){const te=this.placements[K],re=R[K];re?(this.opacities[K]=new mp(re,P,te.text,te.icon,null,te.clipped),C=C||te.text!==re.text.placed||te.icon!==re.icon.placed):(this.opacities[K]=new mp(null,P,te.text,te.icon,te.skipFade,te.clipped),C=C||te.text||te.icon)}for(const K in R){const te=R[K];if(!this.opacities[K]){const re=new mp(te,P,!1,!1);re.isHidden()||(this.opacities[K]=re,C=C||te.text.placed||te.icon.placed)}}for(const K in F)this.variableOffsets[K]||!this.opacities[K]||this.opacities[K].isHidden()||(this.variableOffsets[K]=F[K]);for(const K in U)this.placedOrientations[K]||!this.opacities[K]||this.opacities[K].isHidden()||(this.placedOrientations[K]=U[K]);C?this.lastPlacementChangeTime=u:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=x?x.lastPlacementChangeTime:u)}updateLayerOpacities(u,x,C,P){P&&(this.lastReplacementSourceUpdateTime=P.updateTime);const R=new Set;for(const F of x){const U=F.getBucket(u);U&&F.latestFeatureIndex&&u.fqid===U.layerIds[0]&&(this.updateBucketOpacities(U,R,F,F.collisionBoxArray,C,P,F.tileID,u.scope),U.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(U,F.tileID),U.elevationType==="road"&&U.updateRoadElevation(F.tileID.canonical),U.updateZOffset())}}updateBucketOpacities(u,x,C,P,R,F,U,K){u.hasTextData()&&u.text.opacityVertexArray.clear(),u.hasIconData()&&u.icon.opacityVertexArray.clear(),u.hasIconCollisionBoxData()&&u.iconCollisionBox.collisionVertexArray.clear(),u.hasTextCollisionBoxData()&&u.textCollisionBox.collisionVertexArray.clear();const te=u.layers[0].layout,re=u.layers[0].paint,pe=!!u.layers[0].dynamicFilter(),me=new mp(null,0,!1,!1,!0),fe=te.get("text-allow-overlap"),Ne=te.get("icon-allow-overlap"),we=te.get("text-variable-anchor"),Re=te.get("text-rotation-alignment")==="map",Le=te.get("text-pitch-alignment")==="map",Ze=re.get("symbol-z-offset"),nt=te.get("symbol-elevation-reference")==="sea",Xe=!Ze.isConstant(),Mt=new mp(null,0,fe&&(Ne||!u.hasIconData()||te.get("icon-optional")),Ne&&(fe||!u.hasTextData()||te.get("text-optional")),!0);!u.collisionArrays&&P&&(u.hasIconCollisionBoxData()||u.hasTextCollisionBoxData())&&u.deserializeCollisionBoxes(P);const gt=(ft,ht,At)=>{for(let Ut=0;Ut0||Ut>0,Gs=ts>0,dr=this.placedOrientations[Bt],qs=dr===i.bL.vertical,Os=dr===i.bL.horizontal||dr===i.bL.horizontalOnly;!ks&&!Gs||es.isHidden()||jt++;let wr=!1;if((ks||Gs)&&F)for(const yr of u.activeReplacements){if(i.bZ(yr,R,i.b_.Symbol,K)||yr.min.x>rs||rs>yr.max.x||yr.min.y>ms||ms>yr.max.y)continue;const ir=i.b$(rs,ms,U.canonical,yr.footprintTileId.canonical);if(wr=i.c0(ir,yr.footprint),wr)break}if(ks){const yr=wr?ty:Rd(es.text);gt(u.text,At,qs?ty:yr),gt(u.text,Ut,Os?ty:yr);const ir=es.text.isHidden(),{leftJustifiedTextSymbolIndex:hr,centerJustifiedTextSymbolIndex:Fr,rightJustifiedTextSymbolIndex:_n,verticalPlacedTextSymbolIndex:ia}=ht,Oa=u.text.placedSymbolArray,Nr=ir||qs?1:0;hr>=0&&(Oa.get(hr).hidden=Nr),Fr>=0&&(Oa.get(Fr).hidden=Nr),_n>=0&&(Oa.get(_n).hidden=Nr),ia>=0&&(Oa.get(ia).hidden=ir||Os?1:0);const Ca=this.variableOffsets[Bt];Ca&&this.markUsedJustification(u,Ca.anchor,ht,dr);const un=this.placedOrientations[Bt];un&&(this.markUsedJustification(u,"left",ht,un),this.markUsedOrientation(u,un,ht))}if(Gs){const yr=wr?ty:Rd(es.icon),{placedIconSymbolIndex:ir,verticalPlacedIconSymbolIndex:hr}=ht,Fr=u.icon.placedSymbolArray,_n=es.icon.isHidden()?1:0;ir>=0&&(gt(u.icon,ts,qs?ty:yr),Fr.get(ir).hidden=_n),hr>=0&&(gt(u.icon,ht.numVerticalIconVertices,Os?ty:yr),Fr.get(hr).hidden=_n)}if(u.hasIconCollisionBoxData()||u.hasTextCollisionBoxData()){const yr=u.collisionArrays[ft];if(yr){let ir=new i.P(0,0),hr=!0;if(yr.textBox||yr.verticalTextBox){if(we){const _n=this.variableOffsets[Bt];_n?(ir=Jc(_n.anchor,_n.width,_n.height,_n.textOffset,_n.textScale),Re&&ir._rotate(Le?this.transform.angle:-this.transform.angle)):hr=!1}pe&&(hr=!es.clipped),yr.textBox&&Og(u.textCollisionBox.collisionVertexArray,es.text.placed,!hr||qs,Pt,nt,ir.x,ir.y),yr.verticalTextBox&&Og(u.textCollisionBox.collisionVertexArray,es.text.placed,!hr||Os,Pt,nt,ir.x,ir.y)}const Fr=hr&&!!(!Os&&yr.verticalIconBox);yr.iconBox&&Og(u.iconCollisionBox.collisionVertexArray,es.icon.placed,Fr,Pt,nt,ht.hasIconTextFit?ir.x:0,ht.hasIconTextFit?ir.y:0),yr.verticalIconBox&&Og(u.iconCollisionBox.collisionVertexArray,es.icon.placed,!Fr,Pt,nt,ht.hasIconTextFit?ir.x:0,ht.hasIconTextFit?ir.y:0)}}}if(u.fullyClipped=jt===0,u.sortFeatures(this.transform.angle),this.retainedQueryData[u.bucketInstanceId]&&(this.retainedQueryData[u.bucketInstanceId].featureSortOrder=u.featureSortOrder),u.hasTextData()&&u.text.opacityVertexBuffer&&u.text.opacityVertexBuffer.updateData(u.text.opacityVertexArray),u.hasIconData()&&u.icon.opacityVertexBuffer&&u.icon.opacityVertexBuffer.updateData(u.icon.opacityVertexArray),u.hasIconCollisionBoxData()&&u.iconCollisionBox.collisionVertexBuffer&&u.iconCollisionBox.collisionVertexBuffer.updateData(u.iconCollisionBox.collisionVertexArray),u.hasTextCollisionBoxData()&&u.textCollisionBox.collisionVertexBuffer&&u.textCollisionBox.collisionVertexBuffer.updateData(u.textCollisionBox.collisionVertexArray),u.bucketInstanceId in this.collisionCircleArrays){const ft=this.collisionCircleArrays[u.bucketInstanceId];u.placementInvProjMatrix=ft.invProjMatrix,u.placementViewportMatrix=ft.viewportMatrix,u.collisionCircleArray=ft.circles,delete this.collisionCircleArrays[u.bucketInstanceId]}}symbolFadeChange(u){return this.fadeDuration===0?1:(u-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(u){return Math.max(0,(this.transform.zoom-u)/1.5)}hasTransitions(u){return this.stale||u-this.lastPlacementChangeTimeu}isStale(){return this.stale}setStale(){this.stale=!0}}function Og(N,u,x,C,P,R,F){N.emplaceBack(u?1:0,x?1:0,R||0,F||0,C,P?1:0),N.emplaceBack(u?1:0,x?1:0,R||0,F||0,C,P?1:0),N.emplaceBack(u?1:0,x?1:0,R||0,F||0,C,P?1:0),N.emplaceBack(u?1:0,x?1:0,R||0,F||0,C,P?1:0)}const xM=Math.pow(2,25),S_=Math.pow(2,24),BN=Math.pow(2,17),yM=Math.pow(2,16),$N=Math.pow(2,9),Od=Math.pow(2,8),mf=Math.pow(2,1);function Rd(N){if(N.opacity===0&&!N.placed)return 0;if(N.opacity===1&&N.placed)return 4294967295;const u=N.placed?1:0,x=Math.floor(127*N.opacity);return x*xM+u*S_+x*BN+u*yM+x*$N+u*Od+x*mf+u}const ty=0;class R0{constructor(u){this._sortAcrossTiles=u.layout.get("symbol-z-order")!=="viewport-y"&&u.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(u,x,C,P,R,F){const U=this._bucketParts;for(;this._currentTileIndexK.sortKey-te.sortKey));this._currentPartIndex{const K=i.o.now()-F;return!this._forceFullPlacement&&K>2};for(;this._currentPlacementIndex>=0;){const K=x[u[this._currentPlacementIndex]],te=this.placement.collisionIndex.transform.zoom;if(K.type==="symbol"&&K.visibility!=="none"&&(!K.minzoom||K.minzoom<=te)&&(!K.maxzoom||K.maxzoom>te)){const re=K,pe=re.layout.get("symbol-z-elevate"),me=re.layout.get("symbol-sort-key").constantOr(1)!==void 0,fe=re.layout.get("symbol-z-order"),Ne=fe==="viewport-y"||fe==="auto"&&!(fe!=="viewport-y"&&me),we=re.layout.get("text-allow-overlap")||re.layout.get("icon-allow-overlap")||re.layout.get("text-ignore-placement")||re.layout.get("icon-ignore-placement"),Re=Ne&&we,Le=this._inProgressLayer=this._inProgressLayer||new R0(re),Ze=i.B(K.source,K.scope);if(Le.continuePlacement(pe||Re?P[Ze]:C[Ze],this.placement,this._showCollisionBoxes,K,U,R))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(u){return this.placement.commit(u),this.placement}}const Oh=512/i.al/2;class pf{constructor(u,x,C){this.tileID=u,this.bucketInstanceId=C,this.index=new i.c4(x.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const P=u.canonical.x*i.al,R=u.canonical.y*i.al;for(let F=0;FRe-Le);for(const Re of we){const Le=this.crossTileIDs[Re];if(this.keys[Re]===re&&!C.has(Le)){C.add(Le),te.crossTileID=Le;break}}}}}class kl{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class vM{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(u){const x=Math.round((u-this.lng)/360);if(x!==0)for(const C in this.indexes){const P=this.indexes[C],R={};for(const F in P){const U=P[F];U.tileID=U.tileID.unwrapTo(U.tileID.wrap+x),R[U.tileID.key]=U}this.indexes[C]=R}this.lng=u}addBucket(u,x,C){if(this.indexes[u.overscaledZ]&&this.indexes[u.overscaledZ][u.key]){if(this.indexes[u.overscaledZ][u.key].bucketInstanceId===x.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(u.overscaledZ,this.indexes[u.overscaledZ][u.key])}for(let R=0;Ru.overscaledZ)for(const U in F){const K=F[U];K.tileID.isChildOf(u)&&K.findMatches(x.symbolInstances,u,P)}else{const U=F[u.scaledTo(Number(R)).key];U&&U.findMatches(x.symbolInstances,u,P)}}for(let R=0;R{x[C]=!0});for(const C in this.layerIndexes)x[C]||delete this.layerIndexes[C]}}const pp=771;class Cn{constructor(u,x,C,P){this.blendFunction=u,this.blendColor=x.toNonPremultipliedRenderColor(null),this.mask=C,this.blendEquation=P}}Cn.Replace=[1,0,1,0],Cn.disabled=new Cn(Cn.Replace,i.ao.transparent,[!1,!1,!1,!1]),Cn.unblended=new Cn(Cn.Replace,i.ao.transparent,[!0,!0,!0,!0]),Cn.alphaBlended=new Cn([1,pp,1,pp],i.ao.transparent,[!0,!0,!0,!0]),Cn.alphaBlendedNonPremultiplied=new Cn([770,pp,770,pp],i.ao.transparent,[!0,!0,!0,!0]),Cn.multiply=new Cn([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),Cn.additive=new Cn([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Cr{constructor(u,x,C){this.func=u,this.mask=x,this.range=C}}Cr.ReadOnly=!1,Cr.ReadWrite=!0,Cr.disabled=new Cr(519,Cr.ReadOnly,[0,1]);const UN=7680;class sn{constructor(u,x,C,P,R,F){this.test=u,this.ref=x,this.mask=C,this.fail=P,this.depthFail=R,this.pass=F}}sn.disabled=new sn({func:519,mask:0},0,0,UN,UN,UN);const F0=1029,qN=2305;class tn{constructor(u,x,C){this.enable=u,this.mode=x,this.frontFace=C}}function fp(N,u){const x=i.ca(N,3);i.cc(N,u),i.cg(N,3,x)}function _M(N,u){const x=i.c7([]);return i.c8(x,x,-u),i.c9(x,x,-N),x}function VN(N,u){const x=[N[0],N[1],0],C=[u[0],u[1],0];if(i.ag(x)>=1e-15){const F=i.aw([],x);i.c5(C,F,i.bJ(C,F)),u[0]=C[0],u[1]=C[1]}const P=i.bI([],u,N);if(i.c6(P)<1e-15)return null;const R=Math.atan2(-P[1],P[0]);return _M(Math.atan2(Math.sqrt(N[0]*N[0]+N[1]*N[1]),-N[2]),R)}tn.disabled=new tn(!1,F0,qN),tn.backCCW=new tn(!0,F0,qN),tn.backCW=new tn(!0,F0,2304),tn.frontCW=new tn(!0,1028,2304),tn.frontCCW=new tn(!0,1028,qN);class Fd{constructor(u,x){this.position=u,this.orientation=x}get position(){return this._position}set position(u){if(u){const x=u instanceof i.ae?u:new i.ae(u[0],u[1],u[2]);this._renderWorldCopies&&(x.x=i.bT(x.x,0,1)),this._position=x}else this._position=null}lookAtPoint(u,x,C){if(this.orientation=null,!this.position)return;const P=this.position,R=C||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(u)):0),F=i.ae.fromLngLat(u,R),U=[F.x-P.x,F.y-P.y,F.z-P.z];x||(x=[0,0,1]),x[2]=Math.abs(x[2]),this.orientation=VN(U,x)}setPitchBearing(u,x){this.orientation=_M(i.an(u),i.an(-x))}}class HN{constructor(u,x){this._transform=i.bA([]),this.orientation=x,this.position=u}get mercatorPosition(){const u=this.position;return new i.ae(u[0],u[1],u[2])}get position(){const u=i.ca(this._transform,3);return[u[0],u[1],u[2]]}set position(u){var x;u&&i.cg(this._transform,3,[(x=u)[0],x[1],x[2],1])}get orientation(){return this._orientation}set orientation(u){this._orientation=u||i.c7([]),u&&fp(this._transform,this._orientation)}getPitchBearing(){const u=this.forward(),x=this.right();return{bearing:Math.atan2(-x[1],x[0]),pitch:Math.atan2(Math.sqrt(u[0]*u[0]+u[1]*u[1]),-u[2])}}setPitchBearing(u,x){this._orientation=_M(u,x),fp(this._transform,this._orientation)}forward(){const u=i.ca(this._transform,2);return[-u[0],-u[1],-u[2]]}up(){const u=i.ca(this._transform,1);return[-u[0],-u[1],-u[2]]}right(){const u=i.ca(this._transform,0);return[u[0],u[1],u[2]]}getCameraToWorld(u,x){const C=new Float64Array(16);return i.bl(C,this.getWorldToCamera(u,x)),C}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(u,x,C){const P=this.position;i.c5(P,P,-u);const R=new Float64Array(16);return i.bq(R,[C,C,C]),i.br(R,R,P),R[10]*=x,R}getWorldToCamera(u,x){const C=new Float64Array(16),P=new Float64Array(4),R=this.position;return i.cb(P,this._orientation),i.c5(R,R,-u),i.cc(C,P),i.br(C,C,R),C[1]*=-1,C[5]*=-1,C[9]*=-1,C[13]*=-1,C[8]*=x,C[9]*=x,C[10]*=x,C[11]*=x,C}getCameraToClipPerspective(u,x,C,P){const R=new Float64Array(16);return i.cd(R,u,x,C,P),R}getCameraToClipOrthographic(u,x,C,P,R,F){const U=new Float64Array(16);return i.ce(U,u,x,C,P,R,F),U}getDistanceToElevation(u,x=!1){const C=u===0?0:i.cf(u,x?i.a$(this.position[1]):this.position[1]),P=this.forward();return(C-this.position[2])/P[2]}clone(){return new HN([...this.position],[...this.orientation])}}const Xl={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class WN{constructor(u=0,x=0,C=0,P=0){if(isNaN(u)||u<0||isNaN(x)||x<0||isNaN(C)||C<0||isNaN(P)||P<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=u,this.bottom=x,this.left=C,this.right=P}interpolate(u,x,C){return x.top!=null&&u.top!=null&&(this.top=i.ak(u.top,x.top,C)),x.bottom!=null&&u.bottom!=null&&(this.bottom=i.ak(u.bottom,x.bottom,C)),x.left!=null&&u.left!=null&&(this.left=i.ak(u.left,x.left,C)),x.right!=null&&u.right!=null&&(this.right=i.ak(u.right,x.right,C)),this}getCenter(u,x){const C=i.aA((this.left+u-this.right)/2,0,u),P=i.aA((this.top+x-this.bottom)/2,0,x);return new i.P(C,P)}equals(u){return this.top===u.top&&this.bottom===u.bottom&&this.left===u.left&&this.right===u.right}clone(){return new WN(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const jm=15;class bM{constructor(u,x,C,P,R,F,U){this.tileSize=512,this._renderWorldCopies=R===void 0||R,this._minZoom=u||0,this._maxZoom=x||22,this._minPitch=C??0,this._maxPitch=P??60,this.setProjection(F),this.setMaxBounds(U),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 WN,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new HN,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 u=new bM(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return u._elevation=this._elevation,u._centerAltitude=this._centerAltitude,u._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,u.tileSize=this.tileSize,u.mercatorFromTransition=this.mercatorFromTransition,u.width=this.width,u.height=this.height,u.cameraElevationReference=this.cameraElevationReference,u._center=this._center,u._setZoom(this.zoom),u._seaLevelZoom=this._seaLevelZoom,u.angle=this.angle,u._fov=this._fov,u._pitch=this._pitch,u._nearZ=this._nearZ,u._farZ=this._farZ,u._averageElevation=this._averageElevation,u._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,u._unmodified=this._unmodified,u._edgeInsets=this._edgeInsets.clone(),u._camera=this._camera.clone(),u._calcMatrices(),u.freezeTileCoverage=this.freezeTileCoverage,u.frustumCorners=this.frustumCorners,u._allowWorldUnderZoom=this._allowWorldUnderZoom,u}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||u===Number.NEGATIVE_INFINITY&&(!x||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const C=this._elevation;x||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&C.exaggeration()&&this._centerAltitudeValidForExaggeration!==C.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*C.exaggeration(),this._centerAltitudeValidForExaggeration=C.exaggeration()):(this._centerAltitude=u||0,this._centerAltitudeValidForExaggeration=C.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const u=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(u)}sampleAverageElevation(){if(!this._elevation)return 0;const u=this._elevation,x=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],C=this.horizonLineFromTop();let P=0,R=0;for(let F=0;F{const Re=i.cY(me,pe,fe,Ne,we);K.has(Re)||(R.push(new i.aQ(pe,me,fe,Ne,we)),K.add(Re))};for(let pe=0;peme.canonical.z)continue;const fe=me.canonical,Ne=me.overscaledZ,we=me.wrap,Re=1<0,nt=fe.y+10,Mt=me.wrap-(Ze?0:1),gt=me.wrap+(Le?0:1),jt=Ze?fe.x-1:Re-1,ft=Le?fe.x+1:0;if(F)C[0]<0?(te(Ne,gt,fe.z,ft,fe.y),C[1]<0&&nt&&(te(Ne,we,fe.z,fe.x,fe.y+1),te(Ne,gt,fe.z,ft,fe.y+1)),C[1]>0&&Xe&&(te(Ne,we,fe.z,fe.x,fe.y-1),te(Ne,gt,fe.z,ft,fe.y-1))):C[0]>0?(te(Ne,Mt,fe.z,jt,fe.y),C[1]<0&&nt&&(te(Ne,we,fe.z,fe.x,fe.y+1),te(Ne,Mt,fe.z,jt,fe.y+1)),C[1]>0&&Xe&&(te(Ne,we,fe.z,fe.x,fe.y-1),te(Ne,Mt,fe.z,jt,fe.y-1))):C[1]<0&&nt?te(Ne,we,fe.z,fe.x,fe.y+1):Xe&&te(Ne,we,fe.z,fe.x,fe.y-1);else{const ht=me.visibleQuadrants;1&ht&&(te(Ne,Mt,fe.z,jt,fe.y),Xe&&(te(Ne,we,fe.z,fe.x,fe.y-1),te(Ne,Mt,fe.z,jt,fe.y-1))),2&ht&&(te(Ne,gt,fe.z,ft,fe.y),Xe&&(te(Ne,we,fe.z,fe.x,fe.y-1),te(Ne,gt,fe.z,ft,fe.y-1))),4&ht&&(te(Ne,Mt,fe.z,jt,fe.y),nt&&(te(Ne,we,fe.z,fe.x,fe.y+1),te(Ne,Mt,fe.z,jt,fe.y+1))),8&ht&&(te(Ne,gt,fe.z,ft,fe.y),nt&&(te(Ne,we,fe.z,fe.x,fe.y+1),te(Ne,gt,fe.z,ft,fe.y+1)))}}const re=[];for(const pe of R)R.some(me=>pe.isChildOf(me))||re.push(pe);if(R=re.filter(pe=>!u.some(me=>!!(pe.overscaledZ{const Le=Re.canonical.x+.5-fe[0],Ze=Re.canonical.y+.5-fe[1];return Le*Le+Ze*Ze{const jt=i.cY(nt,Ze,Xe,Mt,gt);R.has(jt)||(P.push(new i.aQ(Ze,nt,Xe,Mt,gt)),R.add(jt))},U=u.reduce((Ze,nt)=>Math.max(Ze,nt.overscaledZ),C),K=1<{const Xe=Math.floor(Ze[0]),Mt=Math.floor(Ze[1]),gt=(Ze[0]-Xe)*i.al,jt=(Ze[1]-Mt)*i.al,ft=Math.floor(nt[0]),ht=Math.floor(nt[1]),At=(nt[0]-ft)*i.al,Ut=(nt[1]-ht)*i.al;for(let Bt=-1;Bt<=1;Bt++){const ts=Xe+Bt;if(!(ts<0||ts>=K)){re.x=gt-Bt*i.al,pe.x=At-(ts-ft)*i.al;for(let rs=-1;rs<=1;rs++){const ms=Mt+rs;re.y=jt-rs*i.al,pe.y=Ut-(ms-ht)*i.al,i.cZ(re,pe,te)&&F(U,0,C,ts,ms)}}}},fe=x.points,Ne=fe[i.cv],we=fe[i.cw],Re=this._projectToGround(Ne,fe[i.cx]),Le=this._projectToGround(we,fe[i.cy]);return me(Ne,Re),me(we,Le),P}_projectToGround(u,x){return i.cz(i.cA(),u,x,u[2]/(u[2]-x[2]))}coveringTiles(u){let x=this.coveringZoomLevel(u);const C=x,P=this.elevation&&this.elevation.exaggeration(),R=P&&!u.isTerrainDEM,F=this.projection.name==="mercator";if(u.minzoom!==void 0&&xu.maxzoom&&(x=u.maxzoom);const U=this.locationCoordinate(this.center),K=this.center.lat,te=1<{const es=new i.ae(Pt.x+25e-6,Pt.y,Pt.z),ks=new i.ae(Pt.x,Pt.y+25e-6,Pt.z),Gs=Pt.toLngLat(),dr=es.toLngLat(),qs=ks.toLngLat(),Os=this.locationCoordinate(Gs),wr=this.locationCoordinate(dr),yr=this.locationCoordinate(qs),ir=Math.hypot(wr.x-Os.x,wr.y-Os.y),hr=Math.hypot(yr.x-Os.x,yr.y-Os.y);return Math.sqrt(ir*hr)*jt/25e-6},ht=Pt=>{const is=Mt,es=gt;return{aabb:i.cF(this,te,0,0,0,Pt,es,is,this.projection),zoom:0,x:0,y:0,minZ:es,maxZ:is,wrap:Pt,fullyVisible:!1}},At=[];let Ut=[];const Bt=x,ts=u.reparseOverscaled?C:x,rs=(Re-this._centerAltitude)*we,ms=Pt=>{if(!this._elevation||!Pt.tileID||!F)return;const is=this._elevation.getMinMaxForTile(Pt.tileID),es=Pt.aabb;is?(es.min[2]=is.min,es.max[2]=is.max,es.center[2]=(es.min[2]+es.max[2])/2):(Pt.shouldSplit=Yt(Pt),Pt.shouldSplit||(es.min[2]=es.max[2]=es.center[2]=this._centerAltitude))},Ds=(Pt,is)=>{if(.707*is{if(Pt.zoom=.9)return!0}else if(R&&(ks=Pt.aabb.distanceZ(Le)*we),this.projection.isReprojectedInTileSpace&&C<=5){const hr=Math.pow(2,Pt.zoom),Fr=ft(new i.ae((Pt.x+.5)/hr,(Pt.y+.5)/hr));Gs=Fr>.85?1:Fr}if(!F&&!pe){const hr=Math.sqrt(is*is+es*es+ks*ks);let Fr=(1<0;){const Pt=At.pop(),is=Pt.x,es=Pt.y;let ks=Pt.fullyVisible;const Gs=()=>this.projection.name==="globe"&&(Pt.y===0||Pt.y===(1<>1),wr={aabb:F?Pt.aabb.quadrant(dr):i.cF(this,te,Pt.zoom+1,qs,Os,Pt.wrap,Pt.minZ,Pt.maxZ,this.projection),zoom:Pt.zoom+1,x:qs,y:Os,wrap:Pt.wrap,fullyVisible:ks,tileID:void 0,shouldSplit:void 0,minZ:Pt.minZ,maxZ:Pt.maxZ};R&&!pe&&(wr.tileID=new i.aQ(Pt.zoom+1===Bt?ts:Pt.zoom+1,Pt.wrap,Pt.zoom+1,qs,Os),ms(wr)),At.push(wr)}else{const dr=Pt.zoom===Bt?ts:Pt.zoom;if(u.minzoom&&u.minzoom>dr)continue;let qs=0;if(!ks){let ir=Ze?Pt.aabb.intersectsPrecise(fe):Pt.aabb.intersectsPreciseFlat(fe);if(ir===0&&Gs()){const hr=new i.cD(Pt.zoom,is,es);ir=i.cE(this,te,hr,!0).intersectsPrecise(fe)}if(ir===0)continue;if(u.calculateQuadrantVisibility)if(fe.containsPoint(Pt.aabb.center))qs=15;else for(let hr=0;hr<4;hr++)Pt.aabb.quadrant(hr).intersects(fe)!==0&&(qs|=1<{const ks=[0,0,0,1],Gs=[i.al,i.al,0,1],dr=this.calculateFogTileMatrix(es.tileID.toUnwrapped());i.aC(ks,ks,dr),i.aC(Gs,Gs,dr);const qs=i.cG([],ks,Gs),Os=i.cH([],ks,Gs),wr=i.c$(qs,Os);if(wr===0)return!0;let yr=!1;const ir=this._elevation;if(ir&&wr>Pt&&is!==0){const hr=this.calculateProjMatrix(es.tileID.toUnwrapped());let Fr;u.isTerrainDEM||(Fr=ir.getMinMaxForTile(es.tileID)),Fr||(Fr={min:gt,max:Mt});const _n=i.cI(this.rotation),ia=[_n[0]*i.al,_n[1]*i.al,Fr.max];i.af(ia,ia,hr),yr=(1-ia[1])*this.height*.5Pt.distanceSq-is.distanceSq).map(Pt=>Pt.tileID)}resize(u,x){this.width=u,this.height=x,this.pixelsToGLUnits=[2/u,-2/x],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(u){return Math.pow(2,u)}scaleZoom(u){return Math.log2(u)}project(u){const x=i.aA(u.lat,-i.cJ,i.cJ),C=this.projection.project(u.lng,x);return new i.P(C.x*this.worldSize,C.y*this.worldSize)}unproject(u){return this.projection.unproject(u.x/this.worldSize,u.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(u,x){let C,P;const R=this.centerPoint;if(this.projection.name==="globe"){const U=this.worldSize;C=(x.x-R.x)/U,P=(x.y-R.y)/U}else{const U=this.pointCoordinate(x),K=this.pointCoordinate(R);C=U.x-K.x,P=U.y-K.y}const F=this.locationCoordinate(u);this.setLocation(new i.ae(F.x-C,F.y-P))}setLocation(u){this.center=this.coordinateLocation(u),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(u,x){return this.projection.locationPoint(this,u,x)}locationPoint3D(u,x){return this.projection.locationPoint(this,u,x,!0)}pointLocation(u){return this.coordinateLocation(this.pointCoordinate(u))}pointLocation3D(u,x){return this.coordinateLocation(this.pointCoordinate3D(u,x))}locationCoordinate(u,x){const C=x?i.cf(x,u.lat):void 0,P=this.projection.project(u.lng,u.lat);return new i.ae(P.x,P.y,C)}coordinateLocation(u){return this.projection.unproject(u.x,u.y)}pointRayIntersection(u,x){const C=x??this._centerAltitude,P=[u.x,u.y,0,1],R=[u.x,u.y,1,1];i.aC(P,P,this.pixelMatrixInverse),i.aC(R,R,this.pixelMatrixInverse);const F=R[3];i.cK(P,P,1/P[3]),i.cK(R,R,1/F);const U=P[2],K=R[2];return{p0:P,p1:R,t:U===K?0:(C-U)/(K-U)}}screenPointToMercatorRay(u){const x=[u.x,u.y,0,1],C=[u.x,u.y,1,1];return i.aC(x,x,this.pixelMatrixInverse),i.aC(C,C,this.pixelMatrixInverse),i.cK(x,x,1/x[3]),i.cK(C,C,1/C[3]),x[2]=i.cf(x[2],this._center.lat)*this.worldSize,C[2]=i.cf(C[2],this._center.lat)*this.worldSize,i.cK(x,x,1/this.worldSize),i.cK(C,C,1/this.worldSize),new i.ax([x[0],x[1],x[2]],i.aw([],i.av([],C,x)))}rayIntersectionCoordinate(u){const{p0:x,p1:C,t:P}=u,R=i.cf(x[2],this._center.lat),F=i.cf(C[2],this._center.lat);return new i.ae(i.ak(x[0],C[0],P)/this.worldSize,i.ak(x[1],C[1],P)/this.worldSize,i.ak(R,F,P))}pointCoordinate(u,x=this._centerAltitude){return this.projection.pointCoordinate(this,u.x,u.y,x)}pointCoordinate3D(u,x){if(!this.elevation)return this.pointCoordinate(u,x);let C=this.projection.pointCoordinate3D(this,u.x,u.y);if(C)return new i.ae(C[0],C[1],C[2]);let P=0,R=this.horizonLineFromTop();if(u.y>R)return this.pointCoordinate(u,x);const F=.02*R,U=u.clone();for(let K=0;K<10&&R-P>F;K++){U.y=i.ak(P,R,.66);const te=this.projection.pointCoordinate3D(this,U.x,U.y);te?(R=U.y,C=te):P=U.y}return C?new i.ae(C[0],C[1],C[2]):this.pointCoordinate(u)}isPointAboveHorizon(u){return this.projection.isPointAboveHorizon(this,u)}isPointOnSurface(u){if(u.y<0||u.y>this.height||u.x<0||u.x>this.width)return!1;if(this.elevation||this.zoom>=i.cL)return!this.isPointAboveHorizon(u);const x=this.pointCoordinate(u);return x.y>=0&&x.y<=1}_coordinatePoint(u,x){const C=x&&this.elevation?this.elevation.getAtPointOrZero(u,this._centerAltitude):this._centerAltitude,P=[u.x*this.worldSize,u.y*this.worldSize,C+u.toAltitude(),1];return i.aC(P,P,this.pixelMatrix),P[3]>0?new i.P(P[0]/P[3],P[1]/P[3]):new i.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:u,left:x}=this._edgeInsets,C=this.height-this._edgeInsets.bottom,P=this.width-this._edgeInsets.right,R=this.pointLocation3D(new i.P(x,u)),F=this.pointLocation3D(new i.P(P,u)),U=this.pointLocation3D(new i.P(P,C)),K=this.pointLocation3D(new i.P(x,C));let te=Math.min(R.lng,F.lng,U.lng,K.lng),re=Math.max(R.lng,F.lng,U.lng,K.lng),pe=Math.min(R.lat,F.lat,U.lat,K.lat),me=Math.max(R.lat,F.lat,U.lat,K.lat);const fe=Math.pow(2,-this.zoom)/16*270,Ne=this.projection.name==="globe"?1:4,we=(Re,Le,Ze,nt,Xe)=>{const Mt=(Re+Ze)/2,gt=(Le+nt)/2,jt=new i.P(Mt,gt),{lng:ft,lat:ht}=this.pointLocation3D(jt),At=Math.max(0,te-ft,pe-ht,ft-re,ht-me);te=Math.min(te,ft),re=Math.max(re,ft),pe=Math.min(pe,ht),me=Math.max(me,ht),(Xefe)&&(we(Re,Le,Mt,gt,Xe+1),we(Mt,gt,Ze,nt,Xe+1))};if(we(x,u,P,u,1),we(P,u,P,C,1),we(P,C,x,C,1),we(x,C,x,u,1),this.projection.name==="globe"){const[Re,Le]=i.cM(this);Re?(me=90,re=180,te=-180):Le&&(pe=-90,re=180,te=-180)}return new i.aI(new i.aT(te,pe),new i.aT(re,me))}_getBoundsRectangular(u,x){const{top:C,left:P}=this._edgeInsets,R=this.height-this._edgeInsets.bottom,F=this.width-this._edgeInsets.right,U=new i.P(P,C),K=new i.P(F,C),te=new i.P(F,R),re=new i.P(P,R);let pe=this.pointCoordinate(U,u),me=this.pointCoordinate(K,u);const fe=this.pointCoordinate(te,x),Ne=this.pointCoordinate(re,x),we=(Re,Le)=>(Le.y-Re.y)/(Le.x-Re.x);return pe.y>1&&me.y>=0?pe=new i.ae((1-Ne.y)/we(Ne,pe)+Ne.x,1):pe.y<0&&me.y<=1&&(pe=new i.ae(-Ne.y/we(Ne,pe)+Ne.x,0)),me.y>1&&pe.y>=0?me=new i.ae((1-fe.y)/we(fe,me)+fe.x,1):me.y<0&&pe.y<=1&&(me=new i.ae(-fe.y/we(fe,me)+fe.x,0)),new i.aI().extend(this.coordinateLocation(pe)).extend(this.coordinateLocation(me)).extend(this.coordinateLocation(Ne)).extend(this.coordinateLocation(fe))}_getBoundsRectangularTerrain(){const u=this.elevation;if(!u.visibleDemTiles.length||u.isUsingMockSource())return this._getBoundsRectangular(0,0);const x=u.visibleDemTiles.reduce((C,P)=>{if(P.dem){const R=P.dem.tree;C.min=Math.min(C.min,R.minimums[0]),C.max=Math.max(C.max,R.maximums[0])}return C},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(x.min*u.exaggeration(),x.max*u.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(u=!0){const x=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,C=this.height/2-x*(1-this._horizonShift);return u?Math.max(0,C):C}getMaxBounds(){return this.maxBounds}setMaxBounds(u){this.maxBounds=u,this.minLat=-i.cJ,this.maxLat=i.cJ,this.minLng=-180,this.maxLng=180,u&&(this.minLat=u.getSouth(),this.maxLat=u.getNorth(),this.minLng=u.getWest(),this.maxLng=u.getEast(),this.maxLngpe&&(U=pe-te),pe-refe&&(F=fe-K),fe-me{for(let Yt=0;Yt<16;Yt++)ts[Yt]=i.ak(rs[Yt],ms[Yt],Ds)})(U,U,K,i.d0(this.pitch>=jm?1:this.pitch/jm))}else U=K;const te=i.cP([],K,F);let re=i.cP([],U,F);if(this.projection.isReprojectedInTileSpace){const ht=this.locationCoordinate(this.center),At=i.bA([]);i.br(At,At,[ht.x*this.worldSize,ht.y*this.worldSize,0]),i.aB(At,At,i.cQ(this)),i.br(At,At,[-ht.x*this.worldSize,-ht.y*this.worldSize,0]),i.aB(re,re,At),i.aB(te,te,At),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],re,[this.worldSize,this.worldSize,this.worldSize/R,1]),this.projMatrix=re,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),x){const ht=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);ht[8]=2*-u.x/this.width,ht[9]=2*u.y/this.height,this.expandedFarZProjMatrix=i.cP([],ht,F)}else this.expandedFarZProjMatrix=this.projMatrix;const pe=i.bl([],U);this.frustumCorners=i.cT.fromInvProjectionMatrix(pe,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 fe=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(fe);const Ne=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;fe[8]=2*-u.x/this.width,fe[9]=2*(u.y+Ne)/this.height,this.skyboxMatrix=i.aB(me,fe,me);const we=this.point,Re=we.x,Le=we.y,Ze=this.width%2/2,nt=this.height%2/2,Xe=Math.cos(this.angle),Mt=Math.sin(this.angle),gt=Re-Math.round(Re)+Xe*Ze+Mt*nt,jt=Le-Math.round(Le)+Xe*nt+Mt*Ze,ft=new Float64Array(re);if(i.br(ft,ft,[gt>.5?gt-1:gt,jt>.5?jt-1:jt,0]),this.alignedProjMatrix=ft,re=i.bC(),i.cS(re,re,[this.width/2,-this.height/2,1]),i.br(re,re,[1,-1,0]),this.labelPlaneMatrix=re,re=i.bC(),i.cS(re,re,[1,-1,1]),i.br(re,re,[-1,-1,0]),i.cS(re,re,[2/this.width,2/this.height,1]),this.glCoordMatrix=re,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,te),this._calcFogMatrices(),this._distanceTileDataCache={},re=i.bl(new Float64Array(16),this.pixelMatrix),!re)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=re,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const ht=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(ht,ht,F),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=re;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const u=this.cameraWorldSizeForFog,x=this.cameraPixelsPerMeter,C=this._camera.position,P=1/this.height/this._pixelsPerMercatorPixel,R=[u,u,x];i.c5(R,R,P),i.c5(C,C,-1),i.cW(C,C,R);const F=i.bC();i.br(F,F,C),i.cS(F,F,R),this.mercatorFogMatrix=F,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(u,x,P)}_computeCameraPosition(u){const x=(u=u||this.pixelsPerMeter)/this.pixelsPerMeter,C=this._camera.forward(),P=this.point,R=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*x-u/this.worldSize*this._centerAltitude;return[P.x/this.worldSize-C[0]*R,P.y/this.worldSize-C[1]*R,u/this.worldSize*this._centerAltitude-C[2]*R]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(u){const x=this._maxCameraBoundsDistance()*Math.cos(this._pitch),C=this._camera.position[2],P=u[2];let R=1;this.projection.wrap&&(this.center=this.center.wrap()),P>0&&(R=Math.min((x-C)/P,1)),this._camera.position=i.bH([],this._camera.position,u,R),this._updateStateFromCamera()}_updateStateFromCamera(){const u=this._camera.position,x=this._camera.forward(),{pitch:C,bearing:P}=this._camera.getPitchBearing(),R=i.cf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,F=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.an(this._maxPitch)),U=Math.max((u[2]-R)/Math.cos(C),F),K=this._zoomFromMercatorZ(U);i.bH(u,u,x,U),this._pitch=i.aA(C,i.an(this.minPitch),i.an(this.maxPitch)),this.angle=i.bT(P,-Math.PI,Math.PI),this._setZoom(i.aA(K,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ae(u[0],u[1],u[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(u){return Math.pow(2,u)*this.tileSize}_mercatorZfromZoom(u){return this.cameraToCenterDistance/this._worldSizeFromZoom(u)}_minimumHeightOverTerrain(){const u=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(u)}_zoomFromMercatorZ(u){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,u)*this.tileSize))}zoomFromMercatorZAdjusted(u){let x=0,C=i.cL,P=0,R=1/0;for(;C-x>1e-6&&C>x;){const F=x+.5*(C-x),U=this.tileSize*Math.pow(2,F),K=this.getCameraToCenterDistance(this.projection,F,U),te=this.scaleZoom(K/(Math.max(0,u)*this.tileSize)),re=Math.abs(F-te);rete||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(u,x){const C=i.ag(i.av([],this._camera.position,u)),P=this._zoomFromMercatorZ(C)+x;return C-this._mercatorZfromZoom(P)}getCameraPoint(){if(this.projection.name==="globe"){const u=function([x,C,P],R){const F=[x,C,P,1];i.aC(F,F,R);const U=F[3]=Math.max(F[3],1e-6);return F[0]/=U,F[1]/=U,F[2]/=U,F}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.P(u[0],u[1])}{const u=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,u))}}getCameraToCenterDistance(u,x=this.zoom,C=this.worldSize){const P=i.cO(u,x,this.width,this.height,1024),R=u.pixelSpaceConversion(this.center.lat,C,P);let F=.5/Math.tan(.5*this._fov)*this.height*R;return this.isOrthographic&&(F=i.ak(1,F,i.d0(this.pitch>=jm?1:this.pitch/jm))),F}getWorldToCameraMatrix(){const u=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.aB(u,u,this.globeMatrix),u}getFrustum(u){return i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,u,this.projection.zAxisUnit==="meters")}}const Rg=(N,u)=>{if(u>0&&N.terrain&&i.w("Cutoff is currently disabled on terrain"),u<=0||N.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const x=N.transform,C=Math.max(Math.abs(x._zoom-(N.minCutoffZoom-1)),1),P=x.isLODDisabled(!1)?i.ah(60,45,x.pitch):i.ah(30,15,x.pitch),R=x._farZ-x._nearZ,F=u*x.height,U=((1-(K=P))*x.cameraToCenterDistance+K*(x._farZ+F))*C;var K;return{shouldRenderCutoff:P<1,uniformValues:{u_cutoff_params:[x._nearZ,x._farZ,(U-x._nearZ)/R,(U-F-x._nearZ)/R]}}},Rh=2048;class C_{constructor(u,x){this.aabb=u,this.lastCascade=x}}class Gle{add(u,x){const C=this.receivers[u.key];C!==void 0?(C.aabb.min[0]=Math.min(C.aabb.min[0],x.min[0]),C.aabb.min[1]=Math.min(C.aabb.min[1],x.min[1]),C.aabb.min[2]=Math.min(C.aabb.min[2],x.min[2]),C.aabb.max[0]=Math.max(C.aabb.max[0],x.max[0]),C.aabb.max[1]=Math.max(C.aabb.max[1],x.max[1]),C.aabb.max[2]=Math.max(C.aabb.max[2],x.max[2])):this.receivers[u.key]=new C_(x,null)}clear(){this.receivers={}}get(u){return this.receivers[u.key]}computeRequiredCascades(u,x,C){const P=i.d9.fromPoints(u.points);let R=0;for(const F in this.receivers){const U=this.receivers[F];if(!U||!P.intersectsAabb(U.aabb))continue;U.aabb.min=P.closestPoint(U.aabb.min),U.aabb.max=P.closestPoint(U.aabb.max);const K=U.aabb.getCorners();for(let te=0;te1||me[1]<-1||me[1]>1){re=!1;break}}if(U.lastCascade=te,R=Math.max(R,te),re)break}}return R+1}}class z0{constructor(u){this.painter=u,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Gle,this._depthMode=new Cr(u.context.gl.LEQUAL,Cr.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 u of this._cascades)u.texture.destroy(),u.framebuffer.destroy();this._cascades=[]}updateShadowParameters(u,x){const C=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!x||!x.properties)return;const P=x.properties.get("shadow-intensity");if(!x.shadowsEnabled()||P<=0||(this._shadowLayerCount=C.style.order.reduce((Ne,we)=>{const Re=C.style._mergedLayers[we];return Ne+(Re.hasShadowPass()&&!Re.isHidden(u.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const R=C.context,F=Rh,U=Rh;if(this._cascades.length===0||Rh!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Ne=0;Ne<2;++Ne){const we=C._shadowMapDebug,Re=R.gl,Le=R.createFramebuffer(F,U,we?1:0,"texture"),Ze=new i.T(R,{width:F,height:U,data:null},Re.DEPTH_COMPONENT16);if(Le.depthAttachment.set(Ze.texture),we){const nt=new i.T(R,{width:F,height:U,data:null},Re.RGBA8);Le.colorAttachment0.set(nt.texture)}this._cascades.push({framebuffer:Le,texture:Ze,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=T_(x);let K=0;if(u.elevation){const Ne=u.elevation,we=[1e4,-1e4];Ne.visibleDemTiles.filter(Re=>Re.dem).forEach(Re=>{const Le=Re.dem.tree;we[0]=Math.min(we[0],Le.minimums[0]),we[1]=Math.max(we[1],Le.maximums[0])}),we[0]!==1e4&&(K=(we[1]-we[0])*Ne.exaggeration())}const te=1.5*u.cameraToCenterDistance,re=3*te,pe=new Float64Array(16);for(let Ne=0;Ne=0)return{};const R=function(K,te,re){const pe=re/(1<0&&(i.d8(R[1],R[1],[P[0]*F,0,0]),i.d8(R[2],R[2],[P[0]*F,0,0])),P[1]<0?(i.d8(R[0],R[0],[0,P[1]*F,0]),i.d8(R[1],R[1],[0,P[1]*F,0])):P[1]>0&&(i.d8(R[2],R[2],[0,P[1]*F,0]),i.d8(R[3],R[3],[0,P[1]*F,0]));const U={};return U.vertices=R,U.planes=[M_(R[1],R[0],R[4]),M_(R[2],R[1],R[5]),M_(R[3],R[2],R[6]),M_(R[0],R[3],R[7])],U}addShadowReceiver(u,x,C){this._receivers.add(u,i.d9.fromTileIdAndHeight(u,x,C))}getMaxCascadeForTile(u){const x=this._receivers.get(u);return x&&x.lastCascade?x.lastCascade:0}}function M_(N,u,x){const C=i.av([],x,u),P=i.av([],N,u),R=i.bI([],C,P),F=i.ag(R);return F===0?[0,0,1,0]:(i.c5(R,R,1/F),[R[0],R[1],R[2],-i.bJ(R,u)])}function T_(N){const u=N.properties.get("direction"),x=i.d4(u.x,u.y,u.z);x[2]=i.aA(x[2],0,75);const C=i.d6([x[0],x[1],x[2]]);return i.d5(C.x,C.y,C.z)}function ff(N,u,x){const C=u.properties.get("color-use-theme")==="none",P=u.properties.get("color"),R=u.properties.get("intensity"),F=u.properties.get("direction"),U=[F.x,F.y,F.z],K=x.properties.get("color-use-theme")==="none",te=x.properties.get("color"),re=x.properties.get("intensity"),pe=Math.max(i.bJ([0,0,1],U),0),me=[0,0,0];i.c5(me,te.toPremultipliedRenderColor(K?null:N.getLut(u.scope)).toArray01Linear().slice(0,3),re);const fe=[0,0,0];return i.c5(fe,P.toPremultipliedRenderColor(C?null:N.getLut(x.scope)).toArray01Linear().slice(0,3),pe*R),i.db([me[0]>0?me[0]/(me[0]+fe[0]):0,me[1]>0?me[1]/(me[1]+fe[1]):0,me[2]>0?me[2]/(me[2]+fe[2]):0])}function Fg(N,u,x,C,P,R){const F=N.zoom,U=N.scale,K=N.worldSize,te=1/K,re=N.aspect,pe=Math.sqrt(1+re*re)*Math.tan(.5*N.fovX),me=pe*pe,fe=C-x,Ne=C+x;let we,Re;me>fe/Ne?(we=C,Re=C*pe):(we=.5*Ne*(1+me),Re=.5*Math.sqrt(fe*fe+2*(C*C+x*x)*me+Ne*Ne*me*me));const Le=N.projection.pixelsPerMeter(N.center.lat,K),Ze=N._camera.getCameraToWorldMercator(),nt=[0,0,-we*te];i.af(nt,nt,Ze);let Xe=Re*te;const Mt=N._edgeInsets;if(!(Mt.left===0&&Mt.top===0&&Mt.right===0&&Mt.bottom===0||Mt.left===Mt.right&&Mt.top===Mt.bottom)){const ks=N._camera.getWorldToCamera(N.worldSize,N.projection.zAxisUnit==="meters"?Le:1),Gs=N._camera.getCameraToClipPerspective(N._fov,N.width/N.height,x,C);Gs[8]=2*-N.centerOffset.x/N.width,Gs[9]=2*N.centerOffset.y/N.height;const dr=new Float64Array(16);i.cP(dr,Gs,ks);const qs=new Float64Array(16);i.bl(qs,dr);const Os=i.cB.fromInvProjectionMatrix(qs,K,F,!0);for(const wr of Os.points){const yr=((gt=wr)[0]/=U,gt[1]/=U,gt[2]=i.cf(gt[2],N._center.lat),gt);Xe=Math.max(Xe,i.c6(i.da([],nt,yr)))}}var gt;Xe*=P/(P-1);const jt=Math.acos(u[2]),ft=Math.atan2(-u[0],-u[1]),ht=new HN;ht.position=nt,ht.setPitchBearing(jt,ft);const At=ht.getWorldToCamera(K,Le),Ut=Xe*K,Bt=Math.min(N._mercatorZfromZoom(17)*K*-2,-2*Ut),ts=ht.getCameraToClipOrthographic(-Ut,Ut,-Ut,Ut,Bt,(Ut+R*Le)/u[2]),rs=new Float64Array(16);i.aB(rs,ts,At);const ms=i.d5(Math.floor(1e6*nt[0])/1e6*K,Math.floor(1e6*nt[1])/1e6*K,0),Ds=.5*P,Yt=[0,0,0];i.af(Yt,ms,rs),i.c5(Yt,Yt,Ds);const Pt=[Math.floor(Yt[0]),Math.floor(Yt[1]),Math.floor(Yt[2])],is=[0,0,0];i.av(is,Yt,Pt),i.c5(is,is,-1/Ds);const es=new Float64Array(16);return i.bA(es),i.br(es,es,is),i.aB(rs,es,rs),[rs,Ut]}class Kle extends i.E{constructor(u){super(),this.requestManager=u,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(u,x){return i.dc(this.requestManager.transformRequest(x,i.R.Model).url).then(C=>{if(!C)return;const P=i.dd(C),R=new i.de(u,x,void 0,void 0,P);return R.computeBoundsAndApplyParent(),R}).catch(C=>{if(C&&C.status===404)return null;this.fire(new i.y(new Error(`Could not load model ${u} from ${x}: ${C.message}`)))})}load(u,x,C={forceReload:!1}){this.models[x]||(this.models[x]={});const P=Object.keys(u),R=[],F=[];for(const U of P){const K=u[U];this.hasURLBeenRequested(K)&&!C.forceReload||(this.modelByURL[K]={modelId:U,scope:x},R.push(this.loadModel(U,K)),F.push(U)),this.models[x][U]||(this.models[x][U]={model:null,numReferences:1})}this.numModelsLoading[x]=(this.numModelsLoading[x]||0)+F.length,Promise.allSettled(R).then(U=>{for(let K=0;K{this.fire(new i.y(new Error(`Could not load models: ${U.message}`)))})}isLoaded(){for(const u in this.numModelsLoading)if(this.numModelsLoading[u]>0)return!1;return!0}hasModel(u,x,C={exactIdMatch:!1}){return!!(C.exactIdMatch?this.getModel(u,x):this.getModelByURL(this.modelUris[x][u]))}getModel(u,x){return this.models[x]||(this.models[x]={}),this.models[x][u]?this.models[x][u].model:void 0}getModelByURL(u){if(!u)return null;const x=this.modelByURL[u];return x?this.models[x.scope][x.modelId].model:null}hasModelBeenAdded(u,x){return this.models[x]&&this.models[x][u]!==void 0}getModelURIs(u){return this.modelUris[u]||{}}addModel(u,x,C){this.models[C]||(this.models[C]={}),this.modelUris[C]||(this.modelUris[C]={});const P=this.requestManager.normalizeModelURL(x);if((this.hasModel(u,C,{exactIdMatch:!0})||this.hasModelBeenAdded(u,C))&&this.modelUris[C][u]===P)this.models[C][u].numReferences++;else if(this.hasURLBeenRequested(P)){const{scope:R,modelId:F}=this.modelByURL[P];this.models[R][F].numReferences++}else this.modelUris[C][u]=P,this.load({[u]:this.modelUris[C][u]},C)}addModelURLs(u,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const C=this.modelUris[x];for(const P in u)C[P]=this.requestManager.normalizeModelURL(u[P])}reloadModels(u){this.load(this.modelUris[u],u,{forceReload:!0})}addModelsFromBucket(u,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const C={};for(const P of u)this.hasModel(P,x,{exactIdMatch:!0})||this.hasURLBeenRequested(P)?this.models[x][P].numReferences++:this.modelUris[x][P]&&!this.hasURLBeenRequested(P)?C[P]=this.modelUris[x][P]:!this.hasURLBeenRequested(P)&&i.df(P,!1)&&(this.modelUris[x][P]=this.requestManager.normalizeModelURL(P),C[P]=this.modelUris[x][P]);this.load(C,x)}hasURLBeenRequested(u){return this.modelByURL[u]!==void 0}removeModel(u,x,C=!1,P=!1){if(this.models[x]&&this.models[x][u]&&(this.models[x][u].numReferences--,this.models[x][u].numReferences===0||P)){const R=this.modelUris[x][u];C||delete this.modelUris[x][u],delete this.modelByURL[R];const F=this.models[x][u].model;if(!F)return;delete this.models[x][u],F.destroy()}}destroy(){for(const u of Object.keys(this.models))for(const x of Object.keys(this.models[u])){const C=this.models[u][x].model;delete this.models[u][x],C&&C.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(u){return this.models[u]||(this.models[u]={}),Object.keys(this.models[u])}upload(u,x){this.models[x]||(this.models[x]={});for(const C in this.models[x])this.models[x][C].model&&this.models[x][C].model.upload(u.context)}}const wM=i.a6.colorTheme,Zle=new i.a9({data:new i.aa(wM.data)});function yL(N){if(!N.metadata||!N.metadata.content_area)return;const u=i.o.devicePixelRatio,{left:x,top:C,width:P,height:R}=N.metadata.content_area,F=x*u,U=C*u;return[F,U,F+P*u,U+R*u]}function vL(N){if(N)return N.map(([u,x])=>[u*i.o.devicePixelRatio,x*i.o.devicePixelRatio])}class jM{constructor(u,x,C){this.id=u,this.scope=x,this.sourceCache=C,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(u){this.missingRequests.has(u.name)||this.pendingRequests.has(u.name)||this.pendingRequests.add(u.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const u=new Map;if(!this.sourceCache.loaded())return u;const x=this.sourceCache.getVisibleCoordinates();if(x.length===0)return u;const C=this.sourceCache.getSource();if(!(C instanceof zc))return u;const P=x.map(F=>this.sourceCache.getTile(F)),R=C.getImages(P,Array.from(this.pendingRequests));for(const[F,U]of R)u.set(i.I.from({name:F,iconsetId:this.id}),U),this.pendingRequests.delete(F);for(const F of this.pendingRequests)this.missingRequests.add(F);return this.pendingRequests.clear(),u}}const zg=(N,u)=>Qe(N,u&&u.filter(x=>x.identifier!=="source.canvas")),_L=i.aH(da,["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"]),bL=i.aH(da,["setCenter","setZoom","setBearing","setPitch"]),GN=new Set(["background","sky","slot","custom"]),Bg={version:8,layers:[],sources:{}},A_={duration:300,delay:0};class Fh extends i.E{constructor(u,x={}){super(),this.map=u,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({},A_),this._buildingIndex=new fM(this),this.crossTileSymbolIndex=new wm,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 Fe(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=x.glyphManager?x.glyphManager:new i.di(u._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 Kle(u._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 C=this;this._rtlTextPluginCallback=Fh.registerForPluginStateChange(P=>{C.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:P.pluginStatus,pluginURL:P.pluginURL},(R,F)=>{if(i.dl(R),F&&F.every(U=>U))for(const U in C._sourceCaches){const K=C._sourceCaches[U],te=K.getSource().type;te!=="vector"&&te!=="geojson"||K.reload()}})}),this.on("data",P=>{if(P.dataType!=="source"||P.sourceDataType!=="metadata")return;const R=this.getOwnSource(P.sourceId);if(R&&R.vectorLayerIds)for(const F in this._layers){const U=this._layers[F];U.source===R.id&&this._validateLayer(U)}})}load(u){return u?(typeof u=="string"?this.loadURL(u):this.loadJSON(u),this):this}_getGlobalId(u){if(!u)return null;if(typeof u=="string"){if(i.h(u))return u;const x=i.dm(u);if(!x.startsWith("http"))try{return new URL(x,location.href).toString()}catch{return x}return x}return`json://${i.dn(JSON.stringify(u))}`}_diffStyle(u,x,C){this.globalId=this._getGlobalId(u);const P=(R,F)=>{try{F(null,this.setState(R,C))}catch(U){F(U,!1)}};if(typeof u=="string"){const R=this.map._requestManager.normalizeStyleURL(u),F=this.map._requestManager.transformRequest(R,i.R.Style);i.m(F,(U,K)=>{U?this.fire(new i.y(U)):K&&P(K,x)})}else typeof u=="object"&&P(u,x)}loadURL(u,x={}){this.fire(new i.z("dataloading",{dataType:"style"}));const C=typeof x.validate=="boolean"?x.validate:!i.h(u);this.globalId=this._getGlobalId(u),u=this.map._requestManager.normalizeStyleURL(u,x.accessToken),this.resolvedImports.add(u);const P=this.importsCache.get(u);if(P)return this._load(P,C);const R=this.map._requestManager.transformRequest(u,i.R.Style);this._request=i.m(R,(F,U)=>{if(this._request=null,F)this.fire(new i.y(F));else if(U)return this.importsCache.set(u,U),this._load(U,C)})}loadJSON(u,x={}){this.fire(new i.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(u),this._request=i.o.frame(()=>{this._request=null,this._load(u,x.validate!==!1)})}loadEmpty(){this.fire(new i.z("dataloading",{dataType:"style"})),this._load(Bg,!1)}_loadImports(u,x,C){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const P=[];for(const R of u){const F=this._createFragmentStyle(R),U=new Promise(re=>{F.once("style.import.load",re),F.once("error",re)}).then(()=>this.mergeAll());if(P.push(U),this.resolvedImports.has(R.url)){F.loadEmpty();continue}const K=R.data||this.importsCache.get(R.url);K?(F.loadJSON(K,{validate:x}),this._isInternalStyle(K)&&(F.globalId=null)):R.url?F.loadURL(R.url,{validate:x}):F.loadEmpty();const te={style:F,id:R.id,config:R.config};if(C){const re=this.fragments.findIndex(({id:pe})=>pe===C);this.fragments=this.fragments.slice(0,re).concat(te).concat(this.fragments.slice(re))}else this.fragments.push(te)}return Promise.allSettled(P)}getImportGlobalIds(u=this,x=new Set){for(const C of u.fragments)C.style.globalId&&x.add(C.style.globalId),this.getImportGlobalIds(C.style,x);return[...x.values()]}_createFragmentStyle(u){const x=this.scope?i.B(u.id,this.scope):u.id;let C;const P=this._initialConfig&&this._initialConfig[x];(u.config||P)&&(C=Object.assign({},u.config,P));const R=new Fh(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:C,configOptions:this.options,colorThemeOverride:u["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return R.setEventedParent(this.map,{style:R}),R}_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(u){return this.isRootStyle()&&(u.fragment||!!u.schema&&u.fragment!==!1)}_load(u,x){if(this._isInternalStyle(u)){const R=Object.assign({},Bg,{imports:[{id:"basemap",data:u,url:""}]},u.center?{center:u.center}:{},u.bearing?{bearing:u.bearing}:{},u.pitch?{pitch:u.pitch}:{},u.zoom?{zoom:u.zoom}:{},u.light?{light:u.light}:{});return this._importedAsBasemap=!0,void this._load(R,x)}if(this.updateConfig(this._config,u.schema),x&&zg(this,Pr(u)))return;this._loaded=!0,this.stylesheet=i.dp(u);const C=()=>{for(const K in u.sources)this.addSource(K,u.sources[K],{validate:!1,isInitialLoad:!0});if(u.iconsets)for(const K in u.iconsets)this.addIconset(K,u.iconsets[K]);u.sprite?this._loadIconset(u.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&u.glyphs&&this.glyphManager.setURL(u.glyphs);const R=Jx(this.stylesheet.layers);if(this._order=R.map(K=>K.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 K=this.stylesheet.lights[0];this.light=new Dt(K.properties,K.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Dt(this.stylesheet.light)),this._layers={};for(const K of R){const te=i.du(K,this.scope,this._styleColorTheme.lut,this.options);te.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(te.fqid),te.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(te.fqid),this._hasAppearances=this._hasAppearances||te.getAppearances().length!==0,te.setEventedParent(this,{layer:{id:te.id}}),this._layers[te.id]=te;const re=this.getOwnLayerSourceCache(te),pe=!!this.directionalLight&&this.directionalLight.shadowsEnabled();re&&te.canCastShadows()&&pe&&(re.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const F=this.stylesheet.terrain;F&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(F,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 U=this.isRootStyle();u.imports?this._loadImports(u.imports,x).then(()=>{this._reloadImports(),this.fire(new i.z(U?"style.load":"style.import.load"))}).catch(K=>{this.fire(new i.y(new Error("Failed to load imports",K))),this.fire(new i.z(U?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(U?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const P=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(P){const R=this._evaluateColorThemeData(P);this._loadColorTheme(R).then(()=>{C()}).catch(F=>{i.w(`Couldn't load color theme from the stylesheet: ${F}`),C()})}else this._styleColorTheme.lut=null,C()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(u=>u.style.hasAppearances())}mergeAll(){let u,x,C,P,R,F,U,K,te,re;const pe={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(me=>{if(me.stylesheet){if(me.light!=null&&(u=me.light),me.stylesheet.lights)for(const fe of me.stylesheet.lights)fe.type==="ambient"&&me.ambientLight!=null&&(x=me.ambientLight),fe.type==="directional"&&me.directionalLight!=null&&(C=me.directionalLight);P=this._prioritizeTerrain(P,me.terrain,me.stylesheet.terrain),me.stylesheet.fog&&me.fog!=null&&(R=me.fog),me.stylesheet.snow&&me.snow!=null&&(F=me.snow),me.stylesheet.rain&&me.rain!=null&&(U=me.rain),me.stylesheet.camera!=null&&(re=me.stylesheet.camera),me.stylesheet.projection!=null&&(K=me.stylesheet.projection),me.stylesheet.transition!=null&&(te=me.stylesheet.transition),pe[me.scope]=me._styleColorTheme}}),this.light=u,this.ambientLight=x,this.directionalLight=C,this.fog=R,this.snow=F,this.rain=U,this._styleColorThemeForScope=pe,P===null?delete this.terrain:this.terrain=P,this.camera=re||{"camera-projection":"perspective"},this.projection=K||{name:"mercator"},this.transition=Object.assign({},A_,te),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(u){const x=C=>{for(const P of C.fragments)x(P.style);u(C)};x(this)}_prioritizeTerrain(u,x,C){const P=u&&u.drapeRenderMode===0;return C===null?x&&x.drapeRenderMode===0?x:P?u:null:x!=null&&(!u||P||x&&x.drapeRenderMode===1)?x:u}mergeTerrain(){let u;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(x=>{u=this._prioritizeTerrain(u,x.terrain,x.stylesheet.terrain)}),u===null?delete this.terrain:this.terrain=u}mergeProjection(){let u;this.forEachFragmentStyle(x=>{x.stylesheet.projection!=null&&(u=x.stylesheet.projection)}),this.projection=u||{name:"mercator"}}mergeSources(){const u={},x={},C={};this.forEachFragmentStyle(P=>{for(const R in P._sourceCaches){const F=i.B(R,P.scope);u[F]=P._sourceCaches[R]}for(const R in P._otherSourceCaches){const F=i.B(R,P.scope);x[F]=P._otherSourceCaches[R]}for(const R in P._symbolSourceCaches){const F=i.B(R,P.scope);C[F]=P._symbolSourceCaches[R]}}),this._mergedSourceCaches=u,this._mergedOtherSourceCaches=x,this._mergedSymbolSourceCaches=C}mergeIndoor(){this.forEachFragmentStyle(u=>{if(u.stylesheet&&u.stylesheet.indoor)for(const x of Object.values(u.stylesheet.indoor)){const C=x,P=i.B(C.sourceId,u.scope);this._mergedIndoor[P]=new Set(C.sourceLayers||[])}})}mergeLayers(){const u={},x=[],C={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(F=>{for(const U of F._order){const K=F._layers[U];if(K.type==="slot"){const te=i.dq(U);if(u[te])continue;u[te]=[]}K.slot&&u[K.slot]?u[K.slot].push(K):x.push(K)}}),this._mergedOrder=[];let P=-1;const R=(F=[])=>{for(const U of F)if(U.type==="slot"){const K=i.dq(U.id);u[K]&&R(u[K]),this._mergedSlots.push(K)}else{const K=i.B(U.id,U.scope);this._mergedOrder.push(K),C[K]=U,U.is3D(!!this.terrain)&&(this._has3DLayers=!0,P=this._mergedOrder.length-1),U.type==="circle"&&(this._hasCircleLayers=!0),U.type==="symbol"&&(this._hasSymbolLayers=!0),U.type==="clip"&&(this._clipLayerPresent=!0)}};if(R(x),this._has3DLayers){const F={};for(let U=0;UF[U]-F[K])}this._mergedLayers=C,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(u){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,u),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(u){return u.data?function(x,C,P,R){const F=Object.assign({},C);for(const K of Object.keys(wM))F[K]===void 0&&(F[K]=wM[K].default);const U=new i.a8(Zle,x,new Map(P));return U.setTransitionOrValue(F,P),U.untransitioned().possiblyEvaluate(new i.ac(0,{worldview:void 0}))}(this.scope,u,this.options).get("data"):null}_loadColorTheme(u){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const x=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((C,P)=>{const R="data:image/png;base64,";if(!u||u.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void C();let F=u;F.startsWith(R)||(F=R+F);const U=i.I.from("mapbox-reserved-lut"),K=new Image;K.src=F,K.onerror=()=>{this._styleColorTheme.lutLoading=!1,P(new Error("Failed to load image data"))},K.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==x)return void C();this._styleColorTheme.lutLoading=!1;const{width:te,height:re,data:pe}=i.o.getImageData(K);if(re>32)return void P(new Error("The height of the image must be less than or equal to 32 pixels."));if(te!==re*re)return void P(new Error("The width of the image must be equal to the height squared."));this.getImage(U)&&this.removeImage(U),this.addImage(U,{data:new i.q({width:te,height:re},pe),pixelRatio:1,sdf:!1,usvg:!1,version:0});const me=this.imageManager.getImage(U,this.scope);me?(this._styleColorTheme.lut={image:me.data,data:u},C()):P(new Error("Missing LUT image."))}})}getLut(u){const x=this._styleColorThemeForScope[u];return x?x.lut:null}setProjection(u){u?this.stylesheet.projection=u: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(u){this._spriteRequest=function(x,C,P){let R,F,U;const K=i.o.devicePixelRatio>1?"@2x":"";let te=i.m(C.transformRequest(C.normalizeSpriteURL(x,K,".json"),i.R.SpriteJSON),(me,fe)=>{te=null,U||(U=me,R=fe,pe())}),re=i.n(C.transformRequest(C.normalizeSpriteURL(x,K,".png"),i.R.SpriteImage),(me,fe)=>{re=null,U||(U=me,F=fe,pe())});function pe(){if(U)P(U);else if(R&&F){const me=i.o.getImageData(F),fe={};for(const Ne in R){const{width:we,height:Re,x:Le,y:Ze,sdf:nt,pixelRatio:Xe,stretchX:Mt,stretchY:gt,content:jt}=R[Ne],ft=new i.q({width:we,height:Re});i.q.copy(me,ft,{x:Le,y:Ze},{x:0,y:0},{width:we,height:Re},null),fe[Ne]={data:ft,pixelRatio:Xe!==void 0?Xe:1,sdf:nt!==void 0&&nt,stretchX:Mt,stretchY:gt,content:jt,usvg:!1,version:0}}P(null,fe)}}return{cancel(){te&&(te.cancel(),te=null),re&&(re.cancel(),re=null)}}}(u,this.map._requestManager,(x,C)=>{if(this._spriteRequest=null,x)this.fire(new i.y(x));else if(C){const P=new Map;for(const R in C)P.set(i.I.from(R),C[R]);this.addImages(P)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))})}addIconset(u,x){if(x.type==="sprite")return void this._loadSprite(x.url);const C=this.getOwnSourceCache(x.source);if(!C)return void this.fire(new i.y(new Error(`Source "${x.source}" as specified by iconset "${u}" does not exist and cannot be used as an iconset source`)));const P=C.getSource();if(P.type!=="raster-array")return void this.fire(new i.y(new Error(`Source "${x.source}" as specified by iconset "${u}" is not a "raster-array" source and cannot be used as an iconset source`)));P.partial=!1;const R=new jM(u,this.scope,C);this.imageManager.addImageProvider(R,this.scope)}removeIconset(u){this.imageManager.removeImageProvider(u,this.scope)}_loadIconset(u){if(!i.h(u)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(u);const x=this.map._spriteFormat==="auto";var C,P;this._spriteRequest=(P=(R,F)=>{if(this._spriteRequest=null,R)x?this._loadSprite(u):this.fire(new i.y(R));else if(F){const U=new Map;for(const K in F)U.set(i.I.from(K),F[K]);this.addImages(U)}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((C=this.map._requestManager).transformRequest(C.normalizeIconsetURL(u),i.R.Iconset),(R,F)=>{if(R)return void P(R);const U={},K=i.dg(new i.bt(F));for(const te of K.icons){const re={version:1,pixelRatio:i.o.devicePixelRatio,content:yL(te),stretchX:te.metadata?vL(te.metadata.stretch_x_areas):void 0,stretchY:te.metadata?vL(te.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:te};U[te.name]=re}P(null,U)}))}_validateLayer(u){const x=this.getOwnSource(u.source);if(!x)return;const C=u.sourceLayer;C&&(x.type==="geojson"||x.vectorLayerIds&&x.vectorLayerIds.indexOf(C)===-1)&&this.fire(new i.y(new Error(`Source layer "${C}" does not exist on source "${x.id}" as specified by style layer "${u.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const u in this._sourceCaches)if(!this._sourceCaches[u].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:u}of this.fragments)if(!u.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((u,x)=>{const C=this.fragments[x];return C&&C.style&&(u.data=C.style.serialize()),u})}_serializeSources(){const u={};for(const x in this._sourceCaches){const C=this._sourceCaches[x].getSource();u[C.id]||(u[C.id]=C.serialize())}return u}_serializeLayers(u){const x=[];for(const C of u){const P=this._layers[C];P&&P.type!=="custom"&&x.push(P.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 u in this._sourceCaches)if(this._sourceCaches[u].hasTransition())return!0;for(const u in this._layers)if(this._layers[u].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const u in this._mergedLayers){const x=this._mergedLayers[u];if(x._transitionablePaint&&x._transitionablePaint._values){const C=x._transitionablePaint._values["line-emissive-strength"];if(C&&C.value&&C.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(u){return u?this.order:this._mergedOrder}isLayerDraped(u){return!!this.terrain&&u.isDraped(this.getLayerSourceCache(u))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(u){const x=this.getOwnLayer(u);if(x)return x;this.fire(new i.y(new Error(`The layer '${u}' does not exist in the map's style.`)))}_checkSource(u){const x=this.getOwnSource(u);if(x)return x;this.fire(new i.y(new Error(`The source '${u}' does not exist in the map's style.`)))}precompilePrograms(u,x){const C=this.map.painter;if(C)for(let P=u.minzoom||0;P<(u.maxzoom||25.5);P++){const R=u.getProgramIds();if(R)for(const F of R){const U=u.getDefaultProgramParams(F,x.zoom,this._styleColorTheme.lut);U&&(C.style=this,this.fog&&(C._fogVisible=!0,U.overrideFog=!0,C.getOrCreateProgram(F,U)),C._fogVisible=!1,U.overrideFog=!1,C.getOrCreateProgram(F,U),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(U.overrideRtt=!0,C.getOrCreateProgram(F,U)))}}}update(u){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(u),this.directionalLight&&this.directionalLight.recalculate(u);const x=this.calculateLightsBrightness();u.brightness=x||0,x!==this._brightness&&(this._brightness=x,this.dispatcher.broadcast("setBrightness",x)),u.worldview!==this._worldview&&(this._worldview=u.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const C=this._changes.isDirty();let P=!1;if(this._changes.isDirty()){const U=this._changes.getLayerUpdatesByScope();for(const K in U){const{updatedIds:te,removedIds:re}=U[K];(te||re)&&(this._updateWorkerLayers(K,te,re),P=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(u),this.light&&this.light.updateTransitions(u),this.ambientLight&&this.ambientLight.updateTransitions(u),this.directionalLight&&this.directionalLight.updateTransitions(u),this.fog&&this.fog.updateTransitions(u),this.snow&&this.snow.updateTransitions(u),this.rain&&this.rain.updateTransitions(u),this._changes.reset()}const R={};for(const U in this._mergedSourceCaches){const K=this._mergedSourceCaches[U];R[U]=K.used,K.used=!1,K.tileCoverLift=0}for(const U of this._mergedOrder){const K=this._mergedLayers[U];if(K.visibility!=="none"&&K.recalculate(u,this._availableImages),!K.isHidden(u.zoom)){const te=this.getLayerSourceCache(K);te&&(te.used=!0,te.tileCoverLift=Math.max(te.tileCoverLift,K.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(K,u)}):this.precompilePrograms(K,u))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&P&&this.mergeLayers();const F=this.imageManager.getPendingImageProviders();for(const U of F)U.sourceCache.used=!0;for(const U in R){const K=this._mergedSourceCaches[U];R[U]!==K.used&&K.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:K.getSource().id}))}this.light&&this.light.recalculate(u),this.terrain&&this.terrain.recalculate(u),this.fog&&this.fog.recalculate(u),this.snow&&this.snow.recalculate(u),this.rain&&this.rain.recalculate(u),this.z=u.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),C&&this.fire(new i.z("data",{dataType:"style"}))}updateImageProviders(){const u=this.imageManager.getPendingImageProviders();for(const x of u){const C=x.resolvePendingRequests(),P=this.getFragmentStyle(x.scope);P&&P.addImages(C)}}_updateTilesForChangedImages(){const u={};for(const x in this._mergedSourceCaches){const C=this._mergedSourceCaches[x].getSource().scope;u[C]=u[C]||this._changes.getUpdatedImages(C),u[C].length!==0&&this._mergedSourceCaches[x].reloadTilesForDependencies(["icons","patterns"],u[C])}for(const x in u)this._changes.resetUpdatedImages(x)}_updateWorkerLayers(u,x,C){const P=this.getFragmentStyle(u);P&&this.dispatcher.broadcast("updateLayers",{layers:x?P._serializeLayers(x):[],scope:u,removedIds:C||[],options:P.options})}setState(u,x){if(this._checkLoaded(),zg(this,Pr(u)))return!1;(u=i.dp(u)).layers=Jx(u.layers);const C=function(F,U){if(!F)return[{command:da.setStyle,args:[U]}];let K=[];try{if(!i.by(F.version,U.version))return[{command:da.setStyle,args:[U]}];if(i.by(F.center,U.center)||K.push({command:da.setCenter,args:[U.center]}),i.by(F.zoom,U.zoom)||K.push({command:da.setZoom,args:[U.zoom]}),i.by(F.bearing,U.bearing)||K.push({command:da.setBearing,args:[U.bearing]}),i.by(F.pitch,U.pitch)||K.push({command:da.setPitch,args:[U.pitch]}),i.by(F.sprite,U.sprite)||K.push({command:da.setSprite,args:[U.sprite]}),i.by(F.glyphs,U.glyphs)||K.push({command:da.setGlyphs,args:[U.glyphs]}),i.by(F.imports,U.imports)||function(fe=[],Ne=[],we){Ne=Ne||[];const Re=(fe=fe||[]).map(Dg),Le=Ne.map(Dg),Ze=fe.reduce(ey,{}),nt=Ne.reduce(ey,{}),Xe=Re.slice();let Mt,gt,jt,ft;for(Mt=0,gt=0;Mt{fe.source&&te[fe.source]?K.push({command:da.removeLayer,args:[fe.id]}):pe.push(fe)});let me=F.terrain;me&&te[me.source]&&(K.push({command:da.setTerrain,args:[void 0]}),me=void 0),K=K.concat(re),i.by(me,U.terrain)||K.push({command:da.setTerrain,args:[U.terrain]}),function(fe,Ne,we){Ne=Ne||[];const Re=(fe=fe||[]).map(Dg),Le=Ne.map(Dg),Ze=fe.reduce(ey,{}),nt=Ne.reduce(ey,{}),Xe=Re.slice(),Mt=Object.create(null);let gt,jt,ft,ht,At,Ut,Bt;for(gt=0,jt=0;gt!(F.command in bL));if(C.length===0)return!1;const P=C.filter(F=>!(F.command in _L));if(P.length>0)throw new Error(`Unimplemented: ${P.map(F=>F.command).join(", ")}.`);const R=[];return C.forEach(F=>{R.push(this[F.command](...F.args))}),x&&Promise.all(R).then(x).catch(x),this.stylesheet=u,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(u){if(u.size===0)return this;for(const[x,C]of u.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,C),this._changes.updateImage(x,this.scope)}return this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this}addImage(u,x){return this.getImage(u)?this.fire(new i.y(new Error(`An image with the name "${u.name}" already exists.`))):(this.imageManager.addImage(u,this.scope,x),this._changes.updateImage(u,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this)}updateImage(u,x,C=!1){this.imageManager.updateImage(u,this.scope,x),C&&(this._changes.updateImage(u,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})))}getImage(u){return this.imageManager.getImage(u,this.scope)}removeImage(u){return this.getImage(u)?(this.imageManager.removeImage(u,this.scope),this._changes.updateImage(u,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(u){return this.modelManager.addModelURLs(u,this.getActualScope()),this._updateWorkerModels(),this.fire(new i.z("data",{dataType:"style"})),this}addModel(u,x,C={}){return this._checkLoaded(),this._validate(_e,`models.${u}`,x,null,C)||(this.modelManager.addModel(u,x,this.getActualScope()),this.fire(new i.z("data",{dataType:"style"}))),this}hasModel(u){return this.modelManager.hasModel(u,this.getActualScope())}removeModel(u){return this.hasModel(u)?(this.modelManager.removeModel(u,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(u,x,C={}){if(this._checkLoaded(),this.getOwnSource(u)!==void 0)throw new Error(`There is already a source with ID "${u}".`);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(on,`sources.${u}`,x,null,C))return;this.map&&this.map._collectResourceTiming&&(x.collectResourceTiming=!0);const P=il(u,x,this.dispatcher,this);P.scope=this.scope,P.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(P.id),source:P.serialize(),sourceId:P.id}));const R=F=>{const U=(F?"symbol:":"other:")+P.id,K=i.B(U,this.scope),te=this._sourceCaches[U]=new Dd(K,P,F);(F?this._symbolSourceCaches:this._otherSourceCaches)[P.id]=te,te.onAdd(this.map)};R(!1),x.type!=="vector"&&x.type!=="geojson"||R(!0),P.onAdd&&P.onAdd(this.map),C.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(u){this._checkLoaded();const x=this.getOwnSource(u);if(!x)throw new Error("There is no source with this ID");for(const P in this._layers)if(this._layers[P].source===u)return this.fire(new i.y(new Error(`Source "${u}" cannot be removed while layer "${P}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===u)return this.fire(new i.y(new Error(`Source "${u}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const P=Object.entries(this.stylesheet.iconsets).find(([R,F])=>F.type==="source"&&F.source===u);if(P)return this.fire(new i.y(new Error(`Source "${u}" cannot be removed while iconset "${P[0]}" is using it.`)))}const C=this.getOwnSourceCaches(u);for(const P of C){const R=i.dq(P.id);delete this._sourceCaches[R],this._changes.discardSourceCacheUpdate(P.id),P.fire(new i.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:P.getSource().id})),P.setEventedParent(null),P.clearTiles()}return delete this._otherSourceCaches[u],delete this._symbolSourceCaches[u],this.mergeSources(),x.setEventedParent(null),x.onRemove&&x.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(u,x){this._checkLoaded(),this.getOwnSource(u).setData(x),this._changes.setDirty()}getOwnSource(u){const x=this.getOwnSourceCache(u);return x&&x.getSource()}getOwnSources(){const u=[];for(const x in this._otherSourceCaches){const C=this.getOwnSourceCache(x);C&&u.push(C.getSource())}return u}areTilesLoaded(){const u=this._mergedSourceCaches;for(const x in u){const C=u[x]._tiles;for(const P in C){const R=C[P];if(R.state!=="loaded"&&R.state!=="errored")return!1}}return!0}setLights(u){if(this._checkLoaded(),!u)return delete this.ambientLight,void delete this.directionalLight;const x=this._getTransitionParameters();for(const R of u){if(this._validate(ka,"lights",R))return;switch(R.type){case"ambient":if(this.ambientLight){const F=this.ambientLight;F.set(R),F.updateTransitions(x)}else this.ambientLight=new pa(R,Po||(Po=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 F=this.directionalLight;F.set(R),F.updateTransitions(x)}else this.directionalLight=new pa(R,Pa||(Pa=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 C=Object.assign(x,{worldview:this.map.getWorldview()}),P=new i.ac(this.z||0,C);this.ambientLight&&this.ambientLight.recalculate(P),this.directionalLight&&this.directionalLight.recalculate(P),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const u=this.directionalLight,x=this.ambientLight;if(!u||!x)return;const C=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)),P=u.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),R=u.properties.get("intensity"),F=u.properties.get("direction"),U=1-i.d4(F.x,F.y,F.z)[2]/90,K=C(P)*R*U,te=x.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),re=x.properties.get("intensity"),pe=C(te)*re;return Number(((K+pe)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const u=[];return this.directionalLight&&u.push(this.directionalLight.get()),this.ambientLight&&u.push(this.ambientLight.get()),u}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(u){if(u==null||u===""&&this.isRootStyle())return this;if(i.dr(u)){const x=i.ds(u),C=this.fragments.find(({id:R})=>R===x);if(!C)return;const P=i.dq(u);return C.style.getFragmentStyle(P)}{const x=this.fragments.find(({id:C})=>C===u);return x?x.style:void 0}}setFeaturesetSelectors(u){if(!u)return;const x={},C=(P,R="")=>`${P}::${R}`;this._featuresetSelectors={};for(const P in u){const R=this._featuresetSelectors[P]=[];for(const F of u[P].selectors){if(F.featureNamespace){const K=this.getOwnLayer(F.layer);if(!K){i.w(`Layer is undefined for selector: ${F.layer}`);continue}const te=C(K.source,K.sourceLayer);if(te in x&&x[te]!==F.featureNamespace){i.w(`"featureNamespace ${F.featureNamespace} of featureset ${P}'s selector is not associated to the same source, skip this selector`);continue}x[te]=F.featureNamespace}let U;if(F.properties)for(const K in F.properties){const te=i.U(F.properties[K]);te.result==="success"&&(U=U||{},U[K]=te.value)}R.push({layerId:F.layer,namespace:F.featureNamespace,properties:U,uniqueFeatureID:F._uniqueFeatureID})}}}getFeaturesetDescriptors(u){const x=this.getFragmentStyle(u);if(!x||!x.stylesheet.featuresets)return[];const C=[];for(const P in x.stylesheet.featuresets)C.push({featuresetId:P,importId:x.scope?x.scope:void 0});return C}getFeaturesetLayers(u,x){const C=this.getFragmentStyle(x),P=C.stylesheet.featuresets;if(!P||!P[u])return this.fire(new i.y(new Error(`The featureset '${u}' does not exist in the map's style and cannot be queried.`))),[];const R=[];for(const F of P[u].selectors){const U=C.getOwnLayer(F.layer);U&&R.push(U)}return R}getConfigProperty(u,x){const C=this.getFragmentStyle(u);if(!C)return null;const P=i.B(x,C.scope),R=C.options.get(P),F=R?R.value||R.default:null;return F?F.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(u,x){const C=i.B(u,x);return this._mergedIndoor[C]}setIndoorData(u,x){this.map.indoor.setIndoorData(x)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(u,x,C){const P=this.getFragmentStyle(u);if(!P)return;const R=P.stylesheet.schema;if(!R||!R[x])return;const F=i.U(C);if(F.result!=="success")return void zg(this,F.value);const U=F.value.expression,K=i.B(x,P.scope),te=P.options.get(K);if(!te)return;let re;const{minValue:pe,maxValue:me,stepValue:fe,type:Ne,values:we}=R[x],Re=i.U(R[x].default);Re.result==="success"&&(re=Re.value.expression),re?(this.options.set(K,Object.assign({},te,{value:U,default:re,minValue:pe,maxValue:me,stepValue:fe,type:Ne,values:we})),this.updateConfigDependencies(x)):this.fire(new i.y(new Error(`No schema defined for the config option "${x}" in the "${u}" fragment.`)))}getConfig(u){const x=this.getFragmentStyle(u);if(!x)return null;const C=x.stylesheet.schema;if(!C)return null;const P={};for(const R in C){const F=i.B(R,x.scope),U=x.options.get(F),K=U?U.value||U.default:null;P[R]=K?K.serialize():null}return P}setConfig(u,x){const C=this.getFragmentStyle(u);C&&(C.updateConfig(x,C.stylesheet.schema),this.updateConfigDependencies())}getSchema(u){const x=this.getFragmentStyle(u);return x?x.stylesheet.schema:null}setSchema(u,x){const C=this.getFragmentStyle(u);C&&(C.stylesheet.schema=x,C.updateConfig(C._config,x),this.updateConfigDependencies())}updateConfig(u,x){if(this._config=u,u||x)if(x)for(const C in x){let P,R;const F=i.U(x[C].default);if(F.result==="success"&&(P=F.value.expression),u&&u[C]!==void 0){const me=i.U(u[C]);me.result==="success"&&(R=me.value.expression)}const{minValue:U,maxValue:K,stepValue:te,type:re,values:pe}=x[C];if(P){const me=i.B(C,this.scope);this.options.set(me,{default:P,value:R,minValue:U,maxValue:K,stepValue:te,type:re,values:pe})}else this.fire(new i.y(new Error(`No schema defined for config option "${C}".`)))}else this.fire(new i.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(u,x=()=>!0){for(const C of u){const P=this.getLayer(C);P&&x(P)&&(P.possiblyEvaluateVisibility(),this._updateLayer(P),this._changes.setDirty())}}updateConfigDependencies(u){this._updateLayers(this._configDependentLayers,x=>!u||x.expressionDependencies.configDependencies.has(u)),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 C=x._styleColorTheme.colorThemeOverride?x._styleColorTheme.colorThemeOverride:x._styleColorTheme.colorTheme;if(C){const P=x._evaluateColorThemeData(C);(!x._styleColorTheme.lut&&P!==""||x._styleColorTheme.lut&&P!==x._styleColorTheme.lut.data)&&x.setColorTheme(C)}}),this._changes.setDirty()}addLayer(u,x,C={}){this._checkLoaded();const P=u.id;if(this._layers[P])return void this.fire(new i.y(new Error(`Layer with id "${P}" already exists on this map`)));let R;if(u.type==="custom"){if(zg(this,i.dt(u)))return;R=i.du(u,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof u.source=="object"&&(this.addSource(P,u.source),u=i.dp(u),u=Object.assign(u,{source:P})),this._validate(Rc,`layers.${P}`,u,{arrayIndex:-1},C))return;R=i.du(u,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(R),R.setEventedParent(this,{layer:{id:P}})}const F=i.B(R.source,R.scope);R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F);let U=this._order.length;if(x){const pe=this._order.indexOf(x);if(pe===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));R.slot===this._layers[x].slot?U=pe:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(U,0,P),this._layerOrderChanged=!0,this._layers[P]=R;const K=this.getOwnLayerSourceCache(R),te=!!this.directionalLight&&this.directionalLight.shadowsEnabled();K&&R.canCastShadows()&&te&&(K.castsShadows=!0);const re=this._changes.getRemovedLayer(R);if(re&&R.source&&K&&R.type!=="custom"){this._changes.discardLayerRemoval(R);const pe=i.B(R.source,R.scope);re.type!==R.type?this._changes.updateSourceCache(pe,"clear"):(this._changes.updateSourceCache(pe,"reload"),K.pause())}this._updateLayer(R),R.onAdd&&R.onAdd(this.map),R.scope=this.scope,this.mergeLayers()}moveLayer(u,x){this._checkLoaded();const C=this._checkLayer(u);if(!C||u===x)return;const P=this._order.indexOf(u);this._order.splice(P,1);let R=this._order.length;if(x){const F=this._order.indexOf(x);if(F===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));C.slot===this._layers[x].slot?R=F:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(R,0,u),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(u){this._checkLoaded();const x=this._checkLayer(u);if(!x)return;x.setEventedParent(null);const C=this._order.indexOf(u);this._order.splice(C,1),delete this._layers[u],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(x.fqid),this._indoorDependentLayers.delete(x.fqid),this._changes.removeLayer(x);const P=this.getOwnLayerSourceCache(x);if(P&&P.castsShadows){let R=!1;for(const F in this._layers)if(this._layers[F].source===x.source&&this._layers[F].canCastShadows()){R=!0;break}P.castsShadows=R}x.onRemove&&x.onRemove(this.map),this.mergeLayers()}getOwnLayer(u){return this._layers[u]}hasLayer(u){return u in this._mergedLayers}hasLayerType(u){for(const x in this._layers)if(this._layers[x].type===u)return!0;return!1}setLayerZoomRange(u,x,C){this._checkLoaded();const P=this._checkLayer(u);P&&(P.minzoom===x&&P.maxzoom===C||(x!=null&&(P.minzoom=x),C!=null&&(P.maxzoom=C),this._updateLayer(P)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(u,x){this._checkLoaded();const C=this._checkLayer(u);C&&C.slot!==x&&(C.slot=x,this._updateLayer(C))}setFilter(u,x,C={}){this._checkLoaded();const P=this._checkLayer(u);if(P&&!i.by(P.filter,x))return x==null?(P.filter=void 0,void this._updateLayer(P)):void(this._validate(Co,`layers.${P.id}.filter`,x,{layerType:P.type},C)||(P.filter=i.dp(x),this._updateLayer(P)))}getFilter(u){const x=this._checkLayer(u);if(x)return i.dp(x.filter)}setLayoutProperty(u,x,C,P={}){this._checkLoaded();const R=this._checkLayer(u);if(R&&!i.by(R.getLayoutProperty(x),C)){if(C!=null&&(!P||P.validate!==!1)&&zg(R,rt.call(Pr,{key:`layers.${u}.layout.${x}`,layerType:R.type,objectKey:x,value:C,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;R.setLayoutProperty(x,C),R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(R.fqid),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(R.fqid),this._updateLayer(R)}}setLayerProperty(u,x,C,P={}){this._checkLoaded();const R=this._checkLayer(u);R&&(x==="appearances"?(R.setAppearances(C),this._changes.setDirty()):R.isPaintProperty(x)?this.setPaintProperty(u,x,C,P):this.setLayoutProperty(u,x,C,P))}getLayoutProperty(u,x){const C=this._checkLayer(u);if(C)return C.getLayoutProperty(x)}setPaintProperty(u,x,C,P={}){this._checkLoaded();const R=this._checkLayer(u);if(!R||i.by(R.getPaintProperty(x),C)||C!=null&&(!P||P.validate!==!1)&&zg(R,Fc.call(Pr,{key:`layers.${u}.paint.${x}`,layerType:R.type,objectKey:x,value:C,styleSpec:i.a6})))return;const F=R.setPaintProperty(x,C);R.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(R.fqid),R.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(R.fqid),F&&this._updateLayer(R),this._changes.updatePaintProperties(R)}getPaintProperty(u,x){const C=this._checkLayer(u);if(C)return C.getPaintProperty(x)}setFeatureState(u,x){if(this._checkLoaded(),"target"in u){if("featuresetId"in u.target){const{featuresetId:K,importId:te}=u.target,re=this.getFragmentStyle(te),pe=re.getFeaturesetLayers(K);for(const{source:me,sourceLayer:fe}of pe)re.setFeatureState({id:u.id,source:me,sourceLayer:fe},x)}else if("layerId"in u.target){const{layerId:K}=u.target,te=this.getLayer(K);this.setFeatureState({id:u.id,source:te.source,sourceLayer:te.sourceLayer},x)}return}const C=u.source,P=u.sourceLayer,R=this._checkSource(C);if(!R)return;const F=R.type;if(F==="geojson"&&P)return void this.fire(new i.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(F==="vector"&&!P)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));u.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided.")));const U=this.getOwnSourceCaches(C);for(const K of U)K.setFeatureState(P,u.id,x)}removeFeatureState(u,x){if(this._checkLoaded(),"target"in u){if("featuresetId"in u.target){const{featuresetId:K,importId:te}=u.target,re=this.getFragmentStyle(te),pe=re.getFeaturesetLayers(K);for(const{source:me,sourceLayer:fe}of pe)re.removeFeatureState({id:u.id,source:me,sourceLayer:fe},x)}else if("layerId"in u.target){const{layerId:K}=u.target,te=this.getLayer(K);this.removeFeatureState({id:u.id,source:te.source,sourceLayer:te.sourceLayer},x)}return}const C=u.source,P=this._checkSource(C);if(!P)return;const R=P.type,F=R==="vector"?u.sourceLayer:void 0;if(R==="vector"&&!F)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(x&&typeof u.id!="string"&&typeof u.id!="number")return void this.fire(new i.y(new Error("A feature id is required to remove its specific state property.")));const U=this.getOwnSourceCaches(C);for(const K of U)K.removeFeatureState(F,u.id,x)}getFeatureState(u){if(this._checkLoaded(),"target"in u){let R;if("featuresetId"in u.target){const{featuresetId:F,importId:U}=u.target,K=this.getFragmentStyle(U),te=K.getFeaturesetLayers(F);for(const{source:re,sourceLayer:pe}of te){const me=K.getFeatureState({id:u.id,source:re,sourceLayer:pe});if(me&&!R)R=me;else if(!i.by(R,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 u.target){const{layerId:F}=u.target,U=this.getLayer(F);R=this.getFeatureState({id:u.id,source:U.source,sourceLayer:U.sourceLayer})}return R}const x=u.source,C=u.sourceLayer,P=this._checkSource(x);if(P){if(P.type!=="vector"||C)return u.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(x)[0].getFeatureState(C,u.id);this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(u){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,u),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const u=this.getTerrain(),x=u&&this.terrain&&this.terrain.scope===this.scope?u: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)},C=>C!==void 0)}_updateFilteredLayers(u){for(const x of Object.values(this._mergedLayers))u(x)&&this._updateLayer(x)}_updateLayer(u){this._changes.updateLayer(u);const x=this.getLayerSourceCache(u),C=i.B(u.source,u.scope),P=this._changes.getUpdatedSourceCaches();u.source&&!P[C]&&x&&x.getSource().type!=="raster"&&(this._changes.updateSourceCache(C,"reload"),x.pause()),u.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(u){const x=U=>this._mergedLayers[U].is3D(!!this.terrain),C=this.order,P={},R=[];for(let U=C.length-1;U>=0;U--){const K=C[U];if(x(K)){P[K]=U;for(const te of u){const re=te[K];if(re)for(const pe of re)R.push(pe)}}}R.sort((U,K)=>K.intersectionZ-U.intersectionZ);const F=[];for(let U=C.length-1;U>=0;U--){const K=C[U];if(x(K))for(let te=R.length-1;te>=0;te--){const re=R[te].feature;if(re.layer&&P[re.layer.id]{if(GN.has(re.type))return;const pe=this.getOwnLayerSourceCache(re),me=R[pe.id]=R[pe.id]||{sourceCache:pe,layers:{},has3DLayers:!1};re.is3D(!!this.terrain)&&(me.has3DLayers=!0),me.layers[re.fqid]=me.layers[re.fqid]||{styleLayer:re,targets:[]},me.layers[re.fqid].targets.push({filter:P})};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 re of x.layers){const pe=this._layers[re];if(!pe)return this.fire(new i.y(new Error(`The layer '${re}' does not exist in the map's style and cannot be queried for features.`))),[];F(pe)}}else for(const re in this._layers)F(this._layers[re]);const U=this._queryRenderedFeatures(u,R,C),K=this._flattenAndSortRenderedFeatures(U),te=[];for(const re of K)i.dw(re.layer.id)===this.scope&&te.push(re);return te}queryRenderedFeatureset(u,x,C){let P;x&&!Array.isArray(x)&&x.filter&&(this._validate(Co,"queryRenderedFeatures.filter",x.filter,null,x),P=i.b6(x.filter));const R="mock",F=[];if(x&&x.target)F.push(Object.assign({},x,{targetId:R,filter:P}));else{const re=this.getFeaturesetDescriptors();for(const pe of re)F.push({targetId:R,filter:P,target:pe});for(const{style:pe}of this.fragments){const me=pe.getFeaturesetDescriptors();for(const fe of me)F.push({targetId:R,filter:P,target:fe})}}const U=this.queryRenderedTargets(u,F,C),K=[],te=new Set;for(const re of U)for(const pe of re.variants[R])Lg(pe,re,te)||K.push(new i.dx(re,pe));return K}queryRenderedTargets(u,x,C){const P={},R=(U,K,te,re)=>{const pe=P[K.id]=P[K.id]||{sourceCache:K,layers:{},has3DLayers:!1};if(pe.layers[U.fqid]=pe.layers[U.fqid]||{styleLayer:U,targets:[]},U.is3D(!!this.terrain)&&(pe.has3DLayers=!0),!re)return te.uniqueFeatureID=!1,void pe.layers[U.fqid].targets.push(te);pe.layers[U.fqid].targets.push(Object.assign({},te,{namespace:re.namespace,properties:re.properties,uniqueFeatureID:re.uniqueFeatureID}))};for(const U of x)if("featuresetId"in U.target){const{featuresetId:K,importId:te}=U.target,re=this.getFragmentStyle(te);if(!re||!re._featuresetSelectors)continue;const pe=re._featuresetSelectors[K];if(!pe){this.fire(new i.y(new Error(`The featureset '${K}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const me of pe){const fe=re.getOwnLayer(me.layerId);fe&&!GN.has(fe.type)&&R(fe,re.getOwnLayerSourceCache(fe),U,me)}}else if("layerId"in U.target){const{layerId:K}=U.target,te=this.getLayer(K);if(!te||GN.has(te.type))continue;R(te,this.getLayerSourceCache(te),U)}const F=this._queryRenderedFeatures(u,P,C);return this._flattenAndSortRenderedFeatures(F)}_queryRenderedFeatures(u,x,C){const P=[],R=!!this.map._showQueryGeometry,F=Zi.createFromScreenPoints(u,C);for(const U in x){const K=A0(F,x[U],this._availableImages,C,R);Object.keys(K).length&&P.push(K)}if(this.placement)for(const U in x){if(!x[U].sourceCache._onlySymbols)continue;const K=E0(F.screenGeometry,x[U],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(K).length&&P.push(K)}return P}querySourceFeatures(u,x){const C=x&&x.filter;C&&this._validate(Co,"querySourceFeatures.filter",C,null,x);let P=[];const R=this.getOwnSourceCaches(u);for(const F of R)P=P.concat(I0(F,x));return P}addSourceType(u,x,C){return Fh.getSourceType(u)?C(new Error(`A source type called "${u}" already exists.`)):(Fh.setSourceType(u,x),x.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:u,url:x.workerSourceURL},C):C(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(u,x,C={}){this._checkLoaded();const P=this.light.getLight();let R=!1;for(const U in u)if(!i.by(u[U],P[U])){R=!0;break}if(!R)return;const F=this._getTransitionParameters();this.light.setLight(u,x,C),this.light.updateTransitions(F)}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(u,x=1){if(this._checkLoaded(),!u)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),x===0&&delete this.terrain,u===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let C=u;const P=!("source"in u)||u.source==null;if(x===1){if(this.disableElevatedTerrain)return;if("source"in C&&typeof C.source=="object"){const U="terrain-dem-src";this.addSource(U,C.source),C=i.dp(C),C=Object.assign(C,{source:U})}const R=Object.assign({},C),F={};if(this.terrain&&P){R.source=this.terrain.get().source;const U=this.terrain?this.getFragmentStyle(this.terrain.scope):null;U&&(F.style=U.serialize())}if(this._validate(zi,"terrain",R,F))return}if(!this.terrain||this.terrain.scope!==this.scope&&!P||this.terrain&&x!==this.terrain.drapeRenderMode){if(!C)return;this._createTerrain(C,x),this.fire(new i.z("data",{dataType:"style"}))}else{const R=this.terrain,F=R.get();for(const U of Object.keys(i.a6.terrain))!C.hasOwnProperty(U)&&i.a6.terrain[U].default&&(C[U]=i.a6.terrain[U].default);for(const U in u)if(!i.by(u[U],F[U])){R.set(u,this.options),this.stylesheet.terrain=u;const K=this._getTransitionParameters({duration:0});R.updateTransitions(K),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(u){const x=this.fog=new yn(u,this.map.transform,this.scope,this.options);this.stylesheet.fog=x.get();const C=this._getTransitionParameters({duration:0});x.updateTransitions(C)}_createSnow(u){const x=this.snow=new Fo(u,this.map.transform,this.scope,this.options);this.stylesheet.snow=x.get();const C=this._getTransitionParameters({duration:0});x.updateTransitions(C)}_createRain(u){const x=this.rain=new Ki(u,this.map.transform,this.scope,this.options);this.stylesheet.rain=x.get();const C=this._getTransitionParameters({duration:0});x.updateTransitions(C)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const u of this.map._markers)u._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(u){if(this._checkLoaded(),!u)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const x=this.fog;if(!i.by(x.get(),u)){x.set(u,this.options),this.stylesheet.fog=x.get();const C=this._getTransitionParameters({duration:0});x.updateTransitions(C)}}else this._createFog(u);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(u){if(this._checkLoaded(),!u)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const x=this.snow;if(!i.by(x.get(),u)){x.set(u,this.options),this.stylesheet.snow=x.get();const C=this._getTransitionParameters({duration:0});x.updateTransitions(C)}}else this._createSnow(u);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(u){if(this._checkLoaded(),!u)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const x=this.rain;if(!i.by(x.get(),u)){x.set(u,this.options),this.stylesheet.rain=x.get();const C=this._getTransitionParameters({duration:0});x.updateTransitions(C)}}else this._createRain(u);this._markersNeedUpdate=!0}_reloadColorTheme(){const u=()=>{for(const P in this._layers)this._layers[P].lut=this._styleColorTheme.lut;for(const P in this._sourceCaches)this._sourceCaches[P].clearTiles()},x=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!x)return this._styleColorTheme.lut=null,void u();const C=this._evaluateColorThemeData(x);this._loadColorTheme(C).then(()=>{this.fire(new i.z("colorthemeset")),u()}).catch(P=>{i.w(`Couldn't set color theme: ${P}`)})}setColorTheme(u){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=u,this._reloadColorTheme()}setImportColorTheme(u,x){const C=this.getFragmentStyle(u);C&&(C._styleColorTheme.colorThemeOverride=x,C._reloadColorTheme())}_getTransitionParameters(u){return{now:i.o.now(),transition:Object.assign(this.transition,u)}}updateDrapeFirstLayers(){if(!this.terrain)return;const u=[],x=[];for(const C of this._mergedOrder)this.isLayerDraped(this._mergedLayers[C])?u.push(C):x.push(C);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...u),this._drapedFirstOrder.push(...x)}_createTerrain(u,x){const C=this.terrain=new Ft(u,x,this.scope,this.options,this.map.getWorldview());x===1&&(this.stylesheet.terrain=u),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const P=this._getTransitionParameters({duration:0});C.updateTransitions(P)}_force3DLayerUpdate(){for(const u in this._layers){const x=this._layers[u];x.type==="fill-extrusion"&&this._updateLayer(x)}}_forceSymbolLayerUpdate(){for(const u in this._layers){const x=this._layers[u];x.type==="symbol"&&this._updateLayer(x)}}_validate(u,x,C,P,R={}){if(R&&R.validate===!1)return!1;const F=Object.assign({},this.serialize());return zg(this,u.call(Pr,Object.assign({key:x,style:F,value:C,styleSpec:i.a6},P)))}_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 u in this._mergedLayers)this._mergedLayers[u].setEventedParent(null);for(const u in this._mergedSourceCaches)this._mergedSourceCaches[u].clearTiles(),this._mergedSourceCaches[u].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(u){const x=this.getSourceCaches(u);for(const C of x)C.clearTiles()}clearSources(){for(const u in this._mergedSourceCaches)this._mergedSourceCaches[u].clearTiles()}clearLayers(){for(const u in this._mergedLayers){const x=this._mergedLayers[u];x._clear&&x._clear()}}reloadSource(u){const x=this.getSourceCaches(u);for(const C of x)C.resume(),C.reload()}reloadSources(){for(const u of this.getSources())u.reload&&u.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(u=>{u.modelManager.reloadModels(u.scope)})}updateSources(u){let x;this.directionalLight&&(x=T_(this.directionalLight));const C=new Set,P=new Set;for(const R in this._mergedLayers){const F=this._mergedLayers[R];F.type==="building"&&C.add(F.source),F.hasElevation()&&!P.has(F.source)&&P.add(F.source)}for(const R in this._mergedSourceCaches){const F=this._mergedSourceCaches[R],U=P.has(F._source.id);C.has(F._source.id)&&(F._source.reparseOverscaled=!1),F.update(u,void 0,void 0,x,U)}}_generateCollisionBoxes(){for(const u in this._sourceCaches){const x=this._sourceCaches[u];x.resume(),x.reload()}}_updatePlacement(u,x,C,P,R,F,U=!1){let K=!1,te=!1;const re={},pe={};for(const we of this._mergedOrder){const Re=this._mergedLayers[we];if(Re.type!=="symbol")continue;const Le=i.B(Re.source,Re.scope);let Ze=re[Le];if(!Ze){const Xe=this.getLayerSourceCache(Re);if(!Xe)continue;const Mt=Xe.getRenderableIds(!0).map(gt=>Xe.getTileByID(gt));pe[Le]=Mt.slice(),Ze=re[Le]=Mt.sort((gt,jt)=>jt.tileID.overscaledZ-gt.tileID.overscaledZ||(gt.tileID.isLessThan(jt.tileID)?-1:1))}const nt=this.crossTileSymbolIndex.addLayer(Re,Ze,x.center.lng,x.projection);K=K||nt}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),U=U||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const me=!!(this.placement&&!x.equals(this.placement.transform)),fe=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!F||this.placement.lastReplacementSourceUpdateTime!==F.updateTime)),Ne=(me||fe||K||this.placement&&this.placement.isStale())&&P===0;if((U||!this.pauseablePlacement||Ne||P!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),x.zoom))&&(this.pauseablePlacement=new Dl(x,this._mergedOrder,U||P===0,C,P,R,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,re,pe,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),te=!0),K&&this.pauseablePlacement.placement.setStale()),te||K){this._buildingIndex.onNewFrame(x.zoom);for(let we=0;weR===u.id)!==-1)return void this.fire(new i.y(new Error(`Import with id '${u.id}' already exists in the map's style.`)));if(!x)return C.push(u),this._loadImports([u],!0);const P=C.findIndex(({id:R})=>R===x);return P===-1&&this.fire(new i.y(new Error(`Import with id "${x}" does not exist on this map.`))),this.stylesheet.imports=C.slice(0,P).concat(u).concat(C.slice(P)),this._loadImports([u],!0,x)}updateImport(u,x){this._checkLoaded();const C=this.stylesheet.imports||[],P=this.getImportIndex(u);return P===-1?this:typeof x=="string"?(this.setImportUrl(u,x),this):(x.url&&x.url!==C[P].url&&this.setImportUrl(u,x.url),i.by(x.config,C[P].config)||this.setImportConfig(u,x.config,x.data.schema),i.by(x.data,C[P].data)||this.setImportData(u,x.data),this)}moveImport(u,x){this._checkLoaded();let C=this.stylesheet.imports||[];const P=this.getImportIndex(u);if(P===-1)return this;const R=this.getImportIndex(x);if(R===-1)return this;const F=C[P],U=this.fragments[P];return C=C.filter(({id:K})=>K!==u),this.fragments=this.fragments.filter(({id:K})=>K!==u),this.stylesheet.imports=C.slice(0,R).concat(F).concat(C.slice(R)),this.fragments=this.fragments.slice(0,R).concat(U).concat(this.fragments.slice(R)),this.mergeLayers(),this}setImportUrl(u,x){this._checkLoaded();const C=this.stylesheet.imports||[],P=this.getImportIndex(u);if(P===-1)return this;C[P].url=x;const R=this.fragments[P];return R.style=this._createFragmentStyle(C[P]),R.style.on("style.import.load",()=>this.mergeAll()),R.style.loadURL(x),this}setImportData(u,x){this._checkLoaded();const C=this.getImportIndex(u),P=this.stylesheet.imports||[];return C===-1?this:x?(this.fragments[C].style.setState(x),this._reloadImports(),this):(delete P[C].data,this.setImportUrl(u,P[C].url))}setImportConfig(u,x,C){this._checkLoaded();const P=this.getImportIndex(u),R=this.stylesheet.imports||[];if(P===-1)return this;x?R[P].config=x:delete R[P].config;const F=this.fragments[P];C&&F.style.stylesheet&&(F.style.stylesheet.schema=C);const U=F.style.stylesheet&&F.style.stylesheet.schema;return F.config=x,F.style.updateConfig(x,U),this.updateConfigDependencies(),this}removeImport(u){this._checkLoaded();const x=this.stylesheet.imports||[],C=this.getImportIndex(u);C!==-1&&(x.splice(C,1),this.fragments[C].style._remove(),this.fragments.splice(C,1),this._reloadImports())}getImportIndex(u){const x=(this.stylesheet.imports||[]).findIndex(C=>C.id===u);return x===-1&&this.fire(new i.y(new Error(`Import '${u}' does not exist in the map's style and cannot be updated.`))),x}getLayer(u){return this._mergedLayers[u]}getSources(){const u=[];for(const x in this._mergedOtherSourceCaches){const C=this._mergedOtherSourceCaches[x];C&&u.push(C.getSource())}return u}getSource(u,x){const C=this.getSourceCache(u,x);return C&&C.getSource()}getLayerSource(u){const x=this.getLayerSourceCache(u);return x&&x.getSource()}getSourceCache(u,x){const C=i.B(u,x);return this._mergedOtherSourceCaches[C]}getLayerSourceCache(u){const x=i.B(u.source,u.scope);return u.type==="symbol"?this._mergedSymbolSourceCaches[x]:this._mergedOtherSourceCaches[x]}getSourceCaches(u){if(u==null)return Object.values(this._mergedSourceCaches);const x=[];return this._mergedOtherSourceCaches[u]&&x.push(this._mergedOtherSourceCaches[u]),this._mergedSymbolSourceCaches[u]&&x.push(this._mergedSymbolSourceCaches[u]),x}updateSourceCaches(){const u=this._changes.getUpdatedSourceCaches();for(const x in u){const C=u[x];C==="reload"?this.reloadSource(x):C==="clear"&&this.clearSource(x)}}updateLayers(u){const x=this._changes.getUpdatedPaintProperties();for(const C of x){const P=this.getLayer(C);P&&P.updateTransitions(u)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(u){this.stylesheet.glyphs=u,this.glyphManager.setURL(u)}getImages(u,x,C){this.imageManager.getImages(x.images,x.scope,C),this._updateTilesForChangedImages();const P=F=>{if(F){const U=x.images.map(K=>i.I.toString(K));F.setDependencies(x.tileID.key,x.type,U)}},R=i.B(x.source,x.scope);P(this._mergedOtherSourceCaches[R]),P(this._mergedSymbolSourceCaches[R]),x.images.some(F=>F.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(u,x,C){this.imageManager.rasterizeImages(x,C)}getGlyphs(u,x,C){this.glyphManager.getGlyphs(x.stacks,C)}getResource(u,x,C){return i.dz(x,C)}getOwnSourceCache(u){return this._otherSourceCaches[u]}getOwnLayerSourceCache(u){return u.type==="symbol"?this._symbolSourceCaches[u.source]:this._otherSourceCaches[u.source]}getOwnSourceCaches(u){const x=[];return this._otherSourceCaches[u]&&x.push(this._otherSourceCaches[u]),this._symbolSourceCaches[u]&&x.push(this._symbolSourceCaches[u]),x}_isSourceCacheLoaded(u){const x=this.getOwnSourceCaches(u);return x.length===0?(this.fire(new i.y(new Error(`There is no source with ID '${u}'`))),!1):x.every(C=>C.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(u,x){if(!this._clipLayerPresent&&u.type!=="fill-extrusion"&&u.type!=="building")return!1;const C=u.type==="fill-extrusion"&&(u.sourceLayer==="building"||u.sourceLayer==="procedural_buildings"),P=u.type==="building";if(u.is3D(!!this.terrain)){if(C||P||x&&x.type==="batched-model"||u.type==="model")return!0}else if(u.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(u=>{u.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Fh.getSourceType=function(N){return Lh[N]},Fh.setSourceType=function(N,u){Lh[N]=u},Fh.registerForPluginStateChange=i.dA;class wL extends i.E{constructor(u){super(),this._style=u,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(u){u===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=u,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(u){this._activeFloorsVisible=u,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(u){for(const[x,C]of Object.entries(u.buildings))if(this._buildings[x])for(const P of C.floorIds)this._buildings[x].floors[P]||(this._buildings[x].floors[P]=C.floors[P]);else this._buildings[x]=C;for(const x of u.activeFloors)this._activeFloors.add(x);this._updateIndoorSelector()}getIndoorTileOptions(u,x){const C=this._style.getIndoorSourceLayers(u,x);return C&&this._indoorState?{sourceLayers:C,indoorState:this._indoorState}:null}_updateUI(u,x,C){const P=function(R,F,U,K){let te=null,re=Number.MAX_SAFE_INTEGER;if(K<16)return null;for(const[pe,me]of Object.entries(R)){const fe=me.center;if(fe){const Ne=F.distanceTo(i.aT.convert(fe));Ne({id:F,name:C.floors[F].name,zIndex:C.floors[F].zIndex})).sort((F,U)=>U.zIndex-F.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:P,activeFloorsVisible:this._activeFloorsVisible,floors:R}))}_updateActiveFloors(){const u=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:u,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var B0=` #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`,$0=` #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;}`,kM=` #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`,KN="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;}",eh=` #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`,ZN=`#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`,Hs=`#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`,NM=`#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`,YN=`#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;}`,XN=`#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`,SM=`#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 E_=/#include\s+"([^"]+)"/g,gp=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,CM=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,sy=new Set(["ifdef","ifndef","elif","if","defined"]),ry=new Set;Ug(B0,ry),Ug(kM,ry),Ug($0,ry);const $g={"_prelude_fog.vertex.glsl":ZN,"_prelude_terrain.vertex.glsl":eh,"_prelude_shadow.vertex.glsl":XN,"_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":Hs,"_prelude_shadow.fragment.glsl":SM,"_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":NM,"_prelude_raster_particle.glsl":YN},QN={};xa("",eh),xa(Hs,ZN),xa(SM,XN),xa(NM,""),xa(YN,"");const jL=xa($0,kM),JN=B0,Yle=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",JN,jL.fragmentSource].join(` `),kL=["precision highp float;",JN,jL.vertexSource].join(` `);var MM={background:xa(`#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:xa(`#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:xa(`#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:xa(`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:xa(`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:xa(`#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:xa("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:xa(`#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:xa(`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:xa("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:xa("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:xa("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:xa(`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:xa(`#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:xa(`#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:xa(`#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:xa(`#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:xa(`#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:xa(`#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:xa(`#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:xa(`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:xa(`#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:xa(`#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:xa(`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:xa(`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:xa(`#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:xa(`#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:xa(`#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:xa(`#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:xa(`#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:xa("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:xa("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:xa(`#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:xa(`#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:xa(`#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:xa("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:xa(`#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 }`,KN),skyboxGradient:xa(`#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 }`,KN),skyboxCapture:xa(` 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:xa(`#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:xa(`#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:xa(`#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:xa(`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:xa(`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:xa("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:xa("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:xa("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:xa("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 Ug(N,u){const x=N.split(` `);for(let C of x){if(C=C.trimStart(),C[0]!=="#"||!C.includes("if")||C.startsWith("#endif"))continue;const P=C.match(CM);if(P)for(const R of P)sy.has(R)||u.add(R)}}function xa(N,u){const x=new Set,C=[],P=[];N=N.replace(E_,(F,U)=>(P.push(U),"")),u=u.replace(E_,(F,U)=>(C.push(U),""));let R=new Set(ry);Ug(N,R),Ug(u,R);for(const F of[...C,...P])QN[F]||(QN[F]=new Set,Ug($g[F],QN[F])),R=new Set([...R,...QN[F]]);return{fragmentSource:N=N.replace(gp,(F,U,K,te,re)=>(x.add(re),U==="define"?` #ifndef HAS_UNIFORM_u_${re} in ${K} ${te} ${re}; #else uniform ${K} ${te} u_${re}; #endif `:U==="initialize"?` #ifdef HAS_UNIFORM_u_${re} ${K} ${te} ${re} = u_${re}; #endif `:U==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${re} in ${K} ${te} ${re}; #endif `:U==="initialize-attribute"?"":void 0)),vertexSource:u=u.replace(gp,(F,U,K,te,re)=>{const pe=`MATERIAL_ATTRIBUTE_OFFSET_${re}`,me=te==="float"?"vec2":te,fe=`GET_ATTRIBUTE_${me}(a_${re}, materialInfo, ${pe})`,Ne=re.match(/color/)?"color":me;return U==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${re} in ${K} ${te} a_${re}; #endif `:x.has(re)?U==="define"?` #ifndef HAS_UNIFORM_u_${re} uniform lowp float u_${re}_t; #if !defined(${pe}) in ${K} ${me} a_${re}; #endif out ${K} ${te} ${re}; #else uniform ${K} ${te} u_${re}; #endif `:U==="initialize"?Ne==="vec4"?` #ifndef HAS_UNIFORM_u_${re} ${re} = a_${re}; #else ${K} ${te} ${re} = u_${re}; #endif `:` #if !defined(HAS_UNIFORM_u_${re}) #ifdef ${pe} ${re} = unpack_mix_${Ne}(${fe}, u_${re}_t); #else ${re} = unpack_mix_${Ne}(a_${re}, u_${re}_t); #endif #else ${K} ${te} ${re} = u_${re}; #endif `:U==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${re} in ${K} ${te} a_${re}; out ${K} ${te} ${re}; #endif `:U==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${re} ${re} = a_${re}; #endif `:void 0:U==="define"?` #ifndef HAS_UNIFORM_u_${re} uniform lowp float u_${re}_t; #if !defined(${pe}) in ${K} ${me} a_${re}; #endif #else uniform ${K} ${te} u_${re}; #endif `:U==="define-instanced"?Ne==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${re}0; in vec4 a_${re}1; in vec4 a_${re}2; in vec4 a_${re}3; #else uniform ${K} ${te} u_${re}; #endif `:` #ifdef INSTANCED_ARRAYS in ${K} ${me} a_${re}; #else uniform ${K} ${te} u_${re}; #endif `:U==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${re} ${K} ${te} ${re} = a_${re}; #endif `:Ne==="vec4"?` #ifndef HAS_UNIFORM_u_${re} #ifdef ${pe} ${K} ${te} ${re} = ${fe}; #else ${K} ${te} ${re} = a_${re}; #endif #else ${K} ${te} ${re} = u_${re}; #endif `:` #ifndef HAS_UNIFORM_u_${re} #ifdef ${pe} ${K} ${te} ${re} = unpack_mix_${Ne}(${fe}, u_${re}_t); #else ${K} ${te} ${re} = unpack_mix_${Ne}(a_${re}, u_${re}_t); #endif #else ${K} ${te} ${re} = u_${re}; #endif `}),usedDefines:R,vertexIncludes:C,fragmentIncludes:P}}class Xle{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(u,x,C,P,R,F,U,K){this.context=u;let te=this.boundPaintVertexBuffers.length!==P.length;for(let pe=0;!te&&pe{const Mt=nt.paint.get("hillshade-shadow-color"),gt=nt.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",jt=nt.paint.get("hillshade-highlight-color"),ft=nt.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",ht=nt.paint.get("hillshade-accent-color"),At=nt.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Ut=nt.paint.get("hillshade-emissive-strength");let Bt=i.an(nt.paint.get("hillshade-illumination-direction"));if(nt.paint.get("hillshade-illumination-anchor")==="viewport")Bt-=Le.transform.angle;else if(Le.style&&Le.style.enable3dLights()&&Le.style.directionalLight){const rs=Le.style.directionalLight.properties.get("direction"),ms=i.d4(rs.x,rs.y,rs.z);Bt=i.an(ms[1])}const ts=!Le.options.moving;return{u_matrix:Xe||Le.transform.calculateProjMatrix(Ze.tileID.toUnwrapped(),ts),u_image:0,u_latrange:Qle(0,Ze.tileID),u_light:[nt.paint.get("hillshade-exaggeration"),Bt],u_shadow:Mt.toPremultipliedRenderColor(gt?null:nt.lut),u_highlight:jt.toPremultipliedRenderColor(ft?null:nt.lut),u_emissive_strength:Ut,u_accent:ht.toPremultipliedRenderColor(At?null:nt.lut)}})(N,x,C,N.terrain?u.projMatrix:null);N.uploadCommonUniforms(U,me,u.toUnwrapped());const{tileBoundsBuffer:Ne,tileBoundsIndexBuffer:we,tileBoundsSegments:Re}=N.getTileBoundsBuffers(x);me.draw(N,K.TRIANGLES,P,R,F,tn.disabled,fe,C.id,Ne,we,Re)}function TM(N,u,x){if(!u.needsDEMTextureUpload)return;const C=N.context,P=C.gl;C.pixelStoreUnpackPremultiplyAlpha.set(!1),u.demTexture=u.demTexture||N.getTileTexture(x.stride);const R=x.getPixels();u.demTexture?u.demTexture.update(R,{premultiply:!1}):u.demTexture=new i.T(C,R,P.R32F,{premultiply:!1}),u.needsDEMTextureUpload=!1}function ece(N,u,x){const C=N.context,P=C.gl;if(!u.dem)return;const R=u.dem;if(C.activeTexture.set(P.TEXTURE1),TM(N,u,R),!u.demTexture)return;u.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);const F=R.dim;C.activeTexture.set(P.TEXTURE0);let U=u.hillshadeFBO;if(!U){const me=new i.T(C,{width:F,height:F,data:null},P.RGBA8);me.bind(P.LINEAR,P.CLAMP_TO_EDGE),U=u.hillshadeFBO=C.createFramebuffer(F,F,1,"renderbuffer"),U.colorAttachment0.set(me.texture)}C.bindFramebuffer.set(U.framebuffer),C.viewport.set([0,0,F,F]);const{tileBoundsBuffer:K,tileBoundsIndexBuffer:te,tileBoundsSegments:re}=N.getMercatorTileBoundsBuffers(),pe=[];N.linearFloatFilteringSupported()&&pe.push("TERRAIN_DEM_FLOAT_FORMAT"),N.terrain&&N.terrain.renderingToTexture&&N.emissiveMode==="mrt-fallback"&&pe.push("USE_MRT1"),N.getOrCreateProgram("hillshadePrepare",{defines:pe}).draw(N,P.TRIANGLES,Cr.disabled,sn.disabled,Cn.unblended,tn.disabled,((me,fe)=>{const Ne=fe.stride,we=i.bC();return i.ce(we,0,i.al,-i.al,0,0,1),i.br(we,we,[0,-i.al,0]),{u_matrix:we,u_image:1,u_dimension:[Ne,Ne],u_zoom:me.overscaledZ}})(u.tileID,R),x.id,K,te,re),u.needsHillshadePrepare=!1}class Xi{constructor(u){this.gl=u.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(u){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class tce extends Xi{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(u){const x=this.current;(u.r!==x.r||u.g!==x.g||u.b!==x.b||u.a!==x.a||this.dirty)&&(this.gl.clearColor(u.r,u.g,u.b,u.a),this.current=u,this.dirty=!1)}}class NL extends Xi{getDefault(){return 1}set(u){(u!==this.current||this.dirty)&&(this.gl.clearDepth(u),this.current=u,this.dirty=!1)}}class AM extends Xi{getDefault(){return 0}set(u){(u!==this.current||this.dirty)&&(this.gl.clearStencil(u),this.current=u,this.dirty=!1)}}class eS extends Xi{getDefault(){return[!0,!0,!0,!0]}set(u){const x=this.current;(u[0]!==x[0]||u[1]!==x[1]||u[2]!==x[2]||u[3]!==x[3]||this.dirty)&&(this.gl.colorMask(u[0],u[1],u[2],u[3]),this.current=u,this.dirty=!1)}}class EM extends Xi{getDefault(){return!0}set(u){(u!==this.current||this.dirty)&&(this.gl.depthMask(u),this.current=u,this.dirty=!1)}}class ny extends Xi{getDefault(){return 255}set(u){(u!==this.current||this.dirty)&&(this.gl.stencilMask(u),this.current=u,this.dirty=!1)}}class U0 extends Xi{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(u){const x=this.current;(u.func!==x.func||u.ref!==x.ref||u.mask!==x.mask||this.dirty)&&(this.gl.stencilFunc(u.func,u.ref,u.mask),this.current=u,this.dirty=!1)}}class I_ extends Xi{getDefault(){const u=this.gl;return[u.KEEP,u.KEEP,u.KEEP]}set(u){const x=this.current;(u[0]!==x[0]||u[1]!==x[1]||u[2]!==x[2]||this.dirty)&&(this.gl.stencilOp(u[0],u[1],u[2]),this.current=u,this.dirty=!1)}}class q0 extends Xi{getDefault(){return!1}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;u?x.enable(x.STENCIL_TEST):x.disable(x.STENCIL_TEST),this.current=u,this.dirty=!1}}class SL extends Xi{getDefault(){return[0,1]}set(u){const x=this.current;(u[0]!==x[0]||u[1]!==x[1]||this.dirty)&&(this.gl.depthRange(u[0],u[1]),this.current=u,this.dirty=!1)}}class IM extends Xi{getDefault(){return!1}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;u?x.enable(x.DEPTH_TEST):x.disable(x.DEPTH_TEST),this.current=u,this.dirty=!1}}class CL extends Xi{getDefault(){return this.gl.LESS}set(u){(u!==this.current||this.dirty)&&(this.gl.depthFunc(u),this.current=u,this.dirty=!1)}}class V0 extends Xi{getDefault(){return!1}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;u?x.enable(x.BLEND):x.disable(x.BLEND),this.current=u,this.dirty=!1}}class tS extends Xi{getDefault(){const u=this.gl;return[u.ONE,u.ZERO,u.ONE,u.ZERO]}set(u){const x=this.current;(u[0]!==x[0]||u[1]!==x[1]||u[2]!==x[2]||u[3]!==x[3]||this.dirty)&&(this.gl.blendFuncSeparate(u[0],u[1],u[2],u[3]),this.current=u,this.dirty=!1)}}class sS extends Xi{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(u){const x=this.current;(u.r!==x.r||u.g!==x.g||u.b!==x.b||u.a!==x.a||this.dirty)&&(this.gl.blendColor(u.r,u.g,u.b,u.a),this.current=u,this.dirty=!1)}}class PM extends Xi{getDefault(){return this.gl.FUNC_ADD}set(u){(u!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(u,u),this.current=u,this.dirty=!1)}}class rS extends Xi{getDefault(){return!1}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;u?x.enable(x.CULL_FACE):x.disable(x.CULL_FACE),this.current=u,this.dirty=!1}}class P_ extends Xi{getDefault(){return this.gl.BACK}set(u){(u!==this.current||this.dirty)&&(this.gl.cullFace(u),this.current=u,this.dirty=!1)}}class ML extends Xi{getDefault(){return this.gl.CCW}set(u){(u!==this.current||this.dirty)&&(this.gl.frontFace(u),this.current=u,this.dirty=!1)}}let TL=class extends Xi{getDefault(){return null}set(N){(N!==this.current||this.dirty)&&(this.gl.useProgram(N),this.current=N,this.dirty=!1)}};class AL extends Xi{getDefault(){return this.gl.TEXTURE0}set(u){(u!==this.current||this.dirty)&&(this.gl.activeTexture(u),this.current=u,this.dirty=!1)}}class H0 extends Xi{getDefault(){const u=this.gl;return[0,0,u.drawingBufferWidth,u.drawingBufferHeight]}set(u){const x=this.current;(u[0]!==x[0]||u[1]!==x[1]||u[2]!==x[2]||u[3]!==x[3]||this.dirty)&&(this.gl.viewport(u[0],u[1],u[2],u[3]),this.current=u,this.dirty=!1)}}class EL extends Xi{getDefault(){return null}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;x.bindFramebuffer(x.FRAMEBUFFER,u),this.current=u,this.dirty=!1}}class sce extends Xi{getDefault(){return null}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;x.bindRenderbuffer(x.RENDERBUFFER,u),this.current=u,this.dirty=!1}}class rce extends Xi{getDefault(){return null}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;x.bindTexture(x.TEXTURE_2D,u),this.current=u,this.dirty=!1}}class nce extends Xi{getDefault(){return null}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;x.bindBuffer(x.ARRAY_BUFFER,u),this.current=u,this.dirty=!1}}class LM extends Xi{getDefault(){return null}set(u){const x=this.gl;x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,u),this.current=u,this.dirty=!1}}class DM extends Xi{getDefault(){return null}set(u){this.gl&&(u!==this.current||this.dirty)&&(this.gl.bindVertexArray(u),this.current=u,this.dirty=!1)}}class OM extends Xi{getDefault(){return 4}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_ALIGNMENT,u),this.current=u,this.dirty=!1}}class RM extends Xi{getDefault(){return!1}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_PREMULTIPLY_ALPHA_WEBGL,u),this.current=u,this.dirty=!1}}class IL extends Xi{getDefault(){return!1}set(u){if(u===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_FLIP_Y_WEBGL,u),this.current=u,this.dirty=!1}}class nS extends Xi{constructor(u,x){super(u),this.context=u,this.parent=x}getDefault(){return null}}class aS extends nS{constructor(u,x,C=0){super(u,x),this.attachmentPoint=u.gl.COLOR_ATTACHMENT0+C}setDirty(){this.dirty=!0}set(u){if(u===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferTexture2D(x.FRAMEBUFFER,this.attachmentPoint,x.TEXTURE_2D,u,0),this.current=u,this.dirty=!1}}class W0 extends nS{attachment(){return this.gl.DEPTH_ATTACHMENT}set(u){if(u===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferRenderbuffer(x.FRAMEBUFFER,this.attachment(),x.RENDERBUFFER,u),this.current=u,this.dirty=!1}}class L_ extends nS{attachment(){return this.gl.DEPTH_ATTACHMENT}set(u){if(u===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferTexture2D(x.FRAMEBUFFER,this.attachment(),x.TEXTURE_2D,u,0),this.current=u,this.dirty=!1}}class PL extends W0{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const th=(N,u,x,C)=>({u_matrix:N,u_image0:0,u_image1:1,u_skirt_height:u,u_ground_shadow_factor:x,u_emissive_texture_available:C}),iS=(N,u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re)=>({u_proj_matrix:Float32Array.from(N),u_globe_matrix:u,u_normalize_matrix:Float32Array.from(C),u_merc_matrix:x,u_zoom_transition:P,u_merc_center:R,u_image0:0,u_image1:1,u_frustum_tl:F,u_frustum_tr:U,u_frustum_br:K,u_frustum_bl:te,u_globe_pos:re,u_globe_radius:pe,u_viewport:me,u_grid_matrix:Re?Float32Array.from(Re):new Float32Array(9),u_skirt_height:fe,u_far_z_cutoff:Ne,u_emissive_texture_available:we});function D_(N,u){return N!=null&&u!=null&&!(!N.hasData()||!u.hasData())&&N.demTexture!=null&&u.demTexture!=null&&N.tileID.key!==u.tileID.key}const gf=new class{constructor(){this.operations={}}newMorphing(N,u,x,C,P){if(N in this.operations){const R=this.operations[N];R.to.tileID.key!==x.tileID.key&&(R.queued=x)}else this.operations[N]={startTime:C,phase:0,duration:P,from:u,to:x,queued:null}}getMorphValuesForProxy(N){if(!(N in this.operations))return null;const u=this.operations[N];return{from:u.from,to:u.to,phase:u.phase}}update(N){for(const u in this.operations){const x=this.operations[u];for(x.phase=(N-x.startTime)/x.duration;x.phase>=1||!this._validOp(x);)if(!this._nextOp(x,N)){delete this.operations[u];break}}}_nextOp(N,u){return!!N.queued&&(N.from=N.to,N.to=N.queued,N.queued=null,N.phase=0,N.startTime=u,!0)}_validOp(N){return N.from.hasData()&&N.to.hasData()}},oS={0:null,1:"TERRAIN_VERTEX_MORPHING"};function lS(N,u,x){if(u===0)return 0;const C=u<1&&x===514?.25/u:1;return 6*Math.pow(1.5,22-N)*Math.max(u,1)*C}function FM(N,u){const x=1<({u_matrix:N});function R_(N,u,x,C,P){if(P>0){const R=i.o.now(),F=(R-N.timeAdded)/P,U=u?(R-u.timeAdded)/P:-1,K=x.getSource(),te=C.coveringZoomLevel({tileSize:K.tileSize,roundZoom:K.roundZoom}),re=!u||Math.abs(u.tileID.overscaledZ-te)>Math.abs(N.tileID.overscaledZ-te),pe=re&&N.refreshedUponExpiration?1:i.aA(re?F:1-U,0,1);return u?{opacity:1,mix:1-pe,isFading:F<1}:{opacity:pe,mix:0,isFading:F<1}}return{opacity:1,mix:0,isFading:!1}}class cS extends Dd{constructor(u){const x=il("mock-dem",{type:"raster-dem",maxzoom:u.transform.maxZoom},u.style.dispatcher,u.style);super("mock-dem",x,!1),x.setEventedParent(this),this._sourceLoaded=!0}_loadTile(u,x){u.state="loaded",x(null)}}class zM extends Dd{constructor(u){const x=il("proxy",{type:"geojson",maxzoom:u.transform.maxZoom},u.style.dispatcher,u.style);super("proxy",x,!1),x.setEventedParent(this),this.map=this.getSource().map=u,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(u,x,C){if(u.freezeTileCoverage)return;this.transform=u;const P=u.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((R,F)=>{if(R[F.key]="",!this._tiles[F.key]){const U=new uf(F,this._source.tileSize*F.overscaleFactor(),u.tileZoom,void 0,void 0,this._source.worldview);U.state="loaded",this._tiles[F.key]=U}return R},{});for(const R in this._tiles)R in P||(this.freeFBO(R),this._tiles[R].unloadVectorData(),delete this._tiles[R])}freeFBO(u){const x=this.proxyCachedFBO[u];if(x!==void 0){const C=Object.values(x);this.renderCachePool.push(...C),delete this.proxyCachedFBO[u]}}deallocRenderCache(){this.renderCache.forEach(u=>u.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class BM extends i.aQ{constructor(u,x,C){super(u.overscaledZ,u.wrap,u.canonical.z,u.canonical.x,u.canonical.y),this.proxyTileKey=x,this.projMatrix=C}}class $M extends i.bV{constructor(u,x){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=u,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[C,P,R]=function(K){const te=new i.bd,re=new i.b0,pe=131;te.reserve(17161),re.reserve(33800);const me=i.al/128,fe=i.al+me/2,Ne=fe+me;for(let Re=-me;Refe||Re<0||Re>fe?24575:0,nt=i.aA(Math.round(Le),0,i.al),Xe=i.aA(Math.round(Re),0,i.al);te.emplaceBack(nt+Ze,Xe)}const we=(Re,Le)=>{const Ze=Le*pe+Re;re.emplaceBack(Ze+1,Ze,Ze+pe),re.emplaceBack(Ze+pe,Ze+pe+1,Ze+1)};for(let Re=1;Re<129;Re++)for(let Le=1;Le<129;Le++)we(Le,Re);return[0,129].forEach(Re=>{for(let Le=0;Le<130;Le++)we(Le,Re),we(Re,Le)}),[te,re,32768]}(),F=u.context;this.gridBuffer=F.createVertexBuffer(C,i.bf.members),this.gridIndexBuffer=F.createIndexBuffer(P),this.gridSegments=i.bg.simpleSegment(0,0,C.length,P.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,C.length,R),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new zM(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 U=F.gl;this._overlapStencilMode=new sn({func:U.GEQUAL,mask:255},0,255,U.KEEP,U.KEEP,U.REPLACE),this._previousZoom=u.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=x,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new cS(x.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(u){u.on("data",this._onStyleDataEvent.bind(this)),this._style=u,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(u,x,C){if(u&&u.terrain){this._style!==u&&(this.style=u,this._evaluationZoom=void 0);const P=u.terrain.properties,R=u.terrain.drapeRenderMode===0,F=u.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const U=u.terrain&&u.terrain.scope,K=P.get("source"),te=R?this._mockSourceCache:u.getSourceCache(K,U);if(!te)return void i.w(`Couldn't find terrain source "${K}".`);if(this.sourceCache=te,this._attenuationRange=u.terrain.getAttenuationRange(),this._exaggeration=F?this.calculateExaggeration(x):P.get("exaggeration"),!x.projection.requiresDraping&&F&&this._exaggeration===0)return void this._disable();this.enabled=!0;const re=()=>{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 pe=this.getScaledDemTileSize();this.sourceCache.update(x,pe,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,re(),this._initializing=!0),re(),x.updateElevation(!0,C),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(x),this._emptyDEMTextureDirty=!0,this._previousZoom=x.zoom}else this._disable()}calculateExaggeration(u){if(this._attenuationRange&&u.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(u.zoom);const x=this._previousCameraAltitude,C=u.getFreeCameraOptions().position.z/u.pixelsPerMeter*u.worldSize;this._previousCameraAltitude=C;const P=x!=null?C-x:Number.MAX_VALUE;if(Math.abs(P)<2)return this._exaggeration;const R=u.zoom,F=this._style.terrain;if(!this._previousUpdateTimestamp)return F.getExaggeration(R);let U=R-this._previousZoom;const K=this._previousUpdateTimestamp;let te=R;this._evaluationZoom!=null&&(te=this._evaluationZoom,Math.abs(R-te)>.5&&(U=.5*(R-te+U)),U*P<0&&(te+=U)),this._evaluationZoom=te;const re=F.getExaggeration(te),pe=re===F.getExaggeration(Math.max(0,te-.1));if(pe&&Math.abs(re-this._exaggeration)<.01)return re;let me=Math.min(.1,.00375*(this._updateTimestamp-K));return(pe||re<.1||Math.abs(U)<1e-4)&&(me=Math.min(.2,4*me)),i.ak(this._exaggeration,re,me)}resetTileLookupCache(u){this._findCoveringTileCache[u]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(u){u.dataType==="source"&&u.coord?this._clearRenderCacheForTile(u.sourceCacheId,u.coord):u.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 u in this._style._mergedSourceCaches)this._style._mergedSourceCaches[u].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(u=>u.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 u=2*this.proxySourceCache.getSource().tileSize;return[u,u]}set useVertexMorphing(u){this._useVertexMorphing=u}updateTileBinding(u){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const x=this.proxySourceCache,C=this.painter.transform;this._initializing&&(this._initializing=C._centerAltitude===0&&this.getAtPointOrZero(i.ae.fromLngLat(C.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const P=this.proxyCoords=x.getIds().map(K=>{const te=x.getTileByID(K).tileID;return te.projMatrix=C.calculateProjMatrix(te.toUnwrapped()),te});(function(K,te){const re=te.transform.pointCoordinate(te.transform.getCameraPoint()),pe=new i.P(re.x,re.y);K.sort((me,fe)=>{if(fe.overscaledZ-me.overscaledZ)return fe.overscaledZ-me.overscaledZ;const Ne=new i.P(me.canonical.x+(1<{this.proxyToSource[K.key]={}}),this.terrainTileForTile={};const F=this._style._mergedSourceCaches;for(const K in F){const te=F[K];if(!te.used||(te!==this.sourceCache&&this.resetTileLookupCache(te.id),this._setupProxiedCoordsForOrtho(te,u[K],R),te.usedForTerrain))continue;const re=u[K];te.getSource().reparseOverscaled&&this._assignTerrainTiles(re)}this.proxiedCoords[x.id]=P.map(K=>new BM(K,K.key,this.orthoMatrix)),this._assignTerrainTiles(P),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(R),this.renderingToTexture=!1;const U={};this._visibleDemTiles=[];for(const K of this.proxyCoords){const te=this.terrainTileForTile[K.key];if(!te)continue;const re=te.tileID.key;re in U||(this._visibleDemTiles.push(te),U[re]=re)}}_assignTerrainTiles(u){this._initializing||u.forEach(x=>{if(this.terrainTileForTile[x.key])return;const C=this._findTileCoveringTileID(x,this.sourceCache);C&&(this.terrainTileForTile[x.key]=C)})}_prepareDEMTextures(){const u=this.painter.context,x=u.gl;for(const C in this.terrainTileForTile){const P=this.terrainTileForTile[C],R=P.dem;!R||P.demTexture&&!P.needsDEMTextureUpload||(u.activeTexture.set(x.TEXTURE1),TM(this.painter,P,R))}}_prepareDemTileUniforms(u,x,C,P){if(!x||x.demTexture==null)return!1;const R=u.tileID.canonical,F=Math.pow(2,x.tileID.canonical.z-R.z),U=P||"";return C[`u_dem_tl${U}`]=[R.x*F%1,R.y*F%1],C[`u_dem_scale${U}`]=F,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let u=0;const x=this._visibleDemTiles.reduce((C,P)=>{if(!P.dem)return C;const R=P.dem.tree.minimums[0];return R>0&&u++,C+R},0);return u?x/u:0}_updateEmptyDEMTexture(){const u=this.painter.context,x=u.gl;u.activeTexture.set(x.TEXTURE2);const C=this._getLoadedAreaMinimum(),P=new i.dL({width:1,height:1},new Float32Array([C]));this._emptyDEMTextureDirty=!1;let R=this._emptyDEMTexture;return R?R.update(P,{premultiply:!1}):R=this._emptyDEMTexture=new i.T(u,P,x.R32F,{premultiply:!1}),R}setupElevationDraw(u,x,C){const P=this.painter.context,R=P.gl,F={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};F.u_exaggeration=this.exaggeration();let U=null,K=null,te=1;if(C&&C.morphing&&this._useVertexMorphing){const fe=C.morphing.srcDemTile,Ne=C.morphing.dstDemTile;te=C.morphing.phase,fe&&Ne&&(this._prepareDemTileUniforms(u,fe,F,"_prev")&&(K=fe),this._prepareDemTileUniforms(u,Ne,F)&&(U=Ne))}const re=fe=>fe&&fe.demTexture&&this.painter.linearFloatFilteringSupported()?R.LINEAR:R.NEAREST;let pe=null;var me;if(this.enabled?K&&U?(pe=U.demTexture,P.activeTexture.set(R.TEXTURE4),K.demTexture.bind(re(K),R.CLAMP_TO_EDGE),F.u_dem_lerp=te):(U=this.terrainTileForTile[u.tileID.key],pe=this._prepareDemTileUniforms(u,U,F)?U.demTexture:this.emptyDEMTexture):pe=this.emptyDEMTexture,P.activeTexture.set(R.TEXTURE2),pe&&(F.u_dem_size=(me=pe).size[0]===1?1:me.size[0]-2,pe.bind(re(U),R.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(C&&C.useDepthForOcclusion,x,F),C&&C.useMeterToDem&&U){const fe=(1<{if(Le===rs)return;const ms=[oS[rs],"PROJECTION_GLOBE_VIEW"];nt&&ms.push("CUSTOM_ANTIALIASING");const Ds=te.isTileAffectedByFog(ts);Re=te.getOrCreateProgram("globeRaster",{defines:ms,overrideFog:Ds}),Le=rs},Mt=te.colorModeForRenderPass(),gt=new Cr(we.LEQUAL,Cr.ReadWrite,te.depthRangeFor3D);gf.update(fe);const jt=i.dF(Ze),ft=[i.aF(Ze.center.lng),i.aJ(Ze.center.lat)],ht=te.globeSharedBuffers,At=[Ze.width*i.o.devicePixelRatio,Ze.height*i.o.devicePixelRatio],Ut=Float32Array.from(Ze.globeMatrix),Bt={useDenormalizedUpVectorScale:!0};{const ts=te.transform,rs=lS(ts.zoom,re.exaggeration(),re.sourceCache._source.tileSize);Le=-1;const ms=we.TRIANGLES;for(const Ds of me){const Yt=pe.getTile(Ds),Pt=sn.disabled,is=re.prevTerrainTileForTile[Ds.key],es=re.terrainTileForTile[Ds.key];D_(is,es)&&gf.newMorphing(Ds.key,is,es,fe,250),G0(te,Yt.emissiveTexture),Ne.activeTexture.set(we.TEXTURE0),Yt.texture&&Yt.texture.bind(we.LINEAR,we.CLAMP_TO_EDGE);const ks=gf.getMorphValuesForProxy(Ds.key),Gs=ks?1:0;ks&&Object.assign(Bt,{morphing:{srcDemTile:ks.from,dstDemTile:ks.to,phase:i.dD(ks.phase)}});const dr=i.dG(Ds.canonical),qs=i.dH(dr.getCenter().lat),Os=i.dI(Ds.canonical,dr,qs,ts.worldSize/ts._pixelsPerMercatorPixel),wr=i.bk(i.dJ(Ds.canonical)),yr=te.emissiveMode==="mrt-fallback"?1:0,ir=iS(ts.expandedFarZProjMatrix,Ut,jt,wr,i.aj(ts.zoom),ft,ts.frustumCorners.TL,ts.frustumCorners.TR,ts.frustumCorners.BR,ts.frustumCorners.BL,ts.globeCenterInViewSpace,ts.globeRadius,At,rs,ts._farZ,yr,Os);if(Xe(Ds,Gs),Re&&(re.setupElevationDraw(Yt,Re,Bt),te.uploadCommonUniforms(Ne,Re,Ds.toUnwrapped()),ht)){const[hr,Fr,_n]=ht.getGridBuffers(qs,rs!==0);Re.draw(te,ms,gt,Pt,Mt,tn.backCCW,ir,"globe_raster",hr,Fr,_n)}}}if(ht&&(te.renderDefaultNorthPole||te.renderDefaultSouthPole)){const ts=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];nt&&ts.push("CUSTOM_ANTIALIASING"),Re=te.getOrCreateProgram("globeRaster",{defines:ts});for(const rs of me){const{x:ms,y:Ds,z:Yt}=rs.canonical,Pt=Ds===0,is=Ds===(1<hr.draw(te,we.TRIANGLES,gt,sn.disabled,Mt,tn.disabled,iS(Ze.expandedFarZProjMatrix,Os,Os,wr,0,ft,Ze.frustumCorners.TL,Ze.frustumCorners.TR,Ze.frustumCorners.BR,Ze.frustumCorners.BL,Ze.globeCenterInViewSpace,Ze.globeRadius,At,0,Ze._farZ,yr),"globe_pole_raster",Fr,Gs,dr);re.setupElevationDraw(qs,Re,Bt),te.uploadCommonUniforms(Ne,Re,rs.toUnwrapped()),Pt&&te.renderDefaultNorthPole&&ir(Re,es),is&&te.renderDefaultSouthPole&&(Os=i.cS(i.bC(),Os,[1,-1,1]),ir(Re,ks))}}}})(P,R,F,U,K);else{const te=P.context,re=te.gl;let pe,me;const fe=P.shadowRenderer,Ne=Rg(P,P.longestCutoffRange),we=Mt=>{if(me===Mt)return;const gt=[];gt.push(oS[Mt]),Ne.shouldRenderCutoff&>.push("RENDER_CUTOFF"),fe&&(gt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),fe.useNormalOffset&>.push("NORMAL_OFFSET")),pe=P.getOrCreateProgram("terrainRaster",{defines:gt}),me=Mt},Re=P.colorModeForRenderPass(),Le=new Cr(re.LEQUAL,Cr.ReadWrite,P.depthRangeFor3D);gf.update(K);const Ze=P.transform,nt=lS(Ze.zoom,R.exaggeration(),R.sourceCache._source.tileSize);let Xe=[0,0,0];if(fe){const Mt=P.style.directionalLight,gt=P.style.ambientLight;Mt&>&&(Xe=ff(P.style,Mt,gt))}{me=-1;const Mt=re.TRIANGLES,[gt,jt]=[R.gridIndexBuffer,R.gridSegments];for(const ft of U){const ht=F.getTile(ft),At=sn.disabled,Ut=R.prevTerrainTileForTile[ft.key],Bt=R.terrainTileForTile[ft.key];D_(Ut,Bt)&&gf.newMorphing(ft.key,Ut,Bt,K,250),G0(P,ht.emissiveTexture),te.activeTexture.set(re.TEXTURE0),ht.texture&&ht.texture.bind(re.LINEAR,re.CLAMP_TO_EDGE);const ts=gf.getMorphValuesForProxy(ft.key),rs=ts?1:0;let ms;ts&&(ms={morphing:{srcDemTile:ts.from,dstDemTile:ts.to,phase:i.dD(ts.phase)}});const Ds=P.emissiveMode==="mrt-fallback"?1:0,Yt=th(ft.projMatrix,FM(ft.canonical,Ze.renderWorldCopies)?nt/10:nt,Xe,Ds);if(we(rs),!pe)continue;R.setupElevationDraw(ht,pe,ms);const Pt=ft.toUnwrapped();fe&&fe.setupShadows(Pt,pe),P.uploadCommonUniforms(te,pe,Pt,null,Ne),pe.draw(P,Mt,Le,At,Re,tn.backCCW,Yt,"terrain_raster",R.gridBuffer,gt,jt)}}}}(x,this,this.proxySourceCache,u,this._updateTimestamp),this.renderingToTexture=!0,x.gpuTimingDeferredRenderEnd(),u.splice(0,u.length))}renderBatch(u){if(this._drapedRenderBatches.length===0)return u+1;this.renderingToTexture=!0;const x=this.painter,C=this.painter.context,P=this.proxySourceCache,R=this.proxiedCoords[P.id],F=this._drapedRenderBatches.shift(),U=x.style.order,K=[];this._updateFBOs(x.emissiveMode==="mrt-fallback");let te=0;for(const re of R){const pe=P.getTileByID(re.proxyTileKey),me=P.proxyCachedFBO[re.key]?P.proxyCachedFBO[re.key][u]:void 0,fe=me!==void 0?P.renderCache[me]:this.pool[te++],Ne=me!==void 0;if(pe.texture=fe.tex,pe.emissiveTexture=fe.emissiveTex,Ne&&!fe.dirty){K.push(pe.tileID);continue}C.bindFramebuffer.set(fe.fb.framebuffer);const we=C.gl;let Re;we.drawBuffers(x.emissiveMode==="mrt-fallback"?[we.COLOR_ATTACHMENT0,we.COLOR_ATTACHMENT1]:[we.COLOR_ATTACHMENT0]),this.renderedToTile=!1,fe.dirty&&(C.clear({color:i.ao.transparent,stencil:0}),fe.dirty=!1);for(let Le=F.start;Le<=F.end;++Le){const Ze=x.style._mergedLayers[U[Le]];if(Ze.isHidden(x.transform.zoom))continue;const nt=x.style.getLayerSourceCache(Ze),Xe=nt?this.proxyToSource[re.key][nt.id]:[re];if(!Xe)continue;const Mt=Xe;C.viewport.set([0,0,fe.fb.width,fe.fb.height]),Re!==(nt?nt.id:null)&&(this._setupStencil(fe,Xe,Ze,nt),Re=nt?nt.id:null),x.renderLayer(x,nt,Ze,Mt)}if(we.drawBuffers([we.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Le of this._pendingGroundEffectLayers){const Ze=x.style._mergedLayers[U[Le]];if(Ze.isHidden(x.transform.zoom))continue;const nt=x.style.getLayerSourceCache(Ze),Xe=nt?this.proxyToSource[re.key][nt.id]:[re];if(!Xe)continue;const Mt=Xe;C.viewport.set([0,0,fe.fb.width,fe.fb.height]),Re!==(nt?nt.id:null)&&(this._setupStencil(fe,Xe,Ze,nt),Re=nt?nt.id:null),x.renderLayer(x,nt,Ze,Mt)}this.renderedToTile?(fe.dirty=!0,K.push(pe.tileID)):Ne||--te,te===5&&(te=0,this.renderToBackBuffer(K))}return this.renderToBackBuffer(K),this.renderingToTexture=!1,C.bindFramebuffer.set(null),C.viewport.set([0,0,x.width,x.height]),F.end+1}postRender(){}isLayerOrderingCorrect(u){const x=u.order.length;let C=-1,P=x;for(let R=0;RC}getMinElevationBelowMSL(){let u=0;return this._visibleDemTiles.filter(x=>x.dem).forEach(x=>{u=Math.min(u,x.dem.tree.minimums[0])}),u===0?u:(u-30)*this._exaggeration}raycast(u,x,C){if(!this._visibleDemTiles)return null;const P=this._visibleDemTiles.filter(R=>R.dem).map(R=>{const F=R.tileID,U=1<(R.t!==null?R.t:Number.MAX_VALUE)-(F.t!==null?F.t:Number.MAX_VALUE));for(const R of P){if(R.t==null)return null;const F=R.tile.dem.tree.raycast(R.minx,R.miny,R.maxx,R.maxy,u,x,C);if(F!=null)return F}return null}_createFBO(){const u=this.painter.context,x=u.gl,C=this.drapeBufferSize;u.activeTexture.set(x.TEXTURE0);const P=new i.T(u,{width:C[0],height:C[1],data:null},x.RGBA8);P.bind(x.LINEAR,x.CLAMP_TO_EDGE);const R=u.createFramebuffer(C[0],C[1],1,null);let F;return R.colorAttachment0.set(P.texture),this._emissiveTexture&&(F=new i.T(u,{width:C[0],height:C[1],data:null},x.R8),F.bind(x.LINEAR,x.CLAMP_TO_EDGE),R.createColorAttachment(u,1),R.colorAttachment1.set(F.texture)),R.depthAttachment=new PL(u,R.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=u.createRenderbuffer(u.gl.DEPTH_STENCIL,C[0],C[1]),this._stencilRef=0,R.depthAttachment.set(this._sharedDepthStencil),u.clear({stencil:0})):R.depthAttachment.set(this._sharedDepthStencil),u.extTextureFilterAnisotropic&&x.texParameterf(x.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax),{fb:R,tex:P,emissiveTex:F,dirty:!1}}_updateFBOs(u){if(this._emissiveTexture!==u){for(const x of this.pool)this._updateFBO(x,u);for(const x of this.proxySourceCache.renderCache)this._updateFBO(x,u);this._emissiveTexture=u}}_updateFBO(u,x){const C=u.fb,P=this.painter.context,R=P.gl,F=this.drapeBufferSize;if(x){const U=new i.T(P,{width:F[0],height:F[1],data:null},R.R8);U.bind(R.LINEAR,R.CLAMP_TO_EDGE),u.emissiveTex=U,C.createColorAttachment(P,1),C.colorAttachment1.set(U.texture)}else u.emissiveTex=void 0,C.removeColorAttachment(P,1);u.dirty=!0}_initFBOPool(){for(;this.pool.length{const x=this._style._mergedLayers[u],C=x.isHidden(this.painter.transform.zoom);return x.type==="hillshade"||x.type==="custom"?!C&&x.shouldRedrape():!C&&x.hasTransition()})}_clearLineLayersFromRenderCache(){let u=!1;for(const C of this._style.getSources())if(C instanceof dp){u=!0;break}if(!u)return;const x={};for(let C=0;CK>U.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=C}_setupRenderCache(u){const x=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,x.renderCache.length>x.renderCachePool.length){const F=Object.values(x.proxyCachedFBO);x.proxyCachedFBO={};for(let U=0;U=0;F--){const U=C[F];if(x.getTileByID(U.key),x.proxyCachedFBO[U.key]!==void 0){const K=u[U.key],te=this.proxyToSource[U.key];let re=0;for(const pe in te){const me=te[pe],fe=K[pe];if(!fe||fe.length!==me.length||me.some((Ne,we)=>Ne!==fe[we]||P[pe]&&P[pe].hasOwnProperty(Ne.key))){re=-1;break}++re}for(const pe in x.proxyCachedFBO[U.key])x.renderCache[x.proxyCachedFBO[U.key][pe]].dirty=re<0||re!==Object.values(K).length}}const R=[...this._drapedRenderBatches];R.sort((F,U)=>U.end-U.start-(F.end-F.start));for(const F of R)for(const U of C){if(x.proxyCachedFBO[U.key])continue;let K=x.renderCachePool.pop();K===void 0&&x.renderCache.length<50&&(K=x.renderCache.length,x.renderCache.push(this._createFBO())),K!==void 0&&(x.proxyCachedFBO[U.key]={},x.proxyCachedFBO[U.key][F.start]=K,x.renderCache[K].dirty=!0)}this._tilesDirty={}}_setupStencil(u,x,C,P){if(!P||!this._sourceTilesOverlap[P.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const R=this.painter.context,F=R.gl;if(x.length<=1)return void(this._overlapStencilType=!1);let U;if(C.isTileClipped())U=x.length,this._overlapStencilMode.test={func:F.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(x[0].overscaledZ>x[x.length-1].overscaledZ))return void(this._overlapStencilType=!1);U=1,this._overlapStencilMode.test={func:F.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+U>255&&(R.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=U,this._overlapStencilMode.ref=this._stencilRef,C.isTileClipped()&&this._renderTileClippingMasks(x,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(u){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[u.key]),this._overlapStencilMode):sn.disabled}_renderTileClippingMasks(u,x){const C=this.painter,P=this.painter.context,R=P.gl;C._tileClippingMaskIDs={},P.setColorMode(Cn.disabled),P.setDepthMode(Cr.disabled);const F=C.getOrCreateProgram("clippingMask");for(const U of u){const K=C._tileClippingMaskIDs[U.key]=--x;F.draw(C,R.TRIANGLES,Cr.disabled,new sn({func:R.ALWAYS,mask:0},K,255,R.KEEP,R.KEEP,R.REPLACE),Cn.disabled,tn.disabled,O_(U.projMatrix),"$clipping",C.tileExtentBuffer,C.quadTriangleIndexBuffer,C.tileExtentSegments)}}pointCoordinate(u){const x=this.painter.transform;if(u.x<0||u.x>x.width||u.y<0||u.y>x.height)return null;const C=[u.x,u.y,1,1];i.aC(C,C,x.pixelMatrixInverse),i.cK(C,C,1/C[3]),C[0]/=x.worldSize,C[1]/=x.worldSize;const P=x._camera.position,R=i.cf(1,x.center.lat),F=[P[0],P[1],P[2]/R,0],U=i.da([],C.slice(0,3),F);i.aw(U,U);const K=this.raycast(F,U,this._exaggeration);return K!==null&&K?(i.bH(F,F,U,K),F[3]=F[2],F[2]*=R,F):null}_setupProxiedCoordsForOrtho(u,x,C){if(u.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(u,x,C);this._findCoveringTileCache[u.id]=this._findCoveringTileCache[u.id]||{};const P=this.proxiedCoords[u.id]=[],R=this.proxyCoords;for(let K=0;Kre.overscaledZ-te.overscaledZ)}_setupProxiedCoordsForImageSource(u,x,C){if(!u.getSource().loaded())return;const P=this.proxiedCoords[u.id]=[],R=this.proxyCoords,F=u.getSource(),U=F.tileID;if(!U)return;const K=new i.P(U.x,U.y)._div(1<(pe.min.x=Math.min(pe.min.x,me.x-K.x),pe.min.y=Math.min(pe.min.y,me.y-K.y),pe.max.x=Math.max(pe.max.x,me.x-K.x),pe.max.y=Math.max(pe.max.y,me.y-K.y),pe),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),re=(pe,me)=>{const fe=pe.wrap+pe.canonical.x/(1<Re+te.max.x||Ne+weLe+te.max.y};for(let pe=0;peF.key===x.tileID.key);if(R)return R}if(x.tileID.key!==u.key){const R=u.canonical.z-x.tileID.canonical.z;let F,U,K;P=i.bC();const te=x.tileID.wrap-u.wrap<0?(F=i.al>>R,U=F*((x.tileID.canonical.x<=pe){const me=u.canonical.z-pe;x.getSource().reparseOverscaled?(U=Math.max(u.canonical.z+2,x.transform.tileZoom),F=new i.aQ(U,u.wrap,pe,u.canonical.x>>me,u.canonical.y>>me)):me!==0&&(U=pe,F=new i.aQ(U,u.wrap,pe,u.canonical.x>>me,u.canonical.y>>me))}F.key!==u.key&&(te.push(F.key),C=x.getTile(F))}const re=pe=>{te.forEach(me=>{P[me]=pe}),te.length=0};for(U-=1;U>=K&&(!C||!C.hasData());U--){C&&re(C.tileID.key);const pe=F.calculateScaledKey(U);if(C=x.getTileByID(pe),C&&C.hasData())break;const me=P[pe];if(me===null)break;me===void 0?te.push(pe):C=x.getTileByID(me)}return re(C?C.tileID.key:null),C&&C.hasData()?C:null}findDEMTileFor(u){return this.enabled?this._findTileCoveringTileID(u,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(u,x){let C=this._tilesDirty[u];C||(C=this._tilesDirty[u]={}),C[x.key]=!0}}function K0(N,u,x){const C=function(U,K,te){const re=i.bJ(K,U),pe=i.bJ(te,[.2126,.7152,.0722]),me=(Ne,we,Re)=>(1-Re)*Ne+Re*we,fe=me(1-.3*Math.min(pe,1),1,Math.min(re+1,1));return me(.92,1,Math.asin(i.aA(K[2],-1,1))/Math.PI+.5)*fe}(N,[0,0,1],u),P=[0,0,0];i.c5(P,x.slice(0,3),C);const R=[0,0,0];i.c5(R,u.slice(0,3),N[2]);const F=[0,0,0];return i.d8(F,P,R),i.db(F)}const ace=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],ice=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class LL{static cacheKey(u,x,C,P){const R=[x];P&&R.push(P.cacheKey);for(const F of C)u.usedDefines.has(F)&&R.push(F);return R.join("/")}constructor(u,x,C,P,R,F){const U=u.gl;this.program=U.createProgram(),this.configuration=P,this.name=x,this.fixedDefines=[...F];const K=`#version 300 es ${(P?P.defines():[]).concat(F.map(we=>`#define ${we}`)).join(` `)}`,te=[K,Yle];for(const we of C.fragmentIncludes)te.push($g[we]);te.push(C.fragmentSource);const re=te.join(` `),pe=[K,kL];for(const we of C.vertexIncludes)pe.push($g[we]);this.forceManualRenderingForInstanceIDShaders=u.forceManualRenderingForInstanceIDShaders&&C.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&pe.push("uniform int u_instanceID;"),pe.push(C.vertexSource);let me=pe.join(` `);this.forceManualRenderingForInstanceIDShaders&&(me=me.replaceAll("gl_InstanceID","u_instanceID"));const fe=U.createShader(U.FRAGMENT_SHADER);if(U.isContextLost())return void(this.failedToCreate=!0);U.shaderSource(fe,re),U.compileShader(fe),U.attachShader(this.program,fe);const Ne=U.createShader(U.VERTEX_SHADER);U.isContextLost()?this.failedToCreate=!0:(U.shaderSource(Ne,me),U.compileShader(Ne),U.attachShader(this.program,Ne),this.attributes={},U.linkProgram(this.program),U.deleteShader(Ne),U.deleteShader(fe),this.fixedUniforms=R(u),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=P?P.getUniforms(u):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(we=>({u_instanceID:new i.ch(we)}))(u)),(F.includes("TERRAIN")||x.includes("symbol")||x.includes("circle"))&&(this.terrainUniforms=(we=>({u_dem:new i.ch(we),u_dem_prev:new i.ch(we),u_dem_tl:new i.ck(we),u_dem_scale:new i.cj(we),u_dem_tl_prev:new i.ck(we),u_dem_scale_prev:new i.cj(we),u_dem_size:new i.cj(we),u_dem_lerp:new i.cj(we),u_exaggeration:new i.cj(we),u_depth:new i.ch(we),u_depth_size_inv:new i.ck(we),u_depth_range_unpack:new i.ck(we),u_occluder_half_size:new i.cj(we),u_occlusion_depth_offset:new i.cj(we),u_meter_to_dem:new i.cj(we),u_label_plane_matrix_inv:new i.cl(we)}))(u)),F.includes("GLOBE")&&(this.globeUniforms=(we=>({u_tile_tl_up:new i.ci(we),u_tile_tr_up:new i.ci(we),u_tile_br_up:new i.ci(we),u_tile_bl_up:new i.ci(we),u_tile_up_scale:new i.cj(we)}))(u)),F.includes("FOG")&&(this.fogUniforms=(we=>({u_fog_matrix:new i.cl(we),u_fog_range:new i.ck(we),u_fog_color:new i.d3(we),u_fog_horizon_blend:new i.cj(we),u_fog_vertical_limit:new i.ck(we),u_fog_temporal_offset:new i.cj(we),u_frustum_tl:new i.ci(we),u_frustum_tr:new i.ci(we),u_frustum_br:new i.ci(we),u_frustum_bl:new i.ci(we),u_globe_pos:new i.ci(we),u_globe_radius:new i.cj(we),u_globe_transition:new i.cj(we),u_is_globe:new i.ch(we),u_viewport:new i.ck(we)}))(u)),F.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(we=>({u_cutoff_params:new i.d3(we)}))(u)),F.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(we=>({u_lighting_ambient_color:new i.ci(we),u_lighting_directional_dir:new i.ci(we),u_lighting_directional_color:new i.ci(we),u_ground_radiance:new i.ci(we)}))(u)),F.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(we=>({u_light_matrix_0:new i.cl(we),u_light_matrix_1:new i.cl(we),u_fade_range:new i.ck(we),u_shadow_normal_offset:new i.ci(we),u_shadow_intensity:new i.cj(we),u_shadow_texel_size:new i.cj(we),u_shadow_map_resolution:new i.cj(we),u_shadow_direction:new i.ci(we),u_shadow_bias:new i.ci(we),u_shadowmap_0:new i.ch(we),u_shadowmap_1:new i.ch(we)}))(u)))}getAttributeLocation(u,x){let C=this.attributes[x];return C===void 0&&(C=this.attributes[x]=u.getAttribLocation(this.program,x)),C}setTerrainUniformValues(u,x){if(!this.terrainUniforms)return;const C=this.terrainUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)C[P]&&C[P].set(this.program,P,x[P])}}setGlobeUniformValues(u,x){if(!this.globeUniforms)return;const C=this.globeUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)C[P]&&C[P].set(this.program,P,x[P])}}setFogUniformValues(u,x){if(!this.fogUniforms)return;const C=this.fogUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)C[P].set(this.program,P,x[P])}}setCutoffUniformValues(u,x){if(!this.cutoffUniforms)return;const C=this.cutoffUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)C[P].set(this.program,P,x[P])}}setLightsUniformValues(u,x){if(!this.lightsUniforms)return;const C=this.lightsUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)C[P].set(this.program,P,x[P])}}setShadowUniformValues(u,x){if(this.failedToCreate||!this.shadowUniforms)return;const C=this.shadowUniforms;u.program.set(this.program);for(const P in x)C[P].set(this.program,P,x[P])}_drawDebugWireframe(u,x,C,P,R,F,U,K,te,re){const pe=u.options.wireframe;if(pe.terrain===!1&&pe.layers2D===!1&&pe.layers3D===!1)return;const me=u.context;if(!(!(!pe.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!pe.layers2D||u._terrain&&u._terrain.renderingToTexture||!ace.includes(this.name))||!(!pe.layers3D||!ice.includes(this.name))))return;const fe=me.gl,Ne=u.wireframeDebugCache.getLinesFromTrianglesBuffer(u.frameCounter,R,me);if(!Ne)return;const we=[...this.fixedDefines,"DEBUG_WIREFRAME"],Re=u.getOrCreateProgram(this.name,{config:this.configuration,defines:we});me.program.set(Re.program);const Le=(Xe,Mt,gt)=>{if(Mt[Xe]&>[Xe])for(const jt in Mt[Xe])gt[Xe][jt]&>[Xe][jt].set(gt.program,jt,Mt[Xe][jt].current)};te&&te.setUniforms(Re.program,me,Re.binderUniforms,U,{zoom:K}),Le("fixedUniforms",this,Re),Le("terrainUniforms",this,Re),Le("globeUniforms",this,Re),Le("fogUniforms",this,Re),Le("lightsUniforms",this,Re),Le("shadowUniforms",this,Re),Ne.bind(),me.setColorMode(new Cn([fe.ONE,fe.ONE_MINUS_SRC_ALPHA,fe.ZERO,fe.ONE],i.ao.transparent,[!0,!0,!0,!1])),me.setDepthMode(new Cr(x.func===fe.LESS?fe.LEQUAL:x.func,Cr.ReadOnly,x.range)),me.setStencilMode(sn.disabled);const Ze=3*F.primitiveLength*2,nt=3*F.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const Xe=re||1;for(let Mt=0;Mt1?fe.drawElementsInstanced(fe.LINES,Ze,fe.UNSIGNED_SHORT,nt,re):fe.drawElements(fe.LINES,Ze,fe.UNSIGNED_SHORT,nt);R.bind(),me.program.set(this.program),me.setDepthMode(x),me.setStencilMode(C),me.setColorMode(P)}checkUniforms(u,x,C){if(this.fixedDefines.includes(x)){for(const P of Object.keys(C))if(!C[P].initialized)throw new Error(`Program '${this.name}', from draw '${u}': uniform ${P} not set but required by ${x} being defined`)}}draw(u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re){const Le=u.context,Ze=Le.gl;if(this.failedToCreate)return;Le.program.set(this.program),Le.setDepthMode(C),Le.setStencilMode(P),Le.setColorMode(R),Le.setCullFace(F);for(const[ft,ht]of this.fixedUniformsEntries)ht.set(this.program,ft,U[ft]);Ne&&Ne.setUniforms(this.program,Le,this.binderUniforms,me,{zoom:fe});const nt={[Ze.POINTS]:1,[Ze.LINES]:2,[Ze.TRIANGLES]:3,[Ze.LINE_STRIP]:1}[x];this.checkUniforms(K,"RENDER_SHADOWS",this.shadowUniforms);const Xe=we||[],Mt=Ne?Ne.getPaintVertexBuffers():[],gt=x===Ze.TRIANGLES&&re,jt=Re&&Re>0?1:void 0;for(const ft of pe.get()){const ht=ft.vaos||(ft.vaos={});if((ht[K]||(ht[K]=new Xle)).bind(Le,this,te,Mt,re,ft.vertexOffset,Xe,jt),this.forceManualRenderingForInstanceIDShaders){const At=Re||1;for(let Ut=0;Ut1?Ze.drawElementsInstanced(x,ft.primitiveLength*nt,Ze.UNSIGNED_SHORT,ft.primitiveOffset*nt*2,Re):re?Ze.drawElements(x,ft.primitiveLength*nt,Ze.UNSIGNED_SHORT,ft.primitiveOffset*nt*2):Ze.drawArrays(x,ft.vertexOffset,ft.vertexLength);gt&&this._drawDebugWireframe(u,C,P,R,re,ft,me,fe,Ne,Re)}}}function DL(N,u,x=0){const C=Math.pow(2,u.tileID.overscaledZ),P=u.tileSize*Math.pow(2,N.transform.tileZoom)/C,R=P*(u.tileID.canonical.x+u.tileID.wrap*C),F=P*u.tileID.canonical.y;return{u_image:0,u_texsize:u.imageAtlasTexture?u.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/i.ay(u,1,N.transform.tileZoom),u_pixel_coord_upper:[R>>16,F>>16],u_pixel_coord_lower:[65535&R,65535&F],u_pattern_transition:x}}const dS={terrain:0,flat:1},oce=i.bC(),uS=(N,u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re,Le)=>{const Ze=u.style.light,nt=Ze.properties.get("position"),Xe=[nt.x,nt.y,nt.z],Mt=i.dO();Ze.properties.get("anchor")==="viewport"&&(i.dP(Mt,-u.transform.angle),i.dQ(Xe,Xe,Mt));const gt=Ze.properties.get("color").toPremultipliedRenderColor(null),jt=u.transform,ft={u_matrix:N,u_lightpos:Xe,u_lightintensity:Ze.properties.get("intensity"),u_lightcolor:[gt.r,gt.g,gt.b],u_vertical_gradient:+x,u_opacity:C,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:oce,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:dS[te],u_base_type:dS[re],u_ao:P,u_edge_radius:R,u_width_scale:F,u_flood_light_color:Ne,u_vertical_scale:we,u_flood_light_intensity:Re,u_ground_shadow_factor:Le};return jt.projection.name==="globe"&&(ft.u_tile_id=[U.canonical.x,U.canonical.y,1<({u_matrix:N,u_edge_radius:u,u_width_scale:x,u_vertical_scale:C,u_height_type:dS[P],u_base_type:dS[R]}),OL=(N,u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re,Le)=>{const Ze=uS(N,u,x,C,P,R,F,U,te,re,pe,me,fe,Ne,we,Re,1,[0,0,0]),nt={u_height_factor:-Math.pow(2,U.overscaledZ)/K.tileSize/8};return Object.assign(Ze,DL(u,K,Le),nt)},Z0=(N,u,x,C,P,R,F,U,K,te,re)=>({u_matrix:u,u_opacity:x,u_ao_pass:C?1:0,u_meter_to_tile:P,u_ao:R,u_flood_light_intensity:F,u_flood_light_color:U,u_attenuation:K,u_edge_radius:te,u_fb:0,u_fb_size:re,u_dynamic_offset:1}),qM=(N,u,x)=>({u_matrix:N,u_emissive_strength:u,u_ground_shadow_factor:x}),VM=(N,u,x,C,P,R=0)=>Object.assign(qM(N,u,P),DL(x,C,R)),RL=(N,u,x,C)=>({u_matrix:N,u_world:x,u_emissive_strength:u,u_ground_shadow_factor:C}),HM=(N,u,x,C,P,R,F=0)=>Object.assign(VM(N,u,x,C,R,F),{u_world:P}),qg=(N,u)=>({u_matrix:N,u_ground_shadow_factor:u}),ay=(N,u,x,C,P)=>({u_matrix:N,u_camera_pos:[u[0],u[1],u[2]],u_depth_bias:x,u_height_scale:C,u_reset_depth:P}),hS=(N,u,x,C,P,R,F,U,K)=>({u_matrix:N,u_normal_matrix:u,u_opacity:x,u_faux_facade_ao_intensity:C,u_camera_pos:P,u_tile_to_meter:R,u_facade_emissive_chance:F,u_flood_light_color:U,u_flood_light_intensity:K}),FL=N=>({u_matrix:N}),Vg=N=>({u_matrix:N}),WM=(N,u,x,C,P,R,F,U)=>{const K=i.al/R.tileSize;return{u_matrix:N,u_inv_rot_matrix:u,u_camera_to_center_distance:x.getCameraToCenterDistance(U),u_extrude_scale:[x.pixelsToGLUnits[0]/K,x.pixelsToGLUnits[1]/K],u_zoom_transition:C,u_tile_id:F,u_merc_center:P}},F_=(N,u,x=1)=>({u_matrix:N,u_color:u,u_overlay:0,u_overlay_scale:x}),zL=i.bC(),BL=(N,u,x,C,P,R,F)=>{const U=N.transform,K=U.projection.name==="globe",te=K?i.dR(U.zoom,u.canonical)*U._pixelsPerMercatorPixel:i.ay(x,1,R),re={u_matrix:u.projMatrix,u_extrude_scale:te,u_intensity:F,u_inv_rot_matrix:zL,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(K){re.u_inv_rot_matrix=C,re.u_merc_center=P,re.u_tile_id=[u.canonical.x,u.canonical.y,1<({u_matrix:N,u_normalize_matrix:u,u_globe_matrix:x,u_merc_matrix:C,u_grid_matrix:P,u_tl_parent:R,u_scale_parent:te,u_fade_t:re.mix,u_opacity:re.opacity*pe.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:pe.paint.get("raster-brightness-min"),u_brightness_high:pe.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(pe.paint.get("raster-saturation")),u_contrast_factor:i.dS(pe.paint.get("raster-contrast")),u_spin_weights:UL(pe.paint.get("raster-hue-rotate")),u_perspective_transform:me,u_raster_elevation:fe,u_zoom_transition:F,u_merc_center:U,u_cutoff_params:K,u_colorization_mix:mS(i.dU,we,Le),u_colorization_offset:pS(i.dU,Re,Le),u_color_ramp:Ne,u_texture_offset:[nt/(Ze+2*nt),Ze/(Ze+2*nt)],u_texture_res:[Ze+2*nt,Ze+2*nt],u_emissive_strength:Xe});function UL(N){N*=Math.PI/180;const u=Math.sin(N),x=Math.cos(N);return[(2*x+1)/3,(-Math.sqrt(3)*u-x+1)/3,(Math.sqrt(3)*u-x+1)/3]}const xp=.05,lce=(N,u,x,C,P,R,F,U,K,te,re,pe)=>({u_matrix:N,u_normalize_matrix:u,u_globe_matrix:x,u_merc_matrix:C,u_grid_matrix:P,u_tl_parent:R,u_scale_parent:te,u_fade_t:re.mix,u_opacity:re.opacity,u_image0:0,u_image1:1,u_raster_elevation:pe,u_zoom_transition:F,u_merc_center:U,u_cutoff_params:K}),cce=(N,u,x,C,P,R,F,U,K,te)=>({u_particle_texture:N,u_particle_texture_side_len:u,u_tile_offset:x,u_velocity:C,u_color_ramp:R,u_velocity_res:P,u_max_speed:F,u_uv_offset:U,u_data_scale:[255*K[0],255*K[1]],u_data_offset:te,u_particle_pos_scale:1.1,u_particle_pos_offset:[xp,xp]}),qL=(N,u,x,C,P,R,F,U,K,te)=>({u_particle_texture:N,u_particle_texture_side_len:u,u_velocity:x,u_velocity_res:C,u_max_speed:P,u_speed_factor:R,u_reset_rate:F,u_rand_seed:Math.random(),u_uv_offset:U,u_data_scale:[255*K[0],255*K[1]],u_data_offset:te,u_particle_pos_scale:1.1,u_particle_pos_offset:[xp,xp]}),VL=i.bC(),fS=(N,u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re,Le,Ze,nt,Xe,Mt,gt,jt)=>{const ft=P.transform,ht={u_is_size_zoom_constant:+(N==="constant"||N==="source"),u_is_size_feature_constant:+(N==="constant"||N==="camera"),u_size_t:u?u.uSizeT:0,u_size:u?u.uSize:0,u_camera_to_center_distance:ft.getCameraToCenterDistance(Ze),u_rotate_symbol:+x,u_aspect_ratio:ft.width/ft.height,u_fade_change:P.options.fadeDuration?P.symbolFadeChange:1,u_matrix:R,u_label_plane_matrix:F,u_coord_matrix:U,u_is_text:+te,u_elevation_from_sea:K?1:0,u_pitch_with_map:+C,u_texsize:re,u_texsize_icon:pe,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:VL,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:VL,u_up_vector:[0,-1,0],u_color_adj_mat:Mt,u_icon_transition:gt||0,u_gamma_scale:C?P.transform.getCameraToCenterDistance(Ze)*Math.cos(P.terrain?0:P.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:jt||1,u_ground_shadow_factor:nt,u_inv_matrix:i.bl(i.bC(),F),u_normal_scale:Xe,u_lutTexture:Xl.LUT};return Ze.name==="globe"&&(ht.u_tile_id=[fe.canonical.x,fe.canonical.y,1<({u_matrix:N,u_emissive_strength:u,u_opacity:x,u_color:C}),Hg=(N,u,x,C,P,R,F,U,K)=>Object.assign(function(te,re,pe,me,fe,Ne){const{width:we,height:Re}=me.imageManager.getPixelSize(re),Le=Math.pow(2,Ne.tileID.overscaledZ),Ze=Ne.tileSize*Math.pow(2,me.transform.tileZoom)/Le,nt=Ze*(Ne.tileID.canonical.x+Ne.tileID.wrap*Le),Xe=Ze*Ne.tileID.canonical.y;return{u_image:0,u_pattern_tl:pe.tl,u_pattern_br:pe.br,u_texsize:[we,Re],u_pattern_size:pe.displaySize,u_pattern_units_to_pixels:fe?[me.transform.width,-1*me.transform.height]:[1/i.ay(Ne,1,me.transform.tileZoom),1/i.ay(Ne,1,me.transform.tileZoom)],u_pixel_coord_upper:[nt>>16,Xe>>16],u_pixel_coord_lower:[65535&nt,65535&Xe]}}(0,R,F,C,U,K),{u_matrix:N,u_emissive_strength:u,u_opacity:x}),Y0=new Float32Array(i.bA([])),iy=(N,u,x,C,P,R,F,U,K,te,re,pe,me,fe=[0,0,0],Ne,we,Re)=>{const Le=P.style.light,Ze=Le.properties.get("position"),nt=[-Ze.x,-Ze.y,Ze.z],Xe=i.dO();Le.properties.get("anchor")==="viewport"&&(i.dP(Xe,-P.transform.angle),i.dQ(nt,nt,Xe));const Mt=re.alphaMode==="MASK",gt=Le.properties.get("color").toNonPremultipliedRenderColor(null),jt=me.paint.get("model-ambient-occlusion-intensity"),ft=me.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return ft.a=me.paint.get("model-color-mix-intensity").constantOr(0),Re&&(ft.r=Re[0],ft.g=Re[1],ft.b=Re[2],ft.a=Re[3]),we&&(ft.r=we.color.r,ft.g=we.color.g,ft.b=we.color.b,ft.a=we.colorMix,pe=we.emissionStrength,R*=we.opacity),{u_matrix:N,u_lighting_matrix:u,u_normal_matrix:x,u_node_matrix:C||Y0,u_lightpos:nt,u_lightintensity:Le.properties.get("intensity"),u_lightcolor:[gt.r,gt.g,gt.b],u_camera_pos:fe,u_opacity:R,u_baseTextureIsAlpha:0,u_alphaMask:+Mt,u_alphaCutoff:re.alphaCutoff,u_baseColorFactor:F.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:U.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:K,u_roughnessFactor:te,u_baseColorTexture:Xl.BaseColor,u_metallicRoughnessTexture:Xl.MetallicRoughness,u_normalTexture:Xl.Normal,u_occlusionTexture:Xl.Occlusion,u_emissionTexture:Xl.Emission,u_lutTexture:Xl.LUT,u_color_mix:ft.toArray01(),u_aoIntensity:jt,u_emissive_strength:pe,u_occlusionTextureTransform:Ne||[0,0,0,0]}},GM=(N,u=Y0,x=Y0)=>({u_matrix:N,u_instance:u,u_node_matrix:x}),gS={fillExtrusion:N=>({u_matrix:new i.cl(N),u_lightpos:new i.ci(N),u_lightintensity:new i.cj(N),u_lightcolor:new i.ci(N),u_vertical_gradient:new i.cj(N),u_opacity:new i.cj(N),u_edge_radius:new i.cj(N),u_width_scale:new i.cj(N),u_ao:new i.ck(N),u_height_type:new i.ch(N),u_base_type:new i.ch(N),u_tile_id:new i.ci(N),u_zoom_transition:new i.cj(N),u_inv_rot_matrix:new i.cl(N),u_merc_center:new i.ck(N),u_up_dir:new i.ci(N),u_height_lift:new i.cj(N),u_flood_light_color:new i.ci(N),u_vertical_scale:new i.cj(N),u_flood_light_intensity:new i.cj(N),u_ground_shadow_factor:new i.ci(N)}),fillExtrusionDepth:N=>({u_matrix:new i.cl(N),u_edge_radius:new i.cj(N),u_width_scale:new i.cj(N),u_vertical_scale:new i.cj(N),u_height_type:new i.ch(N),u_base_type:new i.ch(N)}),fillExtrusionPattern:N=>({u_matrix:new i.cl(N),u_lightpos:new i.ci(N),u_lightintensity:new i.cj(N),u_lightcolor:new i.ci(N),u_vertical_gradient:new i.cj(N),u_height_factor:new i.cj(N),u_edge_radius:new i.cj(N),u_width_scale:new i.cj(N),u_ao:new i.ck(N),u_height_type:new i.ch(N),u_base_type:new i.ch(N),u_tile_id:new i.ci(N),u_zoom_transition:new i.cj(N),u_inv_rot_matrix:new i.cl(N),u_merc_center:new i.ck(N),u_up_dir:new i.ci(N),u_height_lift:new i.cj(N),u_image:new i.ch(N),u_texsize:new i.ck(N),u_pixel_coord_upper:new i.ck(N),u_pixel_coord_lower:new i.ck(N),u_tile_units_to_pixels:new i.cj(N),u_opacity:new i.cj(N),u_pattern_transition:new i.cj(N)}),fillExtrusionGroundEffect:N=>({u_matrix:new i.cl(N),u_opacity:new i.cj(N),u_ao_pass:new i.cj(N),u_meter_to_tile:new i.cj(N),u_ao:new i.ck(N),u_flood_light_intensity:new i.cj(N),u_flood_light_color:new i.ci(N),u_attenuation:new i.cj(N),u_edge_radius:new i.cj(N),u_fb:new i.ch(N),u_fb_size:new i.cj(N),u_dynamic_offset:new i.cj(N)}),fill:N=>({u_matrix:new i.cl(N),u_emissive_strength:new i.cj(N),u_ground_shadow_factor:new i.ci(N)}),fillPattern:N=>({u_matrix:new i.cl(N),u_emissive_strength:new i.cj(N),u_image:new i.ch(N),u_texsize:new i.ck(N),u_pixel_coord_upper:new i.ck(N),u_pixel_coord_lower:new i.ck(N),u_tile_units_to_pixels:new i.cj(N),u_ground_shadow_factor:new i.ci(N),u_pattern_transition:new i.cj(N)}),fillOutline:N=>({u_matrix:new i.cl(N),u_emissive_strength:new i.cj(N),u_world:new i.ck(N),u_ground_shadow_factor:new i.ci(N)}),fillOutlinePattern:N=>({u_matrix:new i.cl(N),u_emissive_strength:new i.cj(N),u_world:new i.ck(N),u_image:new i.ch(N),u_texsize:new i.ck(N),u_pixel_coord_upper:new i.ck(N),u_pixel_coord_lower:new i.ck(N),u_tile_units_to_pixels:new i.cj(N),u_ground_shadow_factor:new i.ci(N),u_pattern_transition:new i.cj(N)}),building:N=>({u_matrix:new i.cl(N),u_normal_matrix:new i.cl(N),u_opacity:new i.cj(N),u_faux_facade_ao_intensity:new i.cj(N),u_camera_pos:new i.ci(N),u_tile_to_meter:new i.cj(N),u_facade_emissive_chance:new i.cj(N),u_flood_light_color:new i.ci(N),u_flood_light_intensity:new i.cj(N)}),buildingBloom:N=>({u_matrix:new i.cl(N)}),buildingDepth:N=>({u_matrix:new i.cl(N)}),elevatedStructuresDepth:N=>({u_matrix:new i.cl(N),u_depth_bias:new i.cj(N)}),elevatedStructures:N=>({u_matrix:new i.cl(N),u_ground_shadow_factor:new i.ci(N)}),elevatedStructuresDepthReconstruct:N=>({u_matrix:new i.cl(N),u_camera_pos:new i.ci(N),u_depth_bias:new i.cj(N),u_height_scale:new i.cj(N),u_reset_depth:new i.cj(N)}),circle:i.dY,collisionBox:N=>({u_matrix:new i.cl(N),u_inv_rot_matrix:new i.cl(N),u_camera_to_center_distance:new i.cj(N),u_extrude_scale:new i.ck(N),u_zoom_transition:new i.cj(N),u_merc_center:new i.ck(N),u_tile_id:new i.ci(N)}),collisionCircle:N=>({u_matrix:new i.cl(N),u_inv_matrix:new i.cl(N),u_camera_to_center_distance:new i.cj(N),u_viewport_size:new i.ck(N)}),debug:N=>({u_color:new i.dB(N),u_matrix:new i.cl(N),u_overlay:new i.ch(N),u_overlay_scale:new i.cj(N)}),clippingMask:N=>({u_matrix:new i.cl(N)}),heatmap:N=>({u_extrude_scale:new i.cj(N),u_intensity:new i.cj(N),u_matrix:new i.cl(N),u_inv_rot_matrix:new i.cl(N),u_merc_center:new i.ck(N),u_tile_id:new i.ci(N),u_zoom_transition:new i.cj(N),u_up_dir:new i.ci(N)}),heatmapTexture:N=>({u_image:new i.ch(N),u_color_ramp:new i.ch(N),u_opacity:new i.cj(N)}),hillshade:N=>({u_matrix:new i.cl(N),u_image:new i.ch(N),u_latrange:new i.ck(N),u_light:new i.ck(N),u_shadow:new i.dB(N),u_highlight:new i.dB(N),u_emissive_strength:new i.cj(N),u_accent:new i.dB(N)}),hillshadePrepare:N=>({u_matrix:new i.cl(N),u_image:new i.ch(N),u_dimension:new i.ck(N),u_zoom:new i.cj(N)}),line:i.dX,linePattern:i.dW,raster:N=>({u_matrix:new i.cl(N),u_normalize_matrix:new i.cl(N),u_globe_matrix:new i.cl(N),u_merc_matrix:new i.cl(N),u_grid_matrix:new i.dC(N),u_tl_parent:new i.ck(N),u_scale_parent:new i.cj(N),u_fade_t:new i.cj(N),u_opacity:new i.cj(N),u_image0:new i.ch(N),u_image1:new i.ch(N),u_brightness_low:new i.cj(N),u_brightness_high:new i.cj(N),u_saturation_factor:new i.cj(N),u_contrast_factor:new i.cj(N),u_spin_weights:new i.ci(N),u_perspective_transform:new i.ck(N),u_raster_elevation:new i.cj(N),u_zoom_transition:new i.cj(N),u_merc_center:new i.ck(N),u_cutoff_params:new i.d3(N),u_colorization_mix:new i.d3(N),u_colorization_offset:new i.cj(N),u_color_ramp:new i.ch(N),u_texture_offset:new i.ck(N),u_texture_res:new i.ck(N),u_emissive_strength:new i.cj(N)}),rasterParticle:N=>({u_matrix:new i.cl(N),u_normalize_matrix:new i.cl(N),u_globe_matrix:new i.cl(N),u_merc_matrix:new i.cl(N),u_grid_matrix:new i.dC(N),u_tl_parent:new i.ck(N),u_scale_parent:new i.cj(N),u_fade_t:new i.cj(N),u_opacity:new i.cj(N),u_image0:new i.ch(N),u_image1:new i.ch(N),u_raster_elevation:new i.cj(N),u_zoom_transition:new i.cj(N),u_merc_center:new i.ck(N),u_cutoff_params:new i.d3(N)}),rasterParticleTexture:N=>({u_texture:new i.ch(N),u_opacity:new i.cj(N)}),rasterParticleDraw:N=>({u_particle_texture:new i.ch(N),u_particle_texture_side_len:new i.cj(N),u_tile_offset:new i.ck(N),u_velocity:new i.ch(N),u_color_ramp:new i.ch(N),u_velocity_res:new i.ck(N),u_max_speed:new i.cj(N),u_uv_offset:new i.ck(N),u_data_scale:new i.ck(N),u_data_offset:new i.cj(N),u_particle_pos_scale:new i.cj(N),u_particle_pos_offset:new i.ck(N)}),rasterParticleUpdate:N=>({u_particle_texture:new i.ch(N),u_particle_texture_side_len:new i.cj(N),u_velocity:new i.ch(N),u_velocity_res:new i.ck(N),u_max_speed:new i.cj(N),u_speed_factor:new i.cj(N),u_reset_rate:new i.cj(N),u_rand_seed:new i.cj(N),u_uv_offset:new i.ck(N),u_data_scale:new i.ck(N),u_data_offset:new i.cj(N),u_particle_pos_scale:new i.cj(N),u_particle_pos_offset:new i.ck(N)}),symbol:N=>({u_is_size_zoom_constant:new i.ch(N),u_is_size_feature_constant:new i.ch(N),u_size_t:new i.cj(N),u_size:new i.cj(N),u_camera_to_center_distance:new i.cj(N),u_rotate_symbol:new i.ch(N),u_aspect_ratio:new i.cj(N),u_fade_change:new i.cj(N),u_matrix:new i.cl(N),u_label_plane_matrix:new i.cl(N),u_coord_matrix:new i.cl(N),u_is_text:new i.ch(N),u_elevation_from_sea:new i.ch(N),u_pitch_with_map:new i.ch(N),u_texsize:new i.ck(N),u_texsize_icon:new i.ck(N),u_texture:new i.ch(N),u_texture_icon:new i.ch(N),u_gamma_scale:new i.cj(N),u_device_pixel_ratio:new i.cj(N),u_tile_id:new i.ci(N),u_zoom_transition:new i.cj(N),u_inv_rot_matrix:new i.cl(N),u_merc_center:new i.ck(N),u_camera_forward:new i.ci(N),u_tile_matrix:new i.cl(N),u_up_vector:new i.ci(N),u_ecef_origin:new i.ci(N),u_is_halo:new i.ch(N),u_icon_transition:new i.cj(N),u_color_adj_mat:new i.cl(N),u_scale_factor:new i.cj(N),u_ground_shadow_factor:new i.ci(N),u_inv_matrix:new i.cl(N),u_normal_scale:new i.cj(N),u_lutTexture:new i.ch(N)}),background:N=>({u_matrix:new i.cl(N),u_emissive_strength:new i.cj(N),u_opacity:new i.cj(N),u_color:new i.dB(N)}),backgroundPattern:N=>({u_matrix:new i.cl(N),u_emissive_strength:new i.cj(N),u_opacity:new i.cj(N),u_image:new i.ch(N),u_pattern_tl:new i.ck(N),u_pattern_br:new i.ck(N),u_texsize:new i.ck(N),u_pattern_size:new i.ck(N),u_pixel_coord_upper:new i.ck(N),u_pixel_coord_lower:new i.ck(N),u_pattern_units_to_pixels:new i.ck(N)}),terrainRaster:N=>({u_matrix:new i.cl(N),u_image0:new i.ch(N),u_image1:new i.ch(N),u_skirt_height:new i.cj(N),u_ground_shadow_factor:new i.ci(N),u_emissive_texture_available:new i.cj(N)}),skybox:N=>({u_matrix:new i.cl(N),u_sun_direction:new i.ci(N),u_cubemap:new i.ch(N),u_opacity:new i.cj(N),u_temporal_offset:new i.cj(N)}),skyboxGradient:N=>({u_matrix:new i.cl(N),u_color_ramp:new i.ch(N),u_center_direction:new i.ci(N),u_radius:new i.cj(N),u_opacity:new i.cj(N),u_temporal_offset:new i.cj(N)}),skyboxCapture:N=>({u_matrix_3f:new i.dC(N),u_sun_direction:new i.ci(N),u_sun_intensity:new i.cj(N),u_color_tint_r:new i.d3(N),u_color_tint_m:new i.d3(N),u_luminance:new i.cj(N)}),globeRaster:N=>({u_proj_matrix:new i.cl(N),u_globe_matrix:new i.cl(N),u_normalize_matrix:new i.cl(N),u_merc_matrix:new i.cl(N),u_zoom_transition:new i.cj(N),u_merc_center:new i.ck(N),u_image0:new i.ch(N),u_image1:new i.ch(N),u_grid_matrix:new i.dC(N),u_skirt_height:new i.cj(N),u_far_z_cutoff:new i.cj(N),u_frustum_tl:new i.ci(N),u_frustum_tr:new i.ci(N),u_frustum_br:new i.ci(N),u_frustum_bl:new i.ci(N),u_globe_pos:new i.ci(N),u_globe_radius:new i.cj(N),u_viewport:new i.ck(N),u_emissive_texture_available:new i.cj(N)}),globeAtmosphere:N=>({u_frustum_tl:new i.ci(N),u_frustum_tr:new i.ci(N),u_frustum_br:new i.ci(N),u_frustum_bl:new i.ci(N),u_horizon:new i.cj(N),u_transition:new i.cj(N),u_fadeout_range:new i.cj(N),u_atmosphere_fog_color:new i.d3(N),u_high_color:new i.d3(N),u_space_color:new i.d3(N),u_temporal_offset:new i.cj(N),u_horizon_angle:new i.cj(N)}),model:N=>({u_matrix:new i.cl(N),u_lighting_matrix:new i.cl(N),u_normal_matrix:new i.cl(N),u_node_matrix:new i.cl(N),u_lightpos:new i.ci(N),u_lightintensity:new i.cj(N),u_lightcolor:new i.ci(N),u_camera_pos:new i.ci(N),u_opacity:new i.cj(N),u_baseColorFactor:new i.d3(N),u_emissiveFactor:new i.d3(N),u_metallicFactor:new i.cj(N),u_roughnessFactor:new i.cj(N),u_baseTextureIsAlpha:new i.ch(N),u_alphaMask:new i.ch(N),u_alphaCutoff:new i.cj(N),u_baseColorTexture:new i.ch(N),u_metallicRoughnessTexture:new i.ch(N),u_normalTexture:new i.ch(N),u_occlusionTexture:new i.ch(N),u_emissionTexture:new i.ch(N),u_lutTexture:new i.ch(N),u_color_mix:new i.d3(N),u_aoIntensity:new i.cj(N),u_emissive_strength:new i.cj(N),u_occlusionTextureTransform:new i.d3(N)}),modelDepth:N=>({u_matrix:new i.cl(N),u_instance:new i.cl(N),u_node_matrix:new i.cl(N)}),groundShadow:N=>({u_matrix:new i.cl(N),u_ground_shadow_factor:new i.ci(N)}),stars:N=>({u_matrix:new i.cl(N),u_up:new i.ci(N),u_right:new i.ci(N),u_intensity_multiplier:new i.cj(N)}),snowParticle:N=>({u_modelview:new i.cl(N),u_projection:new i.cl(N),u_time:new i.cj(N),u_cam_pos:new i.ci(N),u_velocityConeAperture:new i.cj(N),u_velocity:new i.cj(N),u_horizontalOscillationRadius:new i.cj(N),u_horizontalOscillationRate:new i.cj(N),u_boxSize:new i.cj(N),u_billboardSize:new i.cj(N),u_simpleShapeParameters:new i.ck(N),u_screenSize:new i.ck(N),u_thinningCenterPos:new i.ck(N),u_thinningShape:new i.ci(N),u_thinningAffectedRatio:new i.cj(N),u_thinningParticleOffset:new i.cj(N),u_particleColor:new i.d3(N),u_direction:new i.ci(N)}),rainParticle:N=>({u_modelview:new i.cl(N),u_projection:new i.cl(N),u_time:new i.cj(N),u_cam_pos:new i.ci(N),u_texScreen:new i.ch(N),u_velocityConeAperture:new i.cj(N),u_velocity:new i.cj(N),u_boxSize:new i.cj(N),u_rainDropletSize:new i.ck(N),u_distortionStrength:new i.cj(N),u_rainDirection:new i.ci(N),u_color:new i.d3(N),u_screenSize:new i.ck(N),u_thinningCenterPos:new i.ck(N),u_thinningShape:new i.ci(N),u_thinningAffectedRatio:new i.cj(N),u_thinningParticleOffset:new i.cj(N),u_shapeDirectionalPower:new i.cj(N),u_shapeNormalPower:new i.cj(N),u_mode:new i.cj(N)}),vignette:N=>({u_vignetteShape:new i.ci(N),u_vignetteColor:new i.d3(N)}),occlusion:N=>({u_matrix:new i.cl(N),u_anchorPos:new i.ci(N),u_screenSizePx:new i.ck(N),u_occluderSizePx:new i.ck(N),u_color:new i.d3(N)})};class km{constructor(u,x,C,P){this.id=km.uniqueIdxCounter,km.uniqueIdxCounter++,this.context=u;const R=u.gl;this.buffer=R.createBuffer(),this.dynamicDraw=!!C,this.context.unbindVAO(),u.bindElementBuffer.set(this.buffer),R.bufferData(R.ELEMENT_ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?R.DYNAMIC_DRAW:R.STATIC_DRAW),this.dynamicDraw||P||x.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(u){this.id=km.uniqueIdxCounter,km.uniqueIdxCounter++;const x=this.context.gl;this.context.unbindVAO(),this.bind(),x.bufferSubData(x.ELEMENT_ARRAY_BUFFER,0,u.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}km.uniqueIdxCounter=0;const KM={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class HL{constructor(u,x,C,P,R,F){this.length=x.length,this.attributes=C,this.itemSize=x.bytesPerElement,this.dynamicDraw=P,this.instanceCount=F,this.context=u;const U=u.gl;this.buffer=U.createBuffer(),u.bindVertexBuffer.set(this.buffer),U.bufferData(U.ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?U.DYNAMIC_DRAW:U.STATIC_DRAW),this.dynamicDraw||R||x.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(u){const x=this.context.gl;this.bind(),x.bufferSubData(x.ARRAY_BUFFER,0,u.arrayBuffer)}enableAttributes(u,x){for(let C=0;C0&&u.vertexAttribDivisor(R,C)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class WL{constructor(u,x,C,P,R){this.context=u,this.width=x,this.height=C;const F=this.framebuffer=u.gl.createFramebuffer();P>0&&(this.colorAttachment0=new aS(u,F,0)),P>1&&(this.colorAttachment1=new aS(u,F,1)),R&&(this.depthAttachmentType=R,this.depthAttachment=R==="renderbuffer"?new W0(u,F):new L_(u,F))}createColorAttachment(u,x){x===0?this.colorAttachment0=new aS(u,this.framebuffer,0):x===1&&(this.colorAttachment1=new aS(u,this.framebuffer,1))}removeColorAttachment(u,x){const C=this.context.gl;let P;x===0?(P=this.colorAttachment0.get(),this.colorAttachment0=void 0):x===1&&(P=this.colorAttachment1.get(),this.colorAttachment1=void 0),P&&C.deleteTexture(P)}destroy(){const u=this.context.gl;if(this.colorAttachment0){const x=this.colorAttachment0.get();x&&u.deleteTexture(x)}if(this.colorAttachment1){const x=this.colorAttachment1.get();x&&u.deleteTexture(x)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const x=this.depthAttachment.get();x&&u.deleteRenderbuffer(x)}else{const x=this.depthAttachment.get();x&&u.deleteTexture(x)}u.deleteFramebuffer(this.framebuffer)}}class X0{constructor(u,x){this.gl=u,this.clearColor=new tce(this),this.clearDepth=new NL(this),this.clearStencil=new AM(this),this.colorMask=new eS(this),this.depthMask=new EM(this),this.stencilMask=new ny(this),this.stencilFunc=new U0(this),this.stencilOp=new I_(this),this.stencilTest=new q0(this),this.depthRange=new SL(this),this.depthTest=new IM(this),this.depthFunc=new CL(this),this.blend=new V0(this),this.blendFunc=new tS(this),this.blendColor=new sS(this),this.blendEquation=new PM(this),this.cullFace=new rS(this),this.cullFaceSide=new P_(this),this.frontFace=new ML(this),this.program=new TL(this),this.activeTexture=new AL(this),this.viewport=new H0(this),this.bindFramebuffer=new EL(this),this.bindRenderbuffer=new sce(this),this.bindTexture=new rce(this),this.bindVertexBuffer=new nce(this),this.bindElementBuffer=new LM(this),this.bindVertexArrayOES=new DM(this),this.pixelStoreUnpack=new OM(this),this.pixelStoreUnpackPremultiplyAlpha=new RM(this),this.pixelStoreUnpackFlipY=new IL(this),this.options=x?Object.assign({},x):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=u.getExtension("EXT_texture_filter_anisotropic")||u.getExtension("MOZ_EXT_texture_filter_anisotropic")||u.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=u.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=u.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=u.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=u.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=x&&!!x.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=u.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=u.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=u.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=u.getParameter(u.MAX_TEXTURE_SIZE),this.extBlendFuncExtended=u.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(u,x,C){return new km(this,u,x,C)}createVertexBuffer(u,x,C,P,R){return new HL(this,u,x,C,P,R)}createRenderbuffer(u,x,C){const P=this.gl,R=P.createRenderbuffer();return this.bindRenderbuffer.set(R),P.renderbufferStorage(P.RENDERBUFFER,u,x,C),this.bindRenderbuffer.set(null),R}createFramebuffer(u,x,C,P){return new WL(this,u,x,C,P)}clear({color:u,depth:x,stencil:C,colorMask:P}){const R=this.gl;let F=0;u&&(F|=R.COLOR_BUFFER_BIT,this.clearColor.set(u.toNonPremultipliedRenderColor(null)),this.colorMask.set(P||[!0,!0,!0,!0])),x!==void 0&&(F|=R.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(x),this.depthMask.set(!0)),C!==void 0&&(F|=R.STENCIL_BUFFER_BIT,this.clearStencil.set(C),this.stencilMask.set(255)),R.clear(F)}setCullFace(u){u.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(u.mode),this.frontFace.set(u.frontFace))}setDepthMode(u){u.func!==this.gl.ALWAYS||u.mask?(this.depthTest.set(!0),this.depthFunc.set(u.func),this.depthMask.set(u.mask),this.depthRange.set(u.range)):this.depthTest.set(!1)}setStencilMode(u){u.test.func!==this.gl.ALWAYS||u.mask?(this.stencilTest.set(!0),this.stencilMask.set(u.mask),this.stencilOp.set([u.fail,u.depthFail,u.pass]),this.stencilFunc.set({func:u.test.func,ref:u.ref,mask:u.test.mask})):this.stencilTest.set(!1)}setColorMode(u){i.by(u.blendFunction,Cn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(u.blendFunction),this.blendColor.set(u.blendColor),u.blendEquation?this.blendEquation.set(u.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(u.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let oy;function xr(N,u,x,C,P,R,F){const U=N.context,K=U.gl,te=N.transform,re=[i.aF(te.center.lng),i.aJ(te.center.lat)],pe=x.layout.get("symbol-placement"),me=x.layout.get("text-variable-anchor"),fe=x.layout.get("icon-rotation-alignment")==="map",Ne=x.layout.get("text-rotation-alignment")==="map",we=pe!=="point",Re=[];let Le=0,Ze=0;for(let ht=0;ht0){const ir=i.bC(),hr=qs;i.cP(ir,Bt.placementInvProjMatrix,te.glCoordMatrix),i.cP(ir,ir,Bt.placementViewportMatrix),Re.push({circleArray:wr,circleOffset:Ze,transform:hr,invTransform:ir,projection:Bt.getProjection()}),Le+=wr.length/4,Ze=Le}if(!Os)continue;N.terrain&&N.terrain.setupElevationDraw(Ut,dr);const yr=ks?[At.canonical.x,At.canonical.y,1<=0&&(fe[nt.associatedIconIndex]={x:Bt,y:ts,z:rs,angle:is})}else bm(gt,pe)}if(te){me.clear();const Ze=N.icon.placedSymbolArray;for(let nt=0;nt{let ya=[0,0,0];if($a){const Tn=N.style.directionalLight,Ei=N.style.ambientLight;Tn&&Ei&&(ya=ff(N.style,Tn,Ei))}return ya},Ca=$a=>{ht.depthOcclusionForSymbolsAndCircles&&(x.hasOcclusionOpacityProperties||N.terrain)&&($a.push("DEPTH_D24"),$a.push("DEPTH_OCCLUSION"))},un=$a=>{x.lut&&!gt&&(x.lut.texture||(x.lut.texture=new i.d$(N.context,x.lut.image,[x.lut.image.height,x.lut.image.height,x.lut.image.height],jt.gl.RGBA8)),jt.activeTexture.set(jt.gl.TEXTURE0+Xl.LUT),x.lut.texture&&x.lut.texture.bind(jt.gl.LINEAR,jt.gl.CLAMP_TO_EDGE),$a.push("APPLY_LUT_ON_GPU"))},Ba=()=>{const $a=At&&x.layout.get("symbol-placement")!=="point",ya=[];Ca(ya),un(ya);const Tn=$a||_n,Ei=Os.elevationType==="road",jo=N.shadowRenderer,no=Ei&&Bt&&!!jo&&jo.enabled,pi=Nr(no),$d=Ei&&Bt&&!N.terrain?Yt:Ds,$c=x.paint.get("icon-image-cross-fade");N.terrainRenderModeElevated()&&Bt&&ya.push("PITCH_WITH_MAP_TERRAIN"),wr&&(ya.push("PROJECTION_GLOBE_VIEW"),Tn&&ya.push("PROJECTED_POS_ON_VIEWPORT")),$c>0&&Os.hasAnySecondaryIcon&&ya.push("ICON_TRANSITION"),!Os.icon.zOffsetVertexBuffer||Ei&&N.terrain||ya.push("Z_OFFSET"),Le===0&&Ze===0&&nt===0&&Xe===1||ya.push("COLOR_ADJUSTMENT"),Os.sdfIcons&&ya.push("RENDER_SDF"),no&&ya.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Ei&&Bt&&!N.terrain&&Os.icon.orientationVertexBuffer&&ya.push("ELEVATED_ROADS");const cl=Os.icon.programConfigurations.get(x.id),td=N.getOrCreateProgram("symbol",{config:cl,defines:ya}),sd=qs.imageAtlasTexture?qs.imageAtlasTexture.size:[0,0],gc=Os.iconSizeData,nh=i.bK(gc,ht.zoom),Uh=Bt||!ht.isOrthographic,cu=La(ir,qs.tileID.canonical,Bt,At,ht,Os.getProjection(),hr),yo=Nu(ir,qs.tileID.canonical,Bt,At,ht,Os.getProjection(),hr),Mo=N.translatePosMatrix(yo,qs,U,te,!0),fi=N.translatePosMatrix(ir,qs,U,te),zo=Tn?B_:cu,uo=At&&!Bt&&!$a;let ao=Gs;!es&&!ht.mercatorFromTransition||At||(ao=xf(ht));const qh=wr?ao:Gs,J_=x.getColorAdjustmentMatrix(Le,Ze,nt,Xe),Cm=fS(gc.kind,nh,uo,Bt,N,fi,zo,Mo,Mt,!1,sd,[0,0],0,dr,yr,Pt,ia,qh,Os.getProjection(),pi,Oa,J_,$c,null),eb=qs.imageAtlasTexture?qs.imageAtlasTexture:null,iv=x.layout.get("icon-size").constantOr(0)!==1||Os.iconsNeedLinear,wp=Os.sdfIcons||N.options.rotating||N.options.zooming||iv||Uh?ft.LINEAR:ft.NEAREST,Sf=Os.sdfIcons&&x.paint.get("icon-halo-width").constantOr(1)!==0,ov=N.terrain&&Bt&&$a?i.bl(i.bC(),cu):B_;if($a&&Os.icon){const Xg=i.bV.getAtTileOffsetFunc(dr,ht.center.lat,ht.worldSize,Os.getProjection()),Cf=_m(ir,qs.tileID.canonical,Bt,At,ht,Os.getProjection(),hr),Mm=x.layout.get("icon-size-scale-range"),Mf=i.aA(N.scaleFactor,Mm[0],Mm[1]);gL(Os,ir,N,!1,Cf,yo,Bt,we,Xg,dr,Mf)}return{program:td,buffers:Os.icon,uniformValues:Cm,atlasTexture:eb,atlasTextureIcon:null,atlasInterpolation:wp,atlasInterpolationIcon:null,isSDF:Os.sdfIcons,hasHalo:Sf,depthMode:$d,tile:qs,renderWithShadows:no,labelPlaneMatrixInv:ov}},ii=()=>{const $a=Ut&&x.layout.get("symbol-placement")!=="point",ya=[],Tn=$a||is||_n,Ei=Os.elevationType==="road",jo=N.shadowRenderer,no=Ei&&ts&&!!jo&&jo.enabled,pi=Nr(no),$d=Ei&&ts&&!N.terrain?Yt:Ds;N.terrainRenderModeElevated()&&ts&&ya.push("PITCH_WITH_MAP_TERRAIN"),wr&&(ya.push("PROJECTION_GLOBE_VIEW"),Tn&&ya.push("PROJECTED_POS_ON_VIEWPORT")),!Os.text.zOffsetVertexBuffer||Ei&&N.terrain||ya.push("Z_OFFSET"),Os.iconsInText&&ya.push("RENDER_TEXT_AND_SYMBOL"),ya.push("RENDER_SDF"),no&&ya.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Ei&&ts&&!N.terrain&&Os.text.orientationVertexBuffer&&ya.push("ELEVATED_ROADS"),Ca(ya);const $c=Os.text.programConfigurations.get(x.id),cl=N.getOrCreateProgram("symbol",{config:$c,defines:ya});let td,sd=[0,0],gc=null;const nh=Os.textSizeData;Os.iconsInText&&(sd=qs.imageAtlasTexture?qs.imageAtlasTexture.size:[0,0],gc=qs.imageAtlasTexture?qs.imageAtlasTexture:null,td=ts||!ht.isOrthographic||N.options.rotating||N.options.zooming||nh.kind==="composite"||nh.kind==="camera"?ft.LINEAR:ft.NEAREST);const Uh=qs.glyphAtlasTexture?qs.glyphAtlasTexture.size:[0,0],cu=x.layout.get("text-size-scale-range"),yo=i.aA(N.scaleFactor,cu[0],cu[1]),Mo=i.bK(nh,ht.zoom,yo),fi=La(ir,qs.tileID.canonical,ts,Ut,ht,Os.getProjection(),hr),zo=Nu(ir,qs.tileID.canonical,ts,Ut,ht,Os.getProjection(),hr),uo=N.translatePosMatrix(zo,qs,K,re,!0),ao=N.translatePosMatrix(ir,qs,K,re),qh=Tn?B_:fi,J_=Ut&&!ts&&!$a;let Cm=Gs;!es&&!ht.mercatorFromTransition||Ut||(Cm=xf(ht));const eb=fS(nh.kind,Mo,J_,ts,N,ao,qh,uo,Mt,!0,Uh,sd,0,dr,yr,Pt,ia,wr?Cm:Gs,Os.getProjection(),pi,Oa,null,null,yo),iv=qs.glyphAtlasTexture?qs.glyphAtlasTexture:null,wp=ft.LINEAR,Sf=x.paint.get("text-halo-width").constantOr(1)!==0,ov=N.terrain&&ts&&$a?i.bl(i.bC(),fi):B_;if($a&&Os.text){const Xg=i.bV.getAtTileOffsetFunc(dr,ht.center.lat,ht.worldSize,Os.getProjection()),Cf=_m(ir,qs.tileID.canonical,ts,Ut,ht,Os.getProjection(),hr);gL(Os,ir,N,!0,Cf,zo,ts,Re,Xg,dr,yo)}return{program:cl,buffers:Os.text,uniformValues:eb,atlasTexture:iv,atlasTextureIcon:gc,atlasInterpolation:wp,atlasInterpolationIcon:td,isSDF:!0,hasHalo:Sf,depthMode:$d,tile:qs,renderWithShadows:no,labelPlaneMatrixInv:ov}},Ja=Os.icon.segments.get().length,Na=Os.text.segments.get().length,Mn=Ja&&!F.onlyText?Ba():null,Fa=Na&&!F.onlyIcons?ii():null,co=x.paint.get("icon-opacity").constantOr(1),$i=x.paint.get("text-opacity").constantOr(1);if(rs&&Os.canOverlap){ms=!0;const $a=co&&!F.onlyText?Os.icon.segments.get():[],ya=$i&&!F.onlyIcons?Os.text.segments.get():[];for(const Tn of $a)ks.push({segments:new i.bg([Tn]),sortKey:Tn.sortKey,state:Mn});for(const Tn of ya)ks.push({segments:new i.bg([Tn]),sortKey:Tn.sortKey,state:Fa})}else F.onlyText||ks.push({segments:co?Os.icon.segments:new i.bg([]),sortKey:0,state:Mn}),F.onlyIcons||ks.push({segments:$i?Os.text.segments:new i.bg([]),sortKey:0,state:Fa})}ms&&ks.sort((dr,qs)=>dr.sortKey-qs.sortKey);for(const dr of ks){const qs=dr.state;if(qs)if(N.terrain?N.terrain.setupElevationDraw(qs.tile,qs.program,{useDepthForOcclusion:ht.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:qs.labelPlaneMatrixInv}):N.setupDepthForOcclusion(ht.depthOcclusionForSymbolsAndCircles,qs.program),jt.activeTexture.set(ft.TEXTURE0),qs.atlasTexture&&qs.atlasTexture.bind(qs.atlasInterpolation,ft.CLAMP_TO_EDGE,!0),qs.atlasTextureIcon&&(jt.activeTexture.set(ft.TEXTURE1),qs.atlasTextureIcon&&qs.atlasTextureIcon.bind(qs.atlasInterpolationIcon,ft.CLAMP_TO_EDGE,!0)),qs.renderWithShadows&&N.shadowRenderer.setupShadows(qs.tile.tileID.toUnwrapped(),qs.program,"vector-tile"),N.uploadCommonLightUniforms(N.context,qs.program),qs.hasHalo){const Os=qs.uniformValues;Os.u_is_halo=1,ZM(qs.buffers,dr.segments,x,N,qs.program,qs.depthMode,P,R,Os,2),Os.u_is_halo=0}else{if(qs.isSDF){const Os=qs.uniformValues;qs.hasHalo&&(Os.u_is_halo=1,ZM(qs.buffers,dr.segments,x,N,qs.program,qs.depthMode,P,R,Os,1)),Os.u_is_halo=0}ZM(qs.buffers,dr.segments,x,N,qs.program,qs.depthMode,P,R,qs.uniformValues,1)}}}function ZM(N,u,x,C,P,R,F,U,K,te){const re=[N.dynamicLayoutVertexBuffer,N.opacityVertexBuffer,N.iconTransitioningVertexBuffer,N.globeExtVertexBuffer,N.zOffsetVertexBuffer,N.orientationVertexBuffer];P.draw(C,C.context.gl.TRIANGLES,R,F,U,tn.disabled,K,x.id,N.layoutVertexBuffer,N.indexBuffer,u,x.paint,C.transform.zoom,N.programConfigurations.get(x.id),re,te)}function GL(N,u){const x=1<=jm?1:fe.pitch/jm))),2*Ne}(N.transform),te=N.transform.getFreeCameraOptions().position,re="elevatedStructuresDepthReconstruct",pe=N.getOrCreateProgram(re,{defines:["DEPTH_RECONSTRUCTION"]}),me=N.getOrCreateProgram(re);for(const fe of C){const Ne=u.getTile(fe),we=Ne.getBucket(x);if(!we)continue;const Re=we.elevatedStructures;if(!Re)continue;const Le=we.elevationBufferData.heightRange,Ze=GL(fe.toUnwrapped(),te),nt=N.translatePosMatrix(fe.projMatrix,Ne,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor"));let Xe,Mt,gt,jt;if(P==="initialize"){if(!Le||Le.min>=1||Re.depthSegments.segments[0].primitiveLength===0)continue;Xe=ay(nt,Ze,K,1,0),Mt=F,gt=Re.depthSegments,jt=pe}else if(P==="reset"){if(!Le||Le.min>=0||Re.maskSegments.segments[0].primitiveLength===0)continue;Xe=ay(nt,Ze,0,0,1),Mt=U,gt=Re.maskSegments,jt=pe}else if(P==="geometry"){if(Re.depthSegments.segments[0].primitiveLength===0)continue;Xe=ay(nt,Ze,K,1,0),Mt=F,gt=Re.depthSegments,jt=me}jt.draw(N,R.TRIANGLES,Mt,sn.disabled,Cn.disabled,tn.disabled,Xe,x.id,Re.vertexBuffer,Re.indexBuffer,gt,x.paint,N.transform.zoom)}}function yS(N,u,x,C){const{painter:P,sourceCache:R,layer:F,coords:U,colorMode:K,elevationType:te,terrainEnabled:re,pass:pe}=N,me=P.context.gl,fe=F.paint.get("fill-pattern"),Ne=F.paint.get("fill-pattern-cross-fade"),we=fe.constantOr(null);let Re=te;te!=="road"||u&&!re||(Re="none");const Le=Re==="road",Ze=N.painter.shadowRenderer,nt=Le&&!!Ze&&Ze.enabled,Xe=new Cr(P.context.gl.LEQUAL,Cr.ReadOnly,P.depthRangeFor3D);let Mt=[0,0,0];if(nt){const ht=P.style.directionalLight,At=P.style.ambientLight;ht&&At&&(Mt=ff(P.style,ht,At))}const gt=fe&&fe.constantOr(1),jt=P.terrain&&P.terrain.renderingToTexture,ft=(ht,At)=>{let Ut,Bt,ts,rs,ms;At?(Ut=gt&&!F.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ts=me.LINES):(Ut=gt?"fillPattern":"fill",ts=me.TRIANGLES);for(const Ds of U){const Yt=R.getTile(Ds);if(gt&&!Yt.patternsLoaded())continue;const Pt=Yt.getBucket(F);if(!Pt)continue;const is=u?Pt.elevationBufferData:Pt.bufferData;if(is.isEmpty())continue;P.prepareDrawTile();const es=is.programConfigurations.get(F.id),ks=P.isTileAffectedByFog(Ds),Gs=[],dr=[];Le&&(Gs.push("ELEVATED_ROADS"),dr.push(is.elevatedLayoutVertexBuffer)),nt&&Gs.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),jt&&x&&Gs.push("USE_MRT1"),gt&&(P.context.activeTexture.set(me.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),es.updatePaintBuffers());let qs=!1;if(we&&Yt.imageAtlas){const hr=Yt.imageAtlas,Fr=i.e3.from(we),_n=Fr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),ia=Fr.getSecondary(),Oa=hr.patternPositions.get(_n),Nr=ia?hr.patternPositions.get(ia.scaleSelf(i.o.devicePixelRatio).toString()):null;qs=!!Oa&&!!Nr,Oa&&es.setConstantPatternPositions(Oa,Nr)}Ne>0&&(qs||es.getPatternTransitionVertexBuffer("fill-pattern"))&&Gs.push("FILL_PATTERN_TRANSITION");const Os=P.getOrCreateProgram(Ut,{config:es,overrideFog:ks,defines:Gs}),wr=P.translatePosMatrix(Ds.projMatrix,Yt,F.paint.get("fill-translate"),F.paint.get("fill-translate-anchor"));nt&&Ze.setupShadows(Yt.tileID.toUnwrapped(),Os,"vector-tile");const yr=F.paint.get("fill-emissive-strength");if(At){rs=is.lineIndexBuffer,ms=is.lineSegments;const hr=P.terrain&&P.terrain.renderingToTexture?P.terrain.drapeBufferSize:[me.drawingBufferWidth,me.drawingBufferHeight];Bt=Ut==="fillOutlinePattern"&>?HM(wr,yr,P,Yt,hr,Mt,Ne):RL(wr,yr,hr,Mt)}else rs=is.indexBuffer,ms=is.triangleSegments,Bt=gt?VM(wr,yr,P,Yt,Mt,Ne):qM(wr,yr,Mt);P.uploadCommonUniforms(P.context,Os,Ds.toUnwrapped());let ir=ht;(te==="road"&&!re||te==="offset")&&(ir=Xe),Os.draw(P,ts,ir,C||P.stencilModeForClipping(Ds),K,tn.disabled,Bt,F.id,is.layoutVertexBuffer,rs,ms,F.paint,P.transform.zoom,es,dr)}};P.renderPass===pe&&ft(P.depthModeForSublayer(1,P.renderPass==="opaque"?Cr.ReadWrite:Cr.ReadOnly),!1),Re==="none"&&P.renderPass==="translucent"&&F.paint.get("fill-antialias")&&ft(P.depthModeForSublayer(F.getPaintProperty("fill-outline-color")?2:0,Cr.ReadOnly),!0)}function vS(N,u,x,C,P,R,F,U){x.resetLayerRenderingStats(N);const K=N.context,te=K.gl,re=N.transform,pe=x.paint.get("fill-extrusion-pattern"),me=x.paint.get("fill-extrusion-pattern-cross-fade"),fe=pe.constantOr(null),Ne=pe.constantOr(1),we=x.paint.get("fill-extrusion-opacity"),Re=N.style.enable3dLights(),Le=x.paint.get(Re&&!Ne?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),Ze=[x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Le],nt=x.layout.get("fill-extrusion-edge-radius"),Xe=nt>0&&!x.paint.get("fill-extrusion-rounded-roof"),Mt=Xe?0:nt,gt=re.projection.name==="globe"?i.eb():0,jt=re.projection.name==="globe",ft=jt?i.aj(re.zoom):0,ht=[i.aF(re.center.lng),i.aJ(re.center.lat)],At=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Ut=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(At?null:x.lut).toArray01().slice(0,3),Bt=x.paint.get("fill-extrusion-flood-light-intensity"),ts=x.paint.get("fill-extrusion-vertical-scale"),rs=x.paint.get("fill-extrusion-line-width").constantOr(1)!==0,ms=x.paint.get("fill-extrusion-height-alignment"),Ds=x.paint.get("fill-extrusion-base-alignment"),Yt=Rg(N,x.paint.get("fill-extrusion-cutoff-fade-range")),Pt=[];let is;jt&&Pt.push("PROJECTION_GLOBE_VIEW"),Ze[0]>0&&Pt.push("FAUX_AO"),Xe&&Pt.push("ZERO_ROOF_RADIUS"),U&&Pt.push("HAS_CENTROID"),Bt>0&&Pt.push("FLOOD_LIGHT"),Yt.shouldRenderCutoff&&Pt.push("RENDER_CUTOFF"),rs&&Pt.push("RENDER_WALL_MODE");const es=N.renderPass==="shadow",ks=N.shadowRenderer,Gs=es&&!!ks,dr=es?tn.disabled:tn.backCCW;N.shadowRenderer&&(N.shadowRenderer.useNormalOffset=!0);let qs=[0,0,0];if(ks){const yr=N.style.directionalLight,ir=N.style.ambientLight;yr&&ir&&(qs=ff(N.style,yr,ir)),es||(Pt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),ks.useNormalOffset&&Pt.push("NORMAL_OFFSET")),is=Pt.concat(["SHADOWS_SINGLE_CASCADE"])}const Os=Gs?"fillExtrusionDepth":Ne?"fillExtrusionPattern":"fillExtrusion",wr=x.getLayerRenderingStats();for(const yr of C){const ir=u.getTile(yr),hr=ir.getBucket(x);if(!hr||hr.projection.name!==re.projection.name)continue;let Fr=!1;ks&&(Fr=ks.getMaxCascadeForTile(yr.toUnwrapped())===0);const _n=N.isTileAffectedByFog(yr),ia=hr.programConfigurations.get(x.id);let Oa=!1;if(fe&&ir.imageAtlas){const Na=ir.imageAtlas,Mn=i.e3.from(fe),Fa=Mn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),co=Mn.getSecondary(),$i=Na.patternPositions.get(Fa),$a=co?Na.patternPositions.get(co.scaleSelf(i.o.devicePixelRatio).toString()):null;Oa=!!$i&&!!$a,$i&&ia.setConstantPatternPositions($i,$a)}me>0&&(Oa||ia.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Pt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Nr=N.getOrCreateProgram(Os,{config:ia,defines:Fr?is:Pt,overrideFog:_n});if(N.terrain&&N.terrain.setupElevationDraw(ir,Nr,{useMeterToDem:!0}),!hr.centroidVertexBuffer){const Na=Nr.getAttributeLocation(te,"a_centroid_pos");Na!==-1&&te.vertexAttrib2f(Na,0,0)}!es&&ks&&ks.setupShadows(ir.tileID.toUnwrapped(),Nr,"vector-tile"),Ne&&(N.context.activeTexture.set(te.TEXTURE0),ir.imageAtlasTexture&&ir.imageAtlasTexture.bind(te.LINEAR,te.CLAMP_TO_EDGE),ia.updatePaintBuffers());const Ca=x.paint.get("fill-extrusion-vertical-gradient"),un=1/hr.tileToMeter;let Ba;if(es&&ks){if(vf(ir.tileID,hr.maxHeight,N))continue;const Na=ks.calculateShadowPassMatrixFromTile(ir.tileID.toUnwrapped());Ba=UM(Na,Mt,un,ts,ms,Ds)}else{const Na=N.translatePosMatrix(yr.expandedProjMatrix,ir,x.paint.get("fill-extrusion-translate"),x.paint.get("fill-extrusion-translate-anchor")),Mn=re.projection.createInversionMatrix(re,yr.canonical);Ba=Ne?OL(Na,N,Ca,we,Ze,Mt,un,yr,ir,gt,ms,Ds,ft,ht,Mn,Ut,ts,me):uS(Na,N,Ca,we,Ze,Mt,un,yr,gt,ms,Ds,ft,ht,Mn,Ut,ts,Bt,qs)}N.uploadCommonUniforms(K,Nr,yr.toUnwrapped(),null,Yt);let ii=hr.segments;if(re.projection.name==="mercator"&&!es&&(ii=hr.getVisibleSegments(ir.tileID,N.terrain,N.transform.getFrustum(0)),!ii.get().length))continue;if(wr)if(es)for(const Na of ii.get())wr.numRenderedVerticesInShadowPass+=Na.primitiveLength;else for(const Na of ii.get())wr.numRenderedVerticesInTransparentPass+=Na.primitiveLength;const Ja=[];(N.terrain||U)&&Ja.push(hr.centroidVertexBuffer),jt&&Ja.push(hr.layoutVertexExtBuffer),rs&&Ja.push(hr.wallVertexBuffer),Nr.draw(N,K.gl.TRIANGLES,P,R,F,dr,Ba,x.id,hr.layoutVertexBuffer,hr.indexBuffer,ii,x.paint,N.transform.zoom,ia,Ja)}N.shadowRenderer&&(N.shadowRenderer.useNormalOffset=!1)}class YM{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function yf(N,u,x,C,P,R,F,U,K,te,re,pe,me,fe,Ne,we,Re,Le,Ze,nt){const Xe=u.context,Mt=Xe.gl,gt=u.transform,jt=u.transform.zoom,ft=[],ht=N.translate,At=N.translateAnchor,Ut=N.edgeRadius,Bt=Rg(u,N.cutoffFadeRange);re==="clear"?(ft.push("CLEAR_SUBPASS"),nt&&(ft.push("CLEAR_FROM_TEXTURE"),Xe.activeTexture.set(Mt.TEXTURE0),nt.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE))):re==="sdf"?ft.push("SDF_SUBPASS"):re==="emissive"&&(ft.push("USE_MRT1"),Xe.activeTexture.set(Mt.TEXTURE0),nt.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE)),Le&&ft.push("HAS_CENTROID"),Bt.shouldRenderCutoff&&ft.push("RENDER_CUTOFF");const ts=(rs,ms,Ds,Yt,Pt)=>{let is=ft;ms.groundRadiusBuffer!=null&&(is=ft.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const es=ms.programConfigurations.get(C.id),ks=u.isTileAffectedByFog(rs),Gs=u.getOrCreateProgram("fillExtrusionGroundEffect",{config:es,defines:is,overrideFog:ks}),dr=Z0(u,Yt,pe,te,Pt,[me,fe*Pt],Ne,we,Re,jt>=17?0:Ut*Pt,nt?nt.size[0]:0),qs=[];Le&&qs.push(ms.hiddenByLandmarkVertexBuffer),ms.groundRadiusBuffer!=null&&qs.push(ms.groundRadiusBuffer),u.uploadCommonUniforms(Xe,Gs,rs.toUnwrapped(),null,Bt),Gs.draw(u,Xe.gl.TRIANGLES,R,F,U,K,dr,C.id,ms.vertexBuffer,ms.indexBuffer,Ds,C.paint,jt,es,qs)};for(const rs of P){const ms=x.getTile(rs),Ds=ms.getBucket(C);if(!Ds||Ds.projection.name!==gt.projection.name||!Ds.groundEffect||Ds.groundEffect&&!Ds.groundEffect.hasData())continue;const Yt=Ds.groundEffect,Pt=1/Ds.tileToMeter;{const is=u.translatePosMatrix(rs.projMatrix,ms,ht,At),es=Yt.getDefaultSegment();ts(rs,Yt,es,is,Pt)}if(Ze)for(let is=0;is<4;is++){const es=i.e9[is](rs),ks=x.getTile(es);if(!ks)continue;const Gs=ks.getBucket(C);if(!Gs||Gs.projection.name!==gt.projection.name||!Gs.groundEffect||Gs.groundEffect&&!Gs.groundEffect.hasData())continue;const dr=Gs.groundEffect;let qs,Os;is===0?(qs=[-i.al,0,0],Os=1):is===1?(qs=[i.al,0,0],Os=0):is===2?(qs=[0,-i.al,0],Os=3):(qs=[0,i.al,0],Os=2);const wr=dr.regionSegments[Os];if(!wr)continue;const yr=new Float32Array(16);i.br(yr,rs.projMatrix,qs),ts(rs,dr,wr,u.translatePosMatrix(yr,ms,ht,At),Pt)}}}function dce(N,u,x,C,P,R,F){C.centroidVertexArray.length===0&&C.createCentroidsBuffer();const U=R?R.findDEMTileFor(x):null;if(!(U&&U.dem||F))return;R&&U&&U.dem&&C.selfDEMTileTimestamp!==U.dem._timestamp&&(C.borderDoneWithNeighborZ=[-1,-1,-1,-1],C.selfDEMTileTimestamp=U.dem._timestamp);const K=Le=>new i.P(Math.ceil((Le+i.ed)*i.ee),0),te=Le=>{const Ze=u.getSource().minzoom,nt=Mt=>{const gt=u.getTileByID(Mt);if(gt&>.hasData())return gt.getBucket(P)},Xe=[0,-1,1];for(const Mt of Xe){if(Le.overscaledZ+Mt(re[0]=Math.min(Le.min.y,Ze.min.y),re[1]=Math.max(Le.max.y,Ze.max.y),re[2]=i.al-Ze.min.x>Le.max.x?Ze.min.x-i.al:Le.max.x,re),me=(Le,Ze)=>(re[0]=Math.min(Le.min.x,Ze.min.x),re[1]=Math.max(Le.max.x,Ze.max.x),re[2]=i.al-Ze.min.y>Le.max.y?Ze.min.y-i.al:Le.max.y,re),fe=[(Le,Ze)=>pe(Le,Ze),(Le,Ze)=>pe(Ze,Le),(Le,Ze)=>me(Le,Ze),(Le,Ze)=>me(Ze,Le)],Ne=(Le,Ze,nt,Xe,Mt,gt,jt)=>{if(!R)return 0;const ft=[[gt?nt:Le,gt?Le:nt,0],[gt?nt:Ze,gt?Ze:nt,0]],ht=jt<0?i.al+jt:jt,At=[gt?ht:(Le+Ze)/2,gt?(Le+Ze)/2:ht,0];return nt===0&&jt<0||nt!==0&&jt>0?R.getForTilePoints(Mt,[At],!0,Xe):ft.push(At),R.getForTilePoints(x,ft,!0,U),Math.max(ft[0][2],ft[1][2],At[2])/R.exaggeration()};for(let Le=0;Le<4;Le++){const Ze=C.borderFeatureIndices[Le];if(Ze.length===0)continue;const nt=i.e9[Le](x),Xe=te(nt);if(!(Xe&&Xe instanceof i.ea))continue;const Mt=R?R.findDEMTileFor(nt):null;if(!(Mt&&Mt.dem||F)||(R&&Mt&&Mt.dem&&C.borderDEMTileTimestamp[Le]!==Mt.dem._timestamp&&(C.borderDoneWithNeighborZ[Le]=-1,C.borderDEMTileTimestamp[Le]=Mt.dem._timestamp),C.borderDoneWithNeighborZ[Le]===Xe.canonical.z))continue;Xe.centroidVertexArray.length===0&&Xe.createCentroidsBuffer();const gt=(Le<2?1:5)-Le,jt=Xe.borderDoneWithNeighborZ[gt]!==C.canonical.z,ft=Xe.borderFeatureIndices[gt];let ht=0;if(C.canonical.z!==Xe.canonical.z){for(const At of Ze)C.showCentroid(C.featuresOnBorder[At]);if(jt)for(const At of ft)Xe.showCentroid(Xe.featuresOnBorder[At]);C.borderDoneWithNeighborZ[Le]=Xe.canonical.z,Xe.borderDoneWithNeighborZ[gt]=C.canonical.z}for(const At of Ze){const Ut=C.featuresOnBorder[At],Bt=C.centroidData[Ut.centroidDataIndex],ts=Ut.borders[Le];let rs;for(;htts[0]+3||ms[0]>ts[0]-3)break;Xe.showCentroid(rs),ht++}if(rs&&htts[1]-3)&&(Ds++,++ht!==ft.length);)rs=Xe.featuresOnBorder[ft[ht]];rs=Xe.featuresOnBorder[ft[ms]];let Yt=!1;if(Ds>=1){const es=rs.borders[gt];Math.abs(ts[0]-es[0])<3&&Math.abs(ts[1]-es[1])<3&&(Ds=1,Yt=!0,ht=ms+1)}else if(Ds===0){C.showCentroid(Ut);continue}const Pt=Xe.centroidData[rs.centroidDataIndex];F&&Yt&&(((we=Bt).flags|(Re=Pt).flags)&i.ec?(we.flags|=i.ec,Re.flags|=i.ec):(we.flags&=~i.ec,Re.flags&=~i.ec));const is=Ut.intersectsCount()>1||rs.intersectsCount()>1;if(Ds>1)ht=ms,Bt.centroidXY=Pt.centroidXY=new i.P(0,0);else if(Mt&&Mt.dem&&!is){const es=fe[Le](Bt,Pt),ks=Le%2?i.al-1:0,Gs=Ne(es[0],Math.min(i.al-1,es[1]),ks,Mt,nt,Le<2,es[2]);Bt.centroidXY=Pt.centroidXY=K(Gs)}else is?Bt.centroidXY=Pt.centroidXY=new i.P(0,0):(Bt.centroidXY=C.encodeBorderCentroid(Ut),Pt.centroidXY=Xe.encodeBorderCentroid(rs));C.writeCentroidToBuffer(Bt),Xe.writeCentroidToBuffer(Pt)}else C.showCentroid(Ut)}C.borderDoneWithNeighborZ[Le]=Xe.canonical.z,Xe.borderDoneWithNeighborZ[gt]=C.canonical.z}var we,Re;(C.needsCentroidUpdate||!C.centroidVertexBuffer&&C.centroidVertexArray.length!==0)&&C.uploadCentroid(N)}const Su=[1,0,0],XM=[0,1,0],zd=[0,0,1];function vf(N,u,x){const C=x.transform,P=x.shadowRenderer;if(!P)return!0;const R=N.toUnwrapped(),F=C.tileSize*P._cascades[x.currentShadowCascade].scale;let U=u;if(C.elevation){const we=C.elevation.getMinMaxForTile(N);we&&(U+=we.max)}const K=[...P.shadowDirection];K[2]=-K[2];const te=P.computeSimplifiedTileShadowVolume(R,U,F,K);if(!te)return!1;const re=[Su,XM,zd,K,[K[0],0,K[2]],[0,K[1],K[2]]],pe=C.projection.name==="globe",me=C.scaleZoom(F),fe=i.cB.fromInvProjectionMatrix(C.invProjMatrix,C.worldSize,me,!pe),Ne=P.getCurrentCascadeFrustum();return fe.intersectsPrecise(te.vertices,te.planes,re)===0||Ne.intersectsPrecise(te.vertices,te.planes,re)===0}function U_(N){const{painter:u,source:x,layer:C,coords:P}=N;let R=N.defines;const F=u.context,U=u.renderPass==="shadow",K=u.renderPass==="light-beam",te=u.shadowRenderer,re=i.ef(u.transform.center.lat,u.transform.zoom),pe=Rg(u,C.paint.get("building-cutoff-fade-range"));pe.shouldRenderCutoff&&(R=R.concat("RENDER_CUTOFF")),N.floodLightIntensity>0&&(R=R.concat("FLOOD_LIGHT"));for(const me of P){const fe=x.getTile(me),Ne=fe.getBucket(C);if(!Ne)continue;te&&te.getMaxCascadeForTile(me.toUnwrapped())===0&&(R=R.concat("SHADOWS_SINGLE_CASCADE"));const we=Ne.programConfigurations.get(C.id);let Re,Le,Ze,nt=u.translatePosMatrix(me.expandedProjMatrix,fe,[0,0],"map");if(nt=i.cS(i.bC(),nt,[1,1,N.verticalScale]),U&&te){if(vf(fe.tileID,Ne.maxHeight*re,u))continue;let Mt=te.calculateShadowPassMatrixFromTile(fe.tileID.toUnwrapped());Mt=i.cS(i.bC(),Mt,[1,1,N.verticalScale]),Ze=Vg(Mt),Re=Le=u.getOrCreateProgram("buildingDepth",{config:we,defines:R,overrideFog:!1})}else if(K)Re=Le=u.getOrCreateProgram("buildingBloom",{config:we,defines:R,overrideFog:!1}),Ze=FL(nt);else{const Mt=u.transform.calculatePosMatrix(me.toUnwrapped(),u.transform.worldSize);i.cS(Mt,Mt,[1,1,N.verticalScale]);const gt=i.bC();i.cS(gt,Mt,[1,-1,1/re]),i.bl(gt,gt),i.eg(gt,gt);const jt=u.transform.getFreeCameraOptions().position,ft=1<{if(K){const jt=Mt.entranceBloom;gt.draw(u,F.gl.TRIANGLES,N.depthMode,sn.disabled,N.blendMode,tn.disabled,Ze,C.id,jt.layoutVertexBuffer,jt.indexBuffer,jt.segmentsBucket,C.paint,u.transform.zoom,we,[jt.layoutAttenuationBuffer,jt.layoutColorBuffer])}else{const jt=Mt.segmentsBucket;let ft=[Mt.layoutNormalBuffer,Mt.layoutCentroidBuffer,Mt.layoutColorBuffer,Mt.layoutFloodLightDataBuffer];Mt.layoutFacadePaintBuffer&&(ft=ft.concat([Mt.layoutFacadeDataBuffer,Mt.layoutFacadeVerticalRangeBuffer,Mt.layoutFacadePaintBuffer])),gt.draw(u,F.gl.TRIANGLES,N.depthMode,sn.disabled,N.blendMode,U?tn.disabled:tn.backCW,Ze,C.id,Mt.layoutVertexBuffer,Mt.indexBuffer,jt,C.paint,u.transform.zoom,we,ft)}};u.uploadCommonUniforms(F,Le,me.toUnwrapped(),null,pe),Ne.buildingWithoutFacade&&Xe(Ne.buildingWithoutFacade,Le),Ne.buildingWithFacade&&(Re!==Le&&u.uploadCommonUniforms(F,Re,me.toUnwrapped(),null,pe),Xe(Ne.buildingWithFacade,Re))}}function _S(N,u,x,C,P,R,F,U,K,te,re,pe,me){const fe=N.context.gl,Ne=N.depthModeForSublayer(1,Cr.ReadOnly,fe.LEQUAL,!0),we=.1*(1-(Re=re))+3*Re;var Re;const Le=N._showOverdrawInspector,Ze=pe,nt=new YM;Le||yf(nt,N,u,x,C,Ne,new sn({func:fe.ALWAYS,mask:255},255,255,fe.KEEP,fe.KEEP,fe.REPLACE),new Cn([fe.ONE,fe.ONE,fe.ONE,fe.ONE],i.ao.transparent,[!1,!1,!1,!0],fe.MIN),tn.disabled,P,"sdf",R,F,U,K,te,we,Ze,!1);{const Xe=Le?sn.disabled:new sn({func:fe.EQUAL,mask:255},255,255,fe.KEEP,fe.DECR,fe.DECR),Mt=Le?N.colorModeForRenderPass():new Cn([fe.ONE_MINUS_DST_ALPHA,fe.DST_ALPHA,fe.ONE,fe.ONE],i.ao.transparent,[!0,!0,!0,!0]);yf(nt,N,u,x,C,Ne,Xe,Mt,tn.disabled,P,"color",R,F,U,K,te,we,Ze,!1)}}function bS(N){return[N[0]*i.eh,N[1]*i.eh,N[2]*i.eh,0]}function q_(N,u,x,C,P,R,F,U,K){const te=C.getSource(),re=x.globeSharedBuffers;if(!re)return;let pe,me,fe;if(u&&(pe=C.getTile(u)),te instanceof i.aU?(me=te.texture,fe=i.dK(0,0,x.transform)):pe&&u&&(me=pe.texture,fe=i.dK(u.canonical.z,u.canonical.x,x.transform)),!me||!fe)return;N||(fe=i.cS(i.bC(),fe,[1,-1,1]));const Ne=x.context,we=Ne.gl,Re=P.paint.get("raster-resampling")==="nearest"?we.NEAREST:we.LINEAR,Le=x.colorModeForDrapableLayerRenderPass(R),Ze=F.defines;Ze.push("GLOBE_POLES");const nt=new Cr(we.LEQUAL,Cr.ReadWrite,x.depthRangeFor3D),Xe=Float32Array.from(x.transform.expandedFarZProjMatrix),Mt=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));x.terrain&&x.terrain.prepareDrawTile(),Ne.activeTexture.set(we.TEXTURE0),me.bind(Re,we.CLAMP_TO_EDGE),Ne.activeTexture.set(we.TEXTURE1),me.bind(Re,we.CLAMP_TO_EDGE),"useMipmap"in me&&Ne.extTextureFilterAnisotropic&&x.transform.pitch>20&&we.texParameterf(we.TEXTURE_2D,Ne.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Ne.extTextureFilterAnisotropicMax);const[gt,jt,ft,ht]=u?re.getPoleBuffers(u.canonical.z,!1):re.getPoleBuffers(0,!0),At=P.paint.get("raster-elevation");let Ut;N?(Ut=gt,x.renderDefaultNorthPole=At!==0):(Ut=jt,x.renderDefaultSouthPole=At!==0);const Bt=bS(F.mix),ts=((ms,Ds,Yt,Pt,is,es,ks,Gs,dr,qs,Os,wr,yr)=>$L(ms,Ds,Yt,new Float32Array(16),new Float32Array(9),[0,0],Pt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},es,[0,0],Gs,2,qs,Os,wr,1,0,yr))(Xe,Mt,fe,i.aj(x.transform.zoom),0,P,0,At,0,Bt,F.offset,F.range,R),rs=x.getOrCreateProgram("raster",{defines:Ze});x.uploadCommonUniforms(Ne,rs,null),rs.draw(x,we.TRIANGLES,nt,K,Le,U,ts,P.id,Ut,ft,ht)}function KL(N){const u=N._nearZ,x=N.projection.farthestPixelDistance(N),C=x-u,P=.2*N.height,R=u+P;return[u,x,(R-P-u)/C,(R-u)/C]}function _f(N,u,x,C){if(N)return u instanceof zc&&N instanceof P0?u.getTextureDescriptor(N,x,!0):{texture:N.texture,mix:bS(C.mix),offset:C.offset,buffer:0,tileSize:1}}var Si=i.ei([{name:"a_index",type:"Int16",components:1}]);class wS{constructor(u,x,C,P){const R={width:C[0],height:C[1],data:null},F=u.gl;this.targetColorTexture=new i.T(u,R,F.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(u,R,F.RGBA8,{useMipmap:!1}),this.context=u,this.updateParticleTexture(x,P),this.lastInvalidatedAt=0}updateParticleTexture(u,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 C=this.context.gl,P=x.width*x.height;this.particleTexture0=new i.T(this.context,x,C.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,x,C.RGBA8,{premultiply:!1,useMipmap:!1});const R=new i.ej;R.reserve(P);for(let F=0;F0){const Bt=i.bj(x.canonical,K),ts=i.el(Bt);me=i.aB(new Float32Array(16),K.globeMatrix,ts),i.aB(me,K.projMatrix,me)}const fe=i.bC();fe[12]+=2*P/(i.o.devicePixelRatio*K.width),fe[13]+=2*R/(i.o.devicePixelRatio*K.height),i.aB(me,fe,me);const Ne=N.getOrCreateProgram("debug",{defines:pe}),we=u.getTileByID(x.key);N.terrain&&N.terrain.setupElevationDraw(we,Ne);const Re=Cr.disabled,Le=sn.disabled,Ze=N.colorModeForRenderPass(),nt="$debug";U.activeTexture.set(te.TEXTURE0),N.emptyTexture.bind(te.LINEAR,te.CLAMP_TO_EDGE),re?we._makeGlobeTileDebugBuffers(N.context,K):we._makeDebugTileBoundsBuffers(N.context,K.projection);const Xe=we._tileDebugBuffer||N.debugBuffer,Mt=we._tileDebugIndexBuffer||N.debugIndexBuffer,gt=we._tileDebugSegments||N.debugSegments;if(Ne.draw(N,te.LINE_STRIP,Re,Le,Ze,tn.disabled,F_(me,C.toPremultipliedRenderColor(null)),nt,Xe,Mt,gt,null,null,null,[we._globeTileDebugBorderBuffer]),F){const Bt=we.latestRawTileData,ts=Math.floor((Bt&&Bt.byteLength||0)/1024);let rs=x.canonical.toString();x.overscaledZ!==x.canonical.z&&(rs+=` => ${x.overscaledZ}`),rs+=` ${we.state}`,rs+=` ${ts}kb`,function(ms,Ds){ms.initDebugOverlayCanvas();const Yt=ms.debugOverlayCanvas,Pt=ms.context.gl,is=ms.debugOverlayCanvas.getContext("2d");is.clearRect(0,0,Yt.width,Yt.height),is.shadowColor="white",is.shadowBlur=2,is.lineWidth=1.5,is.strokeStyle="white",is.textBaseline="top",is.font="bold 36px Open Sans, sans-serif",is.fillText(Ds,5,5),is.strokeText(Ds,5,5),ms.debugOverlayTexture.update(Yt),ms.debugOverlayTexture.bind(Pt.LINEAR,Pt.CLAMP_TO_EDGE)}(N,rs)}const jt=u.getTile(x).tileSize,ft=512/Math.min(jt,512)*(x.overscaledZ/K.zoom)*.5,ht=we._tileDebugTextBuffer||N.debugBuffer,At=we._tileDebugTextIndexBuffer||N.quadTriangleIndexBuffer,Ut=we._tileDebugTextSegments||N.debugSegments;Ne.draw(N,te.TRIANGLES,Re,Le,Cn.alphaBlended,tn.disabled,F_(me,i.ao.transparent.toPremultipliedRenderColor(null),ft),nt,ht,At,Ut,null,null,null,[we._globeTileDebugTextBuffer])}function dy(N,u,x,C){Vt(N,0,u+x/2,N.transform.width,x,C)}function xo(N,u,x,C){Vt(N,u-x/2,0,x,N.transform.height,C)}function Vt(N,u,x,C,P,R){const F=N.context,U=F.gl;U.enable(U.SCISSOR_TEST),U.scissor(u*i.o.devicePixelRatio,x*i.o.devicePixelRatio,C*i.o.devicePixelRatio,P*i.o.devicePixelRatio),F.clear({color:R}),U.disable(U.SCISSOR_TEST)}const JL=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:jS}=JL;function yp(N,u,x,C){N.emplaceBack(u,x,C)}class kS{constructor(u){this.vertexArray=new i.em,this.indices=new i.b0,yp(this.vertexArray,-1,-1,1),yp(this.vertexArray,1,-1,1),yp(this.vertexArray,-1,1,1),yp(this.vertexArray,1,1,1),yp(this.vertexArray,-1,-1,-1),yp(this.vertexArray,1,-1,-1),yp(this.vertexArray,-1,1,-1),yp(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=u.createVertexBuffer(this.vertexArray,jS),this.indexBuffer=u.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function uy(N,u,x,C,P,R){const F=N.context.gl,U=u.paint.get("sky-atmosphere-color"),K=u.paint.get("sky-atmosphere-halo-color"),te=u.paint.get("sky-atmosphere-sun-intensity"),re=((pe,me,fe,Ne,we)=>({u_matrix_3f:pe,u_sun_direction:me,u_sun_intensity:fe,u_color_tint_r:[Ne.r,Ne.g,Ne.b,Ne.a],u_color_tint_m:[we.r,we.g,we.b,we.a],u_luminance:5e-5}))(i.eo(i.dO(),C),P,te,U.toPremultipliedRenderColor(null),K.toPremultipliedRenderColor(null));F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+R,u.skyboxTexture,0),x.draw(N,F.TRIANGLES,Cr.disabled,sn.disabled,Cn.unblended,tn.frontCW,re,"skyboxCapture",u.skyboxGeometry.vertexBuffer,u.skyboxGeometry.indexBuffer,u.skyboxGeometry.segment)}const eD=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Q0{constructor(u){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 C=new i.b0;C.emplaceBack(0,1,2),C.emplaceBack(2,3,0),this.vertexBuffer=u.createVertexBuffer(x,eD.members),this.indexBuffer=u.createIndexBuffer(C),this.segments=i.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const uce=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 hce{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class tD{constructor(u){this.colorModeAlphaBlendedWriteRGB=new Cn([1,pp,1,pp],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Cn([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new hce,this.updateNeeded=!0}update(u){const x=u.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Q0(x);const C=this.params.sizeRange,P=this.params.intensityRange,R=function(re){const pe=i.eq(30),me=[];for(let fe=0;fe{const ft=R.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];jt&&ft.push("ALPHA_PASS");const ht=u.getOrCreateProgram("globeAtmosphere",{defines:ft}),At=((Bt,ts,rs,ms,Ds,Yt,Pt,is,es,ks,Gs,dr)=>({u_frustum_tl:Bt,u_frustum_tr:ts,u_frustum_br:rs,u_frustum_bl:ms,u_horizon:Ds,u_transition:Yt,u_fadeout_range:Pt,u_atmosphere_fog_color:is.toArray01(),u_high_color:es.toArray01(),u_space_color:ks.toArray01(),u_temporal_offset:Gs,u_horizon_angle:dr}))(R.frustumCorners.TL,R.frustumCorners.TR,R.frustumCorners.BR,R.frustumCorners.BL,R.frustumCorners.horizon,U,Re,re,me,Ne,Ze,Mt);u.uploadCommonUniforms(C,ht);const Ut=this.atmosphereBuffer;Ut&&ht.draw(u,P.TRIANGLES,F,sn.disabled,jt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,tn.backCW,At,jt?"atmosphere_glow_alpha":"atmosphere_glow",Ut.vertexBuffer,Ut.indexBuffer,Ut.segments)};gt(!1),gt(!0)}drawStars(u,x){const C=i.aA(x.properties.get("star-intensity"),0,1);if(C===0)return;const P=u.context,R=P.gl,F=u.transform,U=u.getOrCreateProgram("stars"),K=i.c7([]);i.c9(K,K,-F._pitch),i.c8(K,K,-F.angle),i.c9(K,K,i.an(F._center.lat)),i.et(K,K,-i.an(F._center.lng));const te=i.cc(new Float32Array(16),K),re=i.aB([],F.starsProjMatrix,te),pe=i.eo([],te),me=i.eu([],pe),fe=[0,1,0];i.dQ(fe,fe,me),i.c5(fe,fe,this.params.sizeMultiplier);const Ne=[1,0,0];i.dQ(Ne,Ne,me),i.c5(Ne,Ne,this.params.sizeMultiplier);const we=(Re=fe,Le=Ne,Ze=C,{u_matrix:Float32Array.from(re),u_up:Re,u_right:Le,u_intensity_multiplier:Ze});var Re,Le,Ze;u.uploadCommonUniforms(P,U),this.starsVx&&this.starsIdx&&U.draw(u,R.TRIANGLES,Cr.disabled,sn.disabled,this.colorModeAlphaBlendedWriteRGB,tn.disabled,we,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class NS{constructor(){this.visibleTiles=[]}updateBorders(u,x){const C=[],P=[],R=u._getRenderableCoordinates(!1,!0);for(const K of R){const te=u.getTile(K);if(!te.hasData())continue;const re=te.getBucket(x);re&&(re.isEmpty()||(C.push(K.key),P.push({bucket:re,tileID:K.canonical})))}let F=C.length!==this.visibleTiles.length;if(!F){C.sort();for(let K=0;KK.tileID.z-te.tileID.z||K.tileID.x-te.tileID.x||K.tileID.y-te.tileID.y);for(const K of P){const te=new Array,re=new Array,pe=K.bucket;for(const me of pe.featuresOnBorder)U.has(me.featureId)?re.push(me.footprintIndex):(U.add(me.featureId),te.push(me.footprintIndex));pe.updateFootprintHiddenFlags(te,i.ev,!1),pe.updateFootprintHiddenFlags(re,i.ev,!0)}}}function SS(N,u){const x=[...N],C=u.cameraWorldSizeForFog/u.worldSize,P=i.bA([]);return i.cS(P,P,[C,C,1]),i.aB(x,P,x),i.aB(x,u.worldToFogMatrix,x),x}function CS(N,u,x,C,P){const R=x.material,F=C.context,{baseColorTexture:U,metallicRoughnessTexture:K}=R.pbrMetallicRoughness,{normalTexture:te,occlusionTexture:re,emissionTexture:pe}=R;function me(Ne,we,Re){if(Ne&&(N.push(we),F.activeTexture.set(F.gl.TEXTURE0+Re),Ne.gfxTexture)){const{minFilter:Le,magFilter:Ze,wrapS:nt,wrapT:Xe}=Ne.sampler;Ne.gfxTexture.bindExtraParam(Le,Ze,nt,Xe)}}me(U,"HAS_TEXTURE_u_baseColorTexture",Xl.BaseColor),me(K,"HAS_TEXTURE_u_metallicRoughnessTexture",Xl.MetallicRoughness),me(te,"HAS_TEXTURE_u_normalTexture",Xl.Normal),me(re,"HAS_TEXTURE_u_occlusionTexture",Xl.Occlusion),me(pe,"HAS_TEXTURE_u_emissionTexture",Xl.Emission),P&&(P.texture||(P.texture=new i.d$(C.context,P.image,[P.image.height,P.image.height,P.image.height],F.gl.RGBA8)),F.activeTexture.set(F.gl.TEXTURE0+Xl.LUT),P.texture&&P.texture.bind(F.gl.LINEAR,F.gl.CLAMP_TO_EDGE),N.push("APPLY_LUT_ON_GPU")),x.texcoordBuffer&&(N.push("HAS_ATTRIBUTE_a_uv_2f"),u.push(x.texcoordBuffer)),x.colorBuffer&&(N.push(x.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),u.push(x.colorBuffer)),x.normalBuffer&&(N.push("HAS_ATTRIBUTE_a_normal_3f"),u.push(x.normalBuffer)),x.pbrBuffer&&(N.push("HAS_ATTRIBUTE_a_pbr"),N.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),u.push(x.pbrBuffer)),R.alphaMode!=="OPAQUE"&&R.alphaMode!=="MASK"||N.push("UNPREMULT_TEXTURE_IN_SHADER"),R.defined||N.push("DIFFUSE_SHADED");const fe=C.shadowRenderer;fe&&(N.push("RENDER_SHADOWS","DEPTH_TEXTURE"),fe.useNormalOffset&&N.push("NORMAL_OFFSET"))}function MS(N,u,x,C,P,R){const F=N.modelOpacity,U=u.context,K=new Cr(u.context.gl.LEQUAL,N.isLightMesh?Cr.ReadOnly:Cr.ReadWrite,u.depthRangeFor3D),te=u.transform,re=N.mesh,pe=re.material,me=pe.pbrMetallicRoughness,fe=u.style.fog;let Ne;Ne=u.transform.projection.zAxisUnit==="pixels"?[...N.nodeModelMatrix]:i.aB([],C.zScaleMatrix,N.nodeModelMatrix),i.aB(Ne,C.negCameraPosMatrix,Ne);const we=i.bl([],Ne);i.eg(we,we);const Re=x.paint.get("model-color-use-theme").constantOr("default")==="none",Le=x.paint.get("model-emissive-strength").constantOr(0),Ze=iy(new Float32Array(N.worldViewProjection),new Float32Array(Ne),new Float32Array(we),null,u,F,me.baseColorFactor,pe.emissiveFactor,me.metallicFactor,me.roughnessFactor,pe,Le,x,void 0,void 0,N.materialOverride,N.modelColor),nt={defines:[]},Xe=[],Mt=u.shadowRenderer;Mt&&(Mt.useNormalOffset=!1),CS(nt.defines,Xe,re,u,Re?null:x.lut);let gt=null;if(fe){const ht=SS(N.nodeModelMatrix,u.transform);if(gt=new Float32Array(ht),te.projection.name!=="globe"){const At=re.aabb.min,Ut=re.aabb.max,[Bt,ts]=fe.getOpacityForBounds(ht,At[0],At[1],Ut[0],Ut[1]);nt.overrideFog=Bt>=ps||ts>=ps}}const jt=Rg(u,x.paint.get("model-cutoff-fade-range"));jt.shouldRenderCutoff&&nt.defines.push("RENDER_CUTOFF");const ft=u.getOrCreateProgram("model",nt);u.uploadCommonUniforms(U,ft,null,gt,jt),u.renderPass!=="shadow"&&Mt&&Mt.setupShadowsFromMatrix(N.nodeModelMatrix,ft),ft.draw(u,U.gl.TRIANGLES,K,P,R,re.material.doubleSided?tn.disabled:tn.backCCW,Ze,x.id,re.vertexBuffer,re.indexBuffer,re.segments,x.paint,u.transform.zoom,void 0,Xe)}function V_(N,u){return N.style._importedAsBasemap?"basemap":u.scope}function hy(N,u,x,C,P,R,F,U,K,te){const re=N.transform,pe=!!u.isGeometryBloom&&u.isGeometryBloom;if(pe&&N.renderPass==="shadow")return;const me=re.projection.name==="globe"?i.eD(x,re):[...x];i.aB(me,me,u.globalMatrix);const fe=i.aB([],C,me);if(u.meshes)for(const Ne of u.meshes){const we=U.get(Ne.material.name);if(we&&we.opacity<=0)continue;if(Ne.material.alphaMode!=="BLEND"){F.push({mesh:Ne,depth:0,modelIndex:P,worldViewProjection:fe,nodeModelMatrix:me,isLightMesh:pe,materialOverride:we,modelOpacity:K,modelColor:te});continue}const Re=i.af([],Ne.centroid,fe);!re.isOrthographic&&Re[2]<=0||R.push({mesh:Ne,depth:Re[2],modelIndex:P,worldViewProjection:fe,nodeModelMatrix:me,isLightMesh:pe,materialOverride:we,modelOpacity:K,modelColor:te})}if(u.children)for(const Ne of u.children)hy(N,Ne,x,C,P,R,F,U,K,te)}function Nm(N,u,x,C){const P=x.shadowRenderer;if(!P)return;const R=P.getShadowPassDepthMode(),F=P.getShadowPassColorMode(),U=P.calculateShadowPassMatrixFromMatrix(u),K=GM(U);x.getOrCreateProgram("modelDepth",{defines:x._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(x,x.context.gl.TRIANGLES,R,sn.disabled,F,tn.disabled,K,C.id,N.vertexBuffer,N.indexBuffer,N.segments,C.paint,x.transform.zoom,void 0,void 0)}function sD(N,u,x,C,P,R){for(const F of P){const U=Object.assign({},C);U.part=F;const K={type:"Unknown",id:u,properties:U},te={orientation:N.paint.get("model-rotation").evaluate(K,x)};R.set(F,te)}}function rD(N,u,x,C,P,R){for(const F of P){const U=Object.assign({},C);U.part=F;const K={type:"Unknown",id:u,properties:U},te={color:N.paint.get("model-color").evaluate(K,x),colorMix:N.paint.get("model-color-mix-intensity").evaluate(K,x),opacity:N.paint.get("model-opacity").evaluate(K,x),emissionStrength:N.paint.get("model-emissive-strength").evaluate(K,x)};R.set(F,te)}}function nD(N,u,x,C,P){let R=!1;for(const U of C)U.modelOpacity!==1&&(MS(U,N,u,P[U.modelIndex],sn.disabled,Cn.disabled),R=!0);for(const U of C)MS(U,N,u,P[U.modelIndex],U.modelOpacity!==1?N.stencilModeFor3D():sn.disabled,N.colorModeForRenderPass());R&&N.resetStencilClippingMasks();const F=Cn.additive;for(const U of x)MS(U,N,u,P[U.modelIndex],sn.disabled,U.isLightMesh?F:N.colorModeForRenderPass())}function aD(N,u,x){const C=u.updateZoomBasedPaintProperties(),P=function(R,F,U){let K,te,re,pe=R.terrain?R.terrain.exaggeration():0;if(R.terrain&&pe>0){const me=R.terrain,fe=me.findDEMTileFor(U);fe&&fe.dem?K=i.eF.create(me,U,fe):pe=0}if(pe===0&&(F.terrainElevationMin=0,F.terrainElevationMax=0),pe===F.validForExaggeration&&(pe===0||K&&K._demTile&&K._demTile.tileID===F.validForDEMTile.id&&K._dem._timestamp===F.validForDEMTile.timestamp))return!1;for(const me in F.instancesPerModel){const fe=F.instancesPerModel[me];for(let Ne=0;Nete&&(te=fe.max)}const re=i.aA(C.x,R,F)-C.x,pe=i.aA(C.y,U,K)-C.y,me=i.cf(te,u.center.lat)-C.z;return u._zoomFromMercatorZ(Math.sqrt(re*re+pe*pe+me*me))}function iD(N,u,x,C,P,R,F){const U=N.context,K=N.renderPass==="shadow",te=N.shadowRenderer,re=K&&te?te.getShadowPassDepthMode():new Cr(U.gl.LEQUAL,Cr.ReadWrite,N.depthRangeFor3D),pe=N.isTileAffectedByFog(R),me=N.transform.projection.name==="globe";if(x.meshes)for(const fe of x.meshes){const Ne=me?[]:["MODEL_POSITION_ON_GPU"],we=[];let Re,Le,Ze;const nt=!me&&C.instancedDataArray.length>20;nt&&Ne.push("INSTANCED_ARRAYS");const Xe=Rg(N,u.paint.get("model-cutoff-fade-range"));if(Xe.shouldRenderCutoff&&Ne.push("RENDER_CUTOFF"),K&&te)Re=N.getOrCreateProgram("modelDepth",{defines:Ne}),Le=GM(F.shadowTileMatrix,F.shadowTileMatrix,Float32Array.from(x.globalMatrix)),Ze=te.getShadowPassColorMode();else{CS(Ne,we,fe,N,u.paint.get("model-color-use-theme").constantOr("default")==="none"?null:u.lut),Re=N.getOrCreateProgram("model",{defines:Ne,overrideFog:pe});const gt=fe.material,jt=gt.pbrMetallicRoughness,ft=u.paint.get("model-opacity").constantOr(1),ht=u.paint.get("model-emissive-strength").constantOr(0);Le=iy(R.expandedProjMatrix,Float32Array.from(x.globalMatrix),new Float32Array(16),null,N,ft,jt.baseColorFactor,gt.emissiveFactor,jt.metallicFactor,jt.roughnessFactor,gt,ht,u,P),te&&(F.shadowUniformsInitialized?Re.setShadowUniformValues(U,te.getShadowUniformValues()):(te.setupShadows(R.toUnwrapped(),Re,"model-tile"),F.shadowUniformsInitialized=!0)),Ze=Xe.shouldRenderCutoff||ft<1||gt.alphaMode!=="OPAQUE"?Cn.alphaBlended:Cn.unblended}N.uploadCommonUniforms(U,Re,R.toUnwrapped(),null,Xe);const Mt=fe.material.doubleSided?tn.disabled:tn.backCCW;if(nt)we.push(C.instancedDataBuffer),Re.draw(N,U.gl.TRIANGLES,re,sn.disabled,Ze,Mt,Le,u.id,fe.vertexBuffer,fe.indexBuffer,fe.segments,u.paint,N.transform.zoom,void 0,we,C.instancedDataArray.length);else{const gt=K?"u_instance":"u_normal_matrix";for(let jt=0;jtK[1]?F:K,R[0]=x.max[0],F=i.aC(i.eG(),R,P),U=F[1]K[1]?F:K,R[1]=x.min[1],F=i.aC(i.eG(),R,P),U=F[1]K[1]?F:K;const te=i.aA(C[0],0,1),re=100*u.pixelsPerMeter*i.aA(C[1],0,1),pe=i.aA(C[2],0,1),me=i.eH(i.eG(),U,K,te),fe=Math.tan(.5*u.fovX),Ne=-me[2]*fe;if(re===0)return me[1]<-Math.abs(Ne)?pe:1;const we=(-Math.abs(Ne)-me[1])/re,Re=(Ze,nt,Xe)=>(1-Xe)*Ze+Xe*nt,Le=i.aA(Re(1,pe,we),pe,1);return Re(1,Le,i.aA((u.pitch-20)/20,0,1))}class oD{}class Gg{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(u,x,C){{const pe=this._storage.get(x.id);if(pe)return pe.lastUsedFrameIdx=u,pe.buf}const P=C.gl,R=P.getBufferParameter(P.ELEMENT_ARRAY_BUFFER,P.BUFFER_SIZE),F=new ArrayBuffer(R),U=new Int16Array(F);P.getBufferSubData(P.ELEMENT_ARRAY_BUFFER,0,new Int16Array(F));const K=new i.eJ;for(let pe=0;pe30&&(C.buf.destroy(),this._storage.delete(x))}destroy(){for(const[u,x]of this._storage)x.buf.destroy(),this._storage.delete(u)}}class J0{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const ev=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 bf{constructor(u){this.revealStart=11,this.revealRange=2}}const JM=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class eT{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(u,x){const C=u.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const F=new i.eK,U=new i.b0;F.emplaceBack(-1,-1),F.emplaceBack(1,-1),F.emplaceBack(1,1),F.emplaceBack(-1,1),U.emplaceBack(0,1,2),U.emplaceBack(0,2,3),this.vignetteVx=u.context.createVertexBuffer(F,JM.members),this.vignetteIdx=u.context.createIndexBuffer(U)}const P=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){u.uploadCommonUniforms(u.context,C);const F={u_vignetteShape:(R={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:R.vignetteColor};C.draw(u,u.context.gl.TRIANGLES,Cr.disabled,sn.disabled,Cn.alphaBlended,tn.disabled,F,"vignette",this.vignetteVx,this.vignetteIdx,P)}var R}}class tT{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(u,x){const C=u.getFreeCameraOptions().position,P=C.toAltitude(),R=C.toLngLat(),F=i.an(R.lng),U=i.an(R.lat),K=u.pixelsPerMeter/x,te=F*i.eM,re=i.eM*Math.log(Math.tan(Math.PI/4+U/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 pe=-this._offsetYPrev+re,me=-this._elevationPrev+P;this._accumulatedOffsetX+=(-this._offsetXPrev+te)*K,this._accumulatedOffsetY+=pe*K,this._accumulatedElevation+=me*K,this._offsetXPrev=te,this._offsetYPrev=re,this._elevationPrev=P}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function TS(N,u){return[-(N[0]-Math.floor(N[0]/u)*u),-(N[1]-Math.floor(N[1]/u)*u),-(N[2]-Math.floor(N[2]/u)*u)]}function sh(N){const u=i.eq(1323123451230),x=[];for(let C=0;C Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(u){const x=u.context;if(!this.particlesVx){const C=sh(this.particlesCount),P=new i.eN,R=new i.b0;let F=0;const U=i.eq(1323123451230);for(let K=0;KC)return;const P=ou(0,1,x.revealStart,x.revealStart+x.revealRange,C);if(!this.particlesVx||!this.particlesIdx)return;const R=structuredClone(this._params);let F=[-R.direction.x,R.direction.y,-100];i.aw(F,F);const U=structuredClone(this._vignetteParams);U.strength*=P,R.overrideStyleParameters||(R.intensity=u.style.rain.state.density,R.timeFactor=u.style.rain.state.intensity,R.color=structuredClone(u.style.rain.state.color),F=structuredClone(u.style.rain.state.direction),R.screenThinning.intensity=u.style.rain.state.centerThinning,R.dropletSizeX=u.style.rain.state.dropletSize[0],R.dropletSizeYScale=u.style.rain.state.dropletSize[1]/u.style.rain.state.dropletSize[0],R.distortionStrength=100*u.style.rain.state.distortionStrength,U.strength=1,U.color=structuredClone(u.style.rain.state.vignetteColor));const K=this.updateOnRender(u,R.timeFactor),te=u.context,re=te.gl,pe=u.transform;this.screenTexture&&this.screenTexture.size[0]===u.width&&this.screenTexture.size[1]===u.height||(this.screenTexture=new i.T(te,{width:u.width,height:u.height,data:null},re.RGBA8)),R.distortionStrength>0&&(te.activeTexture.set(re.TEXTURE0),this.screenTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE),re.copyTexSubImage2D(re.TEXTURE_2D,0,0,0,0,0,u.width,u.height));const me=u.getOrCreateProgram("rainParticle");u.uploadCommonUniforms(te,me),te.activeTexture.set(re.TEXTURE0),this.screenTexture.bind(re.LINEAR,re.CLAMP_TO_EDGE);const fe=[R.color.r,R.color.g,R.color.b,R.color.a],Ne=(we,Re)=>{const Le=TS(this._movement.getPosition(),we),Ze=R.dropletSizeX,nt=R.dropletSizeX*R.dropletSizeYScale,Xe=u.width/2,Mt=u.height/2,gt=ou(0,R.screenThinning.start,0,1,R.screenThinning.intensity),jt=ou(.001,R.screenThinning.range,0,1,R.screenThinning.intensity),ft=ou(0,R.screenThinning.particleOffset,0,1,R.screenThinning.intensity),ht=(At={modelview:K.modelviewMatrix,projection:K.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Le,velocityConeAperture:R.velocityConeAperture,velocity:R.velocity,boxSize:we,rainDropletSize:[Ze,nt],distortionStrength:R.distortionStrength,rainDirection:F,color:fe,screenSize:[pe.width,pe.height],thinningCenterPos:[Xe,Mt],thinningShape:[gt,jt,Math.pow(10,R.screenThinning.fadePower)],thinningAffectedRatio:R.screenThinning.affectedRatio,thinningParticleOffset:ft,shapeDirectionalPower:R.shapeDirPower,shapeNormalPower:R.shapeNormalPower,mode:Re?0:1},{u_modelview:Float32Array.from(At.modelview),u_projection:Float32Array.from(At.projection),u_time:At.time,u_cam_pos:At.camPos,u_texScreen:0,u_velocityConeAperture:At.velocityConeAperture,u_velocity:At.velocity,u_boxSize:At.boxSize,u_rainDropletSize:At.rainDropletSize,u_distortionStrength:At.distortionStrength,u_rainDirection:At.rainDirection,u_color:At.color,u_screenSize:At.screenSize,u_thinningCenterPos:At.thinningCenterPos,u_thinningShape:At.thinningShape,u_thinningAffectedRatio:At.thinningAffectedRatio,u_thinningParticleOffset:At.thinningParticleOffset,u_shapeDirectionalPower:At.shapeDirectionalPower,u_shapeNormalPower:At.shapeNormalPower,u_mode:At.mode});var At;const Ut=Math.round(R.intensity*this.particlesCount),Bt=i.bg.simpleSegment(0,0,4*Ut,2*Ut);me.draw(u,re.TRIANGLES,Cr.disabled,sn.disabled,Cn.alphaBlended,tn.disabled,ht,"rain_particles",this.particlesVx,this.particlesIdx,Bt)};R.distortionStrength>0&&Ne(R.boxSize,!0),Ne(R.boxSize,!1),this._vignette.draw(u,U)}}const sT=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 rT extends my{constructor(u){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 bf("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(u){const x=u.context;if(!this.particlesVx){const C=sh(this.particlesCount),P=new i.eO,R=new i.b0;let F=0;const U=i.eq(1323123451230);for(let K=0;KF)return;const U=ou(0,1,R.revealStart,R.revealStart+R.revealRange,F);P.strength*=U,x.overrideStyleParameters||(x.intensity=u.style.snow.state.density,x.timeFactor=u.style.snow.state.intensity,x.color=structuredClone(u.style.snow.state.color),C=structuredClone(u.style.snow.state.direction),x.screenThinning.intensity=u.style.snow.state.centerThinning,x.billboardSize=2.79*u.style.snow.state.flakeSize,P.strength=1,P.color=structuredClone(u.style.snow.state.vignetteColor));const K=this.updateOnRender(u,x.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const te=u.context,re=te.gl,pe=u.transform,me=u.getOrCreateProgram("snowParticle");u.uploadCommonUniforms(te,me),((fe,Ne,we)=>{const Re=TS(this._movement.getPosition(),fe),Le=pe.width/2,Ze=pe.height/2,nt=ou(0,we.screenThinning.start,0,1,we.screenThinning.intensity),Xe=ou(.001,we.screenThinning.range,0,1,we.screenThinning.intensity),Mt=ou(0,we.screenThinning.particleOffset,0,1,we.screenThinning.intensity),gt=(jt={modelview:K.modelviewMatrix,projection:K.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Re,velocityConeAperture:we.velocityConeAperture,velocity:we.velocity,horizontalOscillationRadius:we.horizontalOscillationRadius,horizontalOscillationRate:we.horizontalOscillationRate,boxSize:fe,billboardSize:1*we.billboardSize,simpleShapeParameters:[we.shapeFadeStart,we.shapeFadePower],screenSize:[pe.width,pe.height],thinningCenterPos:[Le,Ze],thinningShape:[nt,Xe,Math.pow(10,we.screenThinning.fadePower)],thinningAffectedRatio:we.screenThinning.affectedRatio,thinningParticleOffset:Mt,color:[we.color.r,we.color.g,we.color.b,we.color.a],direction:C},{u_modelview:Float32Array.from(jt.modelview),u_projection:Float32Array.from(jt.projection),u_time:jt.time,u_cam_pos:jt.camPos,u_velocityConeAperture:jt.velocityConeAperture,u_velocity:jt.velocity,u_horizontalOscillationRadius:jt.horizontalOscillationRadius,u_horizontalOscillationRate:jt.horizontalOscillationRate,u_boxSize:jt.boxSize,u_billboardSize:jt.billboardSize,u_simpleShapeParameters:jt.simpleShapeParameters,u_screenSize:jt.screenSize,u_thinningCenterPos:jt.thinningCenterPos,u_thinningShape:jt.thinningShape,u_thinningAffectedRatio:jt.thinningAffectedRatio,u_thinningParticleOffset:jt.thinningParticleOffset,u_particleColor:jt.color,u_direction:jt.direction});var jt;const ft=Math.round(we.intensity*this.particlesCount),ht=i.bg.simpleSegment(0,0,4*ft,2*ft);this.particlesVx&&this.particlesIdx&&me.draw(u,re.TRIANGLES,Cr.disabled,sn.disabled,Cn.alphaBlended,tn.disabled,gt,"snow_particles",this.particlesVx,this.particlesIdx,ht)})(x.boxSize,0,x),this._vignette.draw(u,P)}}const Kg={symbol:function(N,u,x,C,P){if(N.renderPass!=="translucent")return;const R=sn.disabled,F=N.colorModeForRenderPass(),U=x.layout.get("text-variable-anchor"),K=x.layout.get("text-size-scale-range"),te=i.aA(N.scaleFactor,K[0],K[1]);U&&function(me,fe,Ne,we,Re,Le,Ze,nt){const Xe=fe.transform,Mt=Re==="map",gt=Le==="map";for(const jt of me){const ft=we.getTile(jt),ht=ft.getBucket(Ne);if(!ht||!ht.text||!ht.text.segments.get().length)continue;const At=i.bK(ht.textSizeData,Xe.zoom,nt),Ut=Ks(jt,ht.getProjection(),Xe),Bt=Xe.calculatePixelsToTileUnitsMatrix(ft),ts=La(Ut,ft.tileID.canonical,gt,Mt,Xe,ht.getProjection(),Bt),rs=ht.hasIconTextFit()&&ht.hasIconData();At&&qr(ht,Mt,gt,Ze,Xe,ts,jt,Math.pow(2,Xe.zoom-ft.tileID.overscaledZ),At,rs)}}(C,N,x,u,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),P,te);const re=x.paint.get("icon-opacity").constantOr(1)!==0,pe=x.paint.get("text-opacity").constantOr(1)!==0;x.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(re||pe)?$_(N,u,x,C,R,F):(re&&$_(N,u,x,C,R,F,{onlyIcons:!0}),pe&&$_(N,u,x,C,R,F,{onlyText:!0})),u.map.showCollisionBoxes&&(xr(N,u,x,C,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),!0),xr(N,u,x,C,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),!1))},circle:function(N,u,x,C){if(N.renderPass!=="translucent")return;const P=x.paint.get("circle-opacity"),R=x.paint.get("circle-stroke-width"),F=x.paint.get("circle-stroke-opacity"),U=x.layout.get("circle-sort-key").constantOr(1)!==void 0,K=x.paint.get("circle-emissive-strength");if(P.constantOr(1)===0&&(R.constantOr(1)===0||F.constantOr(1)===0))return;const te=N.context,re=te.gl,pe=N.transform,me=!(!N.terrain||!N.terrain.enabled),fe=x.layout.get("circle-elevation-reference"),Ne=N.depthModeForSublayer(0,Cr.ReadOnly),we=new Cr(N.context.gl.LEQUAL,Cr.ReadOnly,N.depthRangeFor3D),Re=fe==="none"||me?Ne:we,Le=sn.disabled,Ze=N.colorModeForDrapableLayerRenderPass(K),nt=pe.projection.name==="globe",Xe=[i.aF(pe.center.lng),i.aJ(pe.center.lat)],Mt=[];for(let jt=0;jtjt.sortKey-ft.sortKey);const gt={useDepthForOcclusion:pe.depthOcclusionForSymbolsAndCircles};for(const jt of Mt){const{programConfiguration:ft,program:ht,layoutVertexBuffer:At,dynamicBuffers:Ut,indexBuffer:Bt,uniformValues:ts,tile:rs}=jt.state,ms=jt.segments;N.terrain&&N.terrain.setupElevationDraw(rs,ht,gt),N.uploadCommonUniforms(te,ht,rs.tileID.toUnwrapped()),ht.draw(N,re.TRIANGLES,Re,Le,Ze,tn.disabled,ts,x.id,At,Bt,ms,x.paint,pe.zoom,ft,Ut)}},heatmap:function(N,u,x,C){if(x.paint.get("heatmap-opacity")!==0)if(N.renderPass==="offscreen"){const P=N.context,R=P.gl,F=sn.disabled,U=new Cn([R.ONE,R.ONE,R.ONE,R.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(fe,Ne,we,Re){const Le=fe.gl,Ze=Ne.width*Re,nt=Ne.height*Re;fe.activeTexture.set(Le.TEXTURE1),fe.viewport.set([0,0,Ze,nt]);let Xe=we.heatmapFbo;if(!Xe||Xe&&(Xe.width!==Ze||Xe.height!==nt)){Xe&&Xe.destroy();const Mt=Le.createTexture();Le.bindTexture(Le.TEXTURE_2D,Mt),Le.texParameteri(Le.TEXTURE_2D,Le.TEXTURE_WRAP_S,Le.CLAMP_TO_EDGE),Le.texParameteri(Le.TEXTURE_2D,Le.TEXTURE_WRAP_T,Le.CLAMP_TO_EDGE),Le.texParameteri(Le.TEXTURE_2D,Le.TEXTURE_MIN_FILTER,Le.LINEAR),Le.texParameteri(Le.TEXTURE_2D,Le.TEXTURE_MAG_FILTER,Le.LINEAR),Xe=we.heatmapFbo=fe.createFramebuffer(Ze,nt,1,null),function(gt,jt,ft,ht,At,Ut){const Bt=gt.gl;Bt.texImage2D(Bt.TEXTURE_2D,0,gt.extRenderToTextureHalfFloat?Bt.RGBA16F:Bt.RGBA,At,Ut,0,Bt.RGBA,gt.extRenderToTextureHalfFloat?Bt.HALF_FLOAT:Bt.UNSIGNED_BYTE,null),ht.colorAttachment0.set(ft)}(fe,0,Mt,Xe,Ze,nt)}else Le.bindTexture(Le.TEXTURE_2D,Xe.colorAttachment0.get()),fe.bindFramebuffer.set(Xe.framebuffer)})(P,N,x,N.transform.projection.name==="globe"?.5:.25),P.clear({color:i.ao.transparent});const K=N.transform,te=K.projection.name==="globe",re=te?["PROJECTION_GLOBE_VIEW"]:[],pe=te?tn.frontCCW:tn.disabled,me=[i.aF(K.center.lng),i.aJ(K.center.lat)];for(let fe=0;fe({u_image:0,u_color_ramp:1,u_opacity:pe.paint.get("heatmap-opacity")}))(0,R),R.id,P.viewportBuffer,P.quadTriangleIndexBuffer,P.viewportSegments,R.paint,P.transform.zoom)}(N,x))},line:function(N,u,x,C){if(N.renderPass!=="translucent")return;const P=x.paint.get("line-opacity"),R=x.paint.get("line-width");if(P.constantOr(1)===0||R.constantOr(1)===0)return;const F=x.paint.get("line-emissive-strength").isConstant(),U=x.paint.get("line-emissive-strength").constantOr(0),K=x.paint.get("line-occlusion-opacity"),te=x.layout.get("line-elevation-reference"),re=x.layout.get("line-width-unit")==="meters",pe=te==="sea",me=!(!N.terrain||!N.terrain.enabled),fe=N.context,Ne=fe.gl;if(x.hasElevatedBuckets&&N.transform.projection.name==="globe")return;const we=x.layout.get("line-cross-slope"),Re=we!==void 0,Le=we<1,Ze=N.colorModeForDrapableLayerRenderPass(F?U:null),nt=N.terrain&&N.terrain.renderingToTexture,Xe=nt?1:i.o.devicePixelRatio,Mt=x.paint.get("line-dasharray"),gt=Mt.constantOr(1),jt=x.layout.get("line-cap"),ft=Mt.constantOr(null),ht=jt.constantOr(null),At=x.paint.get("line-pattern"),Ut=At.constantOr(1),Bt=x.paint.get("line-pattern-cross-fade"),ts=At.constantOr(null),rs=x.paint.get("line-opacity").constantOr(1);let ms=!Ut&&rs!==1||N.depthOcclusion&&K>0&&K<1;const Ds=x.paint.get("line-gradient"),Yt=Ut?"linePattern":"line",Pt=i.e2(x);let is;if(nt&&N.terrain&&N.terrain.clipOrMaskOverlapStencilType()&&(ms=!1),K!==0&&N.depthOcclusion){const dr=x.paint._values["line-opacity"];dr&&dr.value&&dr.value.kind==="constant"?is=dr.value:i.w(`Occlusion opacity for layer ${x.id} is supported only when line-opacity isn't data-driven.`)}R.value.kind!=="constant"&&R.value.isLineProgressConstant===!1&&Pt.push("VARIABLE_LINE_WIDTH"),nt&&(N.emissiveMode!=="dual-source-blending"||F?N.emissiveMode==="mrt-fallback"&&Pt.push("USE_MRT1"):Pt.push("DUAL_SOURCE_BLENDING"));const es=(dr,qs,Os,wr,yr,ir)=>{for(const hr of dr){const Fr=u.getTile(hr);if(Ut&&!Fr.patternsLoaded())continue;const _n=Fr.getBucket(x);if(!_n||_n.elevationType!=="none"&&!yr||_n.elevationType==="none"&&yr)continue;N.prepareDrawTile();const ia=[...qs],Oa=N.shadowRenderer,Nr=_n.elevationType==="road"&&!!Oa&&Oa.enabled;let Ca=[0,0,0];if(Nr){const Tn=N.style.directionalLight,Ei=N.style.ambientLight;Tn&&Ei&&(Ca=ff(N.style,Tn,Ei)),ia.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const un=_n.programConfigurations.get(x.id);let Ba=!1;if(ts&&Fr.imageAtlas){const Tn=i.e3.from(ts),Ei=Tn.getPrimary().scaleSelf(Xe).toString(),jo=Fr.imageAtlas.patternPositions.get(Ei),no=Tn.getSecondary(),pi=no?Fr.imageAtlas.patternPositions.get(no.scaleSelf(Xe).toString()):null;Ba=!!jo&&!!pi,jo&&un.setConstantPatternPositions(jo,pi)}Bt>0&&(Ba||un.getPatternTransitionVertexBuffer("line-pattern"))&&ia.push("LINE_PATTERN_TRANSITION");const ii=N.isTileAffectedByFog(hr),Ja=N.getOrCreateProgram(Yt,{config:un,defines:ia,overrideFog:ii});if(!Ut&&ft&&ht&&Fr.lineAtlas){const Tn=Fr.lineAtlas.getDash(ft,ht);Tn&&un.setConstantPatternPositions(Tn)}Nr&&Oa.setupShadows(Fr.tileID.toUnwrapped(),Ja,"vector-tile");let[Na,Mn]=x.paint.get("line-trim-offset");(ht==="round"||ht==="square")&&Na!==Mn&&(Na===0&&(Na-=1),Mn===1&&(Mn+=1));const Fa=nt?hr.projMatrix:null,co=re?1/_n.tileToMeter/i.ay(Fr,1,N.transform.zoom):1,$i=re?1/_n.tileToMeter/i.ay(Fr,1,Math.floor(N.transform.zoom)):1,$a=Ut?i.e4(N,Fr,x,Fa,Xe,co,$i,[Na,Mn],Ca,Bt):i.e5(N,Fr,x,Fa,_n.lineClipsArray.length,Xe,co,$i,[Na,Mn],Ca);if(Ds){const Tn=_n.gradients[x.id];let Ei=Tn.texture;if(x.gradientVersion!==Tn.version){let jo=256;if(x.stepInterpolant){const no=u.getSource().maxzoom,pi=hr.canonical.z===no?Math.ceil(1<{is!=null&&(is.value=rs*K),Ja.draw(N,Ne.TRIANGLES,Os,Tn,Ze,tn.disabled,$a,x.id,_n.layoutVertexBuffer,_n.indexBuffer,_n.segments,x.paint,N.transform.zoom,un,[_n.layoutVertexBuffer2,_n.patternVertexBuffer,_n.zOffsetVertexBuffer]),is!=null&&(is.value=rs)};if(ms&&!yr){const Tn=N.stencilModeForClipping(hr).ref;Tn===0&&nt&&fe.clear({stencil:0});const Ei={func:Ne.EQUAL,mask:255};$a.u_alpha_discard_threshold=.8,ya(new sn(Ei,Tn,255,Ne.KEEP,Ne.KEEP,Ne.INVERT)),$a.u_alpha_discard_threshold=0,ya(new sn(Ei,Tn,255,Ne.KEEP,Ne.KEEP,Ne.KEEP))}else $a.u_alpha_discard_threshold=ms&&yr&&ir?.8:0,ya(yr?wr:N.stencilModeForClipping(hr))}};let ks=N.depthModeForSublayer(0,Cr.ReadOnly);const Gs=new Cr(N.depthOcclusion?Ne.GREATER:Ne.LEQUAL,Cr.ReadOnly,N.depthRangeFor3D);if(x.hasNonElevatedBuckets){const dr=!nt&&N.terrain;K!==0&&dr?i.w(`Occlusion opacity for layer ${x.id} is supported on terrain only if the layer has line-z-offset enabled.`):dr?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${x.id}.`):es(C,Pt,ks,sn.disabled,!1,!0)}if(x.hasElevatedBuckets){te==="hd-road-markup"?me||(ks=Gs,Pt.push("ELEVATED_ROADS")):(Pt.push("ELEVATED"),ks=Gs,Re&&Pt.push(Le?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),pe&&Pt.push("ELEVATION_REFERENCE_SEA"));const dr=ms?N.stencilModeFor3D():sn.disabled;N.forceTerrainMode=!0,es(C,Pt,ks,dr,!0,!0),ms&&es(C,Pt,ks,dr,!0,!1),N.forceTerrainMode=!1}ms&&(N.resetStencilClippingMasks(),nt&&fe.clear({stencil:0})),K===0||N.depthOcclusion||nt||N.layersWithOcclusionOpacity.push(N.currentLayer)},fill:function(N,u,x,C){const P=x.paint.get("fill-color"),R=x.paint.get("fill-opacity");if(R.constantOr(1)===0)return;const F=x.paint.get("fill-emissive-strength"),U=N.colorModeForDrapableLayerRenderPass(F),K=x.paint.get("fill-pattern"),te=N.opaquePassEnabledForLayer()&&!K.constantOr(1)&&P.constantOr(i.ao.transparent).a===1&&R.constantOr(0)===1?"opaque":"translucent";let re="none";x.layout.get("fill-elevation-reference")!=="none"?re="road":x.paint.get("fill-z-offset").constantOr(1)!==0&&(re="offset");const pe=!(!N.terrain||!N.terrain.enabled),me={painter:N,sourceCache:u,layer:x,coords:C,colorMode:U,elevationType:re,terrainEnabled:pe,pass:te};if(N.renderPass==="shadow")return void(N.shadowRenderer&&re==="road"&&!pe&&function(Ne){const{painter:we,sourceCache:Re,layer:Le,coords:Ze}=Ne,nt=we.context.gl,Xe=Ne.painter.shadowRenderer;for(const Mt of Ze){const gt=Re.getTile(Mt),jt=gt.getBucket(Le);if(!jt)continue;const ft=jt.elevatedStructures;if(!ft||!ft.shadowCasterSegments||ft.shadowCasterSegments.segments[0].primitiveLength===0)continue;we.prepareDrawTile();const ht=jt.bufferData.programConfigurations.get(Le.id),At=we.isTileAffectedByFog(Mt),Ut=we.getOrCreateProgram("elevatedStructuresDepth",{config:ht,overrideFog:At}),Bt=Xe.calculateShadowPassMatrixFromTile(gt.tileID.toUnwrapped());we.uploadCommonUniforms(we.context,Ut,Mt.toUnwrapped());const ts={u_matrix:Bt,u_depth_bias:0};Ut.draw(we,nt.TRIANGLES,Xe.getShadowPassDepthMode(),sn.disabled,Xe.getShadowPassColorMode(),tn.disabled,ts,Le.id,ft.vertexBuffer,ft.indexBuffer,ft.shadowCasterSegments,Le.paint,we.transform.zoom,ht)}}(me));const fe=N.emissiveMode==="mrt-fallback";if(re!=="offset"){if(yS(me,!1,fe),re==="road"){const Ne=!pe&&N.renderPass==="translucent";Ne&&xS(N,u,x,C,"geometry"),yS(me,!0,fe,sn.disabled),Ne&&function(we){const{painter:Re,sourceCache:Le,layer:Ze,coords:nt,colorMode:Xe}=we,Mt=Re.context.gl,gt=we.painter.shadowRenderer,jt=!!gt&>.enabled,ft=new Cr(Re.context.gl.LEQUAL,Cr.ReadOnly,Re.depthRangeFor3D);let ht=[0,0,0];if(jt){const Ut=Re.style.directionalLight,Bt=Re.style.ambientLight;Ut&&Bt&&(ht=ff(Re.style,Ut,Bt))}const At=Ut=>{for(const Bt of nt){const ts=Le.getTile(Bt),rs=ts.getBucket(Ze);if(!rs)continue;const ms=rs.elevatedStructures;if(!ms)continue;let Ds,Yt;if(Ut?(Ds=ms.renderableBridgeSegments,Yt=ms.bridgeProgramConfigurations.get(Ze.id)):(Ds=ms.renderableTunnelSegments,Yt=ms.tunnelProgramConfigurations.get(Ze.id)),!Ds||Ds.segments[0].primitiveLength===0)continue;Yt.updatePaintBuffers(),Re.prepareDrawTile();const Pt=Re.isTileAffectedByFog(Bt),is=[];jt&&is.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const es=Re.getOrCreateProgram("elevatedStructures",{config:Yt,overrideFog:Pt,defines:is}),ks=Re.translatePosMatrix(Bt.projMatrix,ts,Ze.paint.get("fill-translate"),Ze.paint.get("fill-translate-anchor"));jt&>.setupShadows(ts.tileID.toUnwrapped(),es,"vector-tile");const Gs=qg(ks,ht);Re.uploadCommonUniforms(Re.context,es,Bt.toUnwrapped()),es.draw(Re,Mt.TRIANGLES,ft,sn.disabled,Xe,tn.backCCW,Gs,Ze.id,ms.vertexBuffer,ms.indexBuffer,Ds,Ze.paint,Re.transform.zoom,Yt,[ms.vertexBufferNormal])}};At(!0),At(!1)}(me)}}else yS(me,!1,fe,N.stencilModeFor3D())},"fill-extrusion":function(N,u,x,C){const P=x.paint.get("fill-extrusion-opacity"),R=N.context,F=R.gl,U=N.terrain,K=U&&U.renderingToTexture;if(P===0)return;const te=N.emissiveMode==="mrt-fallback",re=N.conflationActive&&N.style.isLayerClipped(x,u.getSource()),pe=N.style.order.indexOf(x.fqid);if(re&&function(me,fe,Ne,we,Re){for(const Le of we){const Ze=fe.getTile(Le).getBucket(Ne);Ze&&(Ze.updateReplacement(Le,me.replacementSource,Re),Ze.uploadCentroid(me.context))}}(N,u,x,C,pe),U||re)for(const me of C){const fe=u.getTile(me).getBucket(x);fe&&dce(N.context,u,me,fe,x,U,re)}if(N.renderPass==="shadow"&&N.shadowRenderer){const me=N.shadowRenderer;if(U&&P<.65&&x._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const fe=me.getShadowPassDepthMode(),Ne=me.getShadowPassColorMode();vS(N,u,x,C,fe,sn.disabled,Ne,re)}else if(N.renderPass==="translucent"){const me=!x.paint.get("fill-extrusion-pattern").constantOr(1),fe=x.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!K&&fe.a!==0){const Ne=new Cr(N.context.gl.LEQUAL,Cr.ReadWrite,N.depthRangeFor3D);P===1&&me?vS(N,u,x,C,Ne,sn.disabled,Cn.unblended,re):(vS(N,u,x,C,Ne,sn.disabled,Cn.disabled,re),vS(N,u,x,C,Ne,N.stencilModeFor3D(),N.colorModeForRenderPass(),re),N.resetStencilClippingMasks())}if(N.style.enable3dLights()&&me&&(!U&&N.transform.projection.name!=="globe"||K)){const Ne=x.paint.get("fill-extrusion-opacity"),we=x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Re=x.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Le=x.paint.get("fill-extrusion-flood-light-intensity"),Ze=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",nt=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Ze?null:x.lut).toArray01().slice(0,3),Xe=we>0&&Re>0,Mt=Le>0,gt=(ht,At,Ut)=>(1-Ut)*ht+Ut*At,jt=new YM;jt.translate=x.paint.get("fill-extrusion-translate"),jt.translateAnchor=x.paint.get("fill-extrusion-translate-anchor"),jt.edgeRadius=x.layout.get("fill-extrusion-edge-radius"),jt.cutoffFadeRange=x.paint.get("fill-extrusion-cutoff-fade-range");const ft=ht=>{const At=N.depthModeForSublayer(1,Cr.ReadOnly,F.LEQUAL,!0),Ut=x.paint.get(ht?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Bt=gt(.1,3,Ut),ts=N._showOverdrawInspector;if(!ts){const rs=new sn({func:F.ALWAYS,mask:255},255,255,F.KEEP,F.KEEP,F.REPLACE),ms=new Cn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!1,!1,!1,!0],F.MIN);yf(jt,N,u,x,C,At,rs,ms,tn.disabled,ht,"sdf",Ne,we,Re,Le,nt,Bt,re,!1)}{const rs=ts?sn.disabled:new sn({func:F.EQUAL,mask:255},255,255,F.KEEP,F.DECR,F.DECR),ms=ts?N.colorModeForRenderPass():new Cn([F.ONE_MINUS_DST_ALPHA,F.DST_ALPHA,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);yf(jt,N,u,x,C,At,rs,ms,tn.disabled,ht,"color",Ne,we,Re,Le,nt,Bt,re,!1)}};if(K){const ht=()=>{const Ut=U.drapeBufferSize[0],Bt=U.drapeBufferSize[1];let ts=U.framebufferCopyTexture;return ts&&(!ts||ts.size[0]===Ut&&ts.size[1]===Bt)||(ts&&ts.destroy(),ts=U.framebufferCopyTexture=new i.T(R,new i.q({width:Ut,height:Bt}),F.RGBA8)),ts.bind(F.LINEAR,F.CLAMP_TO_EDGE),F.copyTexSubImage2D(F.TEXTURE_2D,0,0,0,0,0,Ut,Bt),ts},At=(Ut,Bt,ts)=>{const rs=N.depthModeForSublayer(1,Cr.ReadOnly,F.LEQUAL,!1),ms=x.paint.get(Ut?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ds=gt(.1,3,ms);{const Yt=new Cn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!1,!1,!1,!0]);yf(jt,N,u,x,C,rs,sn.disabled,Yt,tn.disabled,Ut,"clear",Ne,we,Re,Le,nt,Ds,re,Bt)}{const Yt=new sn({func:F.ALWAYS,mask:255},255,255,F.KEEP,F.KEEP,F.REPLACE),Pt=new Cn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!1,!1,!1,!0],F.MIN);yf(jt,N,u,x,C,rs,Yt,Pt,tn.disabled,Ut,"sdf",Ne,we,Re,Le,nt,Ds,re,Bt)}te&&!Ut&&(ts=ht());{const Yt=Ut?F.ZERO:F.ONE_MINUS_DST_ALPHA,Pt=new sn({func:F.EQUAL,mask:255},255,255,F.KEEP,F.DECR,F.DECR),is=new Cn([Yt,F.DST_ALPHA,F.ONE_MINUS_DST_ALPHA,F.ZERO],i.ao.transparent,[!0,!0,!0,!0]);yf(jt,N,u,x,C,rs,Pt,is,tn.disabled,Ut,"color",Ne,we,Re,Le,nt,Ds,re,Bt)}if(!te||Ut){const Yt=new Cn([F.ONE,F.ONE,F.ONE,Ut?F.ZERO:F.ONE],i.ao.transparent,[!1,!1,!1,!0],Ut?F.FUNC_ADD:F.MAX);yf(jt,N,u,x,C,rs,sn.disabled,Yt,tn.disabled,Ut,"clear",Ne,we,Re,Le,nt,Ds,re,Bt,ts)}else{F.drawBuffers([F.NONE,F.COLOR_ATTACHMENT1]);const Yt=new sn({func:F.EQUAL,mask:255},254,255,F.KEEP,F.DECR,F.DECR),Pt=new Cn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!1,!1,!1],F.MAX);yf(jt,N,u,x,C,rs,Yt,Pt,tn.disabled,Ut,"emissive",Ne,we,Re,Le,nt,Ds,re,Bt,ts),F.drawBuffers([F.COLOR_ATTACHMENT0])}};if(Xe||Mt){let Ut;N.prepareDrawTile(),te&&!Xe||(Ut=ht()),Xe&&At(!0,!1,Ut),Mt&&At(!1,!0,Ut)}}else Xe&&ft(!0),Mt&&ft(!1),(Xe||Mt)&&N.resetStencilClippingMasks()}}},building:function(N,u,x,C){N.currentLayer0&&R>0,te=!0;const re=x.paint.get("building-vertical-scale");if(re<=0)return;N.shadowRenderer||(te=!1);const pe=N.conflationActive&&N.style.isLayerClipped(x,u.getSource()),me=N.style.order.indexOf(x.fqid);if(function(fe,Ne,we,Re,Le,Ze){for(const nt of Ze){const Xe=Ne.getTile(nt).getBucket(we);Xe&&(Le&&Xe.updateReplacement(nt,fe.replacementSource,Re),Xe.uploadUpdatedIndexBuffer(fe.context))}}(N,u,x,me,pe,C),function(fe,Ne,we,Re){for(const Le of Re){const Ze=Ne.getTile(Le).getBucket(we);Ze&&Ze.needsEvaluation()&&Ze.uploadUpdatedColorBuffer(fe.context)}}(N,u,x,C),x.resetLayerRenderingStats(N),N.shadowRenderer&&(N.shadowRenderer.useNormalOffset=!0),N.renderPass==="shadow"&&N.shadowRenderer){const fe=N.shadowRenderer,Ne=[],we=fe.getShadowPassDepthMode();U_({painter:N,source:u,layer:x,coords:C,defines:Ne,blendMode:fe.getShadowPassColorMode(),depthMode:we,opacity:U,verticalScale:re,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(N.renderPass==="translucent"){let fe=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];te&&(fe=fe.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),N.shadowRenderer&&N.shadowRenderer.useNormalOffset&&(fe=fe.concat("NORMAL_OFFSET"));const Ne=x.paint.get("building-facade-emissive-chance"),we=x.paint.get("building-ambient-occlusion-intensity"),Re=x.paint.get("building-flood-light-intensity"),Le=x.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",Ze=x.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Le?null:x.lut).toArray01().slice(0,3),nt=x.paint.get("building-flood-light-ground-attenuation"),Xe=Re>0,Mt=new Cr(N.context.gl.LEQUAL,Cr.ReadWrite,N.depthRangeFor3D);U<1&&U_({painter:N,source:u,layer:x,coords:C,defines:fe,blendMode:Cn.disabled,depthMode:Mt,opacity:U,verticalScale:re,facadeEmissiveChance:Ne,facadeAOIntensity:we,floodLightIntensity:Re,floodLightColor:Ze,depthOnly:!0});const gt=N.colorModeForRenderPass();U_({painter:N,source:u,layer:x,coords:C,defines:fe,blendMode:gt,depthMode:Mt,opacity:U,verticalScale:re,facadeEmissiveChance:Ne,facadeAOIntensity:we,floodLightIntensity:Re,floodLightColor:Ze}),K&&_S(N,u,x,C,!0,U,P,R,Re,Ze,F,pe),Xe&&_S(N,u,x,C,!1,U,P,R,Re,Ze,nt,pe)}else if(N.renderPass==="light-beam"){const fe=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Ne=new Cr(N.context.gl.LEQUAL,Cr.ReadOnly,N.depthRangeFor3D);U_({painter:N,source:u,layer:x,coords:C,defines:fe,blendMode:Cn.alphaBlended,depthMode:Ne,opacity:U,verticalScale:re,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}N.shadowRenderer&&(N.shadowRenderer.useNormalOffset=!1),N.resetStencilClippingMasks()},hillshade:function(N,u,x,C){if(N.renderPass!=="offscreen"&&N.renderPass!=="translucent"||N.style.disableElevatedTerrain)return;const P=N.context,R=N.terrain&&N.terrain.renderingToTexture,[F,U]=N.renderPass!=="translucent"||R?[{},C]:N.stencilConfigForOverlap(C);for(const K of U){const te=u.getTile(K);if(te.needsHillshadePrepare&&N.renderPass==="offscreen")ece(N,te,x);else if(N.renderPass==="translucent"){const re=N.depthModeForSublayer(0,Cr.ReadOnly),pe=x.paint.get("hillshade-emissive-strength"),me=N.colorModeForDrapableLayerRenderPass(pe),fe=R&&N.terrain?N.terrain.stencilModeForRTTOverlap(K):F[K.overscaledZ];Jle(N,K,te,x,re,fe,me)}}P.viewport.set([0,0,N.width,N.height]),N.resetStencilClippingMasks()},raster:function(N,u,x,C,P,R){if(N.renderPass!=="translucent"||x.paint.get("raster-opacity")===0)return;const F=N.transform.projection.name==="globe",U=x.paint.get("raster-elevation")!==0,K=U&&F;if(N.renderElevatedRasterBackface&&!K)return;const te=N.context,re=te.gl,pe=u.getSource(),me=function(gt,jt,ft,ht,At){const Ut=jt.paint.get("raster-color"),Bt=gt.type==="raster-array",ts=[],rs=jt.paint.get("raster-resampling"),ms=jt.paint.get("raster-color-mix");let Ds=jt.paint.get("raster-color-range");const Yt=[ms[0],ms[1],ms[2],0],Pt=ms[3];let is=rs==="nearest"?ht.NEAREST:ht.LINEAR;if(Bt&&(ts.push("RASTER_ARRAY"),Ut||ts.push("RASTER_COLOR"),rs==="linear"&&ts.push("RASTER_ARRAY_LINEAR"),is=ht.NEAREST,!Ds&>.rasterLayers)){const es=gt.rasterLayers.find(({id:ks})=>ks===jt.sourceLayer);es&&es.fields&&es.fields.range&&(Ds=es.fields.range)}if(Ds=Ds||[0,1],Ut){ts.push("RASTER_COLOR"),ft.activeTexture.set(ht.TEXTURE2),jt.updateColorRamp(Ds);let es=jt.colorRampTexture;es||(es=jt.colorRampTexture=new i.T(ft,jt.colorRamp,ht.RGBA8)),es.bind(ht.LINEAR,ht.CLAMP_TO_EDGE)}return At&&ts.push("USE_MRT1"),{mix:Yt,range:Ds,offset:Pt,defines:ts,resampling:is}}(pe,x,te,re,N.terrain&&N.terrain.renderingToTexture&&N.emissiveMode==="mrt-fallback");if(pe instanceof i.aU&&!C.length&&!F)return;const fe=x.paint.get("raster-emissive-strength"),Ne=N.colorModeForDrapableLayerRenderPass(fe),we=N.terrain&&N.terrain.renderingToTexture,Re=!N.options.moving,Le=x.paint.get("raster-resampling")==="nearest"?re.NEAREST:re.LINEAR;if(pe instanceof i.aU&&!C.length&&(pe.onNorthPole||pe.onSouthPole)){const gt=U?N.stencilModeFor3D():sn.disabled;return void q_(!!pe.onNorthPole,null,N,u,x,fe,me,tn.disabled,gt)}if(!C.length)return;const[Ze,nt]=pe instanceof i.aU||we?[{},C]:N.stencilConfigForOverlap(C),Xe=nt[nt.length-1].overscaledZ;K&&me.defines.push("PROJECTION_GLOBE_VIEW"),U&&me.defines.push("RENDER_CUTOFF");const Mt=(gt,jt,ft)=>{for(const ht of gt){const At=ht.toUnwrapped(),Ut=u.getTile(ht);if(we&&(!Ut||!Ut.hasData()))continue;te.activeTexture.set(re.TEXTURE0);const Bt=_f(Ut,pe,x,me);if(!Bt||!Bt.texture)continue;const{texture:ts,mix:rs,offset:ms,tileSize:Ds,buffer:Yt}=Bt;let Pt,is;we?(Pt=Cr.disabled,is=ht.projMatrix):U?(Pt=new Cr(re.LEQUAL,Cr.ReadWrite,N.depthRangeFor3D),is=F?Float32Array.from(N.transform.expandedFarZProjMatrix):N.transform.calculateProjMatrix(At,Re)):(Pt=N.depthModeForSublayer(ht.overscaledZ-Xe,x.paint.get("raster-opacity")===1?Cr.ReadWrite:Cr.ReadOnly,re.LESS),is=N.transform.calculateProjMatrix(At,Re));const es=N.terrain&&we?N.terrain.stencilModeForRTTOverlap(ht):Ze[ht.overscaledZ],ks=R?0:x.paint.get("raster-fade-duration");Ut.registerFadeDuration(ks);const Gs=u.findLoadedParent(ht,0),dr=R_(Ut,Gs,u,N.transform,ks);let qs,Os;!dr.isFading&&Ut.refreshedUponExpiration&&(Ut.refreshedUponExpiration=!1),N.terrain&&N.terrain.prepareDrawTile(),te.activeTexture.set(re.TEXTURE0),ts.bind(Le,re.CLAMP_TO_EDGE),te.activeTexture.set(re.TEXTURE1),Gs?(Gs.texture&&Gs.texture.bind(Le,re.CLAMP_TO_EDGE),qs=Math.pow(2,Gs.tileID.overscaledZ-Ut.tileID.overscaledZ),Os=[Ut.tileID.canonical.x*qs%1,Ut.tileID.canonical.y*qs%1]):ts.bind(Le,re.CLAMP_TO_EDGE),"useMipmap"in ts&&te.extTextureFilterAnisotropic&&N.transform.pitch>20&&re.texParameterf(re.TEXTURE_2D,te.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,te.extTextureFilterAnisotropicMax);const wr=N.transform;let yr;const ir=U?KL(wr):[0,0,0,0];let hr,Fr,_n,ia,Oa,Nr=0;if(K&&pe instanceof i.aU&&pe.coordinates.length>3)hr=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Fr=Float32Array.from(wr.globeMatrix),_n=Float32Array.from(i.dF(wr)),ia=[i.aF(wr.center.lng),i.aJ(wr.center.lat)],yr=pe.elevatedGlobePerspectiveTransform,Oa=pe.elevatedGlobeGridMatrix||new Float32Array(9);else if(K){const ii=i.dG(ht.canonical);Nr=i.dH(ii.getCenter().lat),hr=Float32Array.from(i.bk(i.dJ(ht.canonical))),Fr=Float32Array.from(wr.globeMatrix),_n=Float32Array.from(i.dF(wr)),ia=[i.aF(wr.center.lng),i.aJ(wr.center.lat)],yr=[0,0],Oa=Float32Array.from(i.dI(ht.canonical,ii,Nr,wr.worldSize/wr._pixelsPerMercatorPixel))}else yr=pe instanceof i.aU?pe.perspectiveTransform:[0,0],hr=new Float32Array(16),Fr=new Float32Array(9),_n=new Float32Array(16),ia=[0,0],Oa=new Float32Array(9);const Ca=$L(is,hr,Fr,_n,Oa,Os||[0,0],i.aj(N.transform.zoom),ia,ir,qs||1,dr,x,yr,U?x.paint.get("raster-elevation"):0,2,rs,ms,me.range,Ds,Yt,fe),un=N.isTileAffectedByFog(ht),Ba=N.getOrCreateProgram("raster",{defines:me.defines,overrideFog:un});if(N.uploadCommonUniforms(te,Ba,At),pe instanceof i.aU){const ii=pe.elevatedGlobeVertexBuffer,Ja=pe.elevatedGlobeIndexBuffer;if(we||!F)pe.boundsBuffer&&pe.boundsSegments&&Ba.draw(N,re.TRIANGLES,Pt,sn.disabled,Ne,tn.disabled,Ca,x.id,pe.boundsBuffer,N.quadTriangleIndexBuffer,pe.boundsSegments);else if(ii&&Ja){const Na=wr.zoom<=i.c_?pe.elevatedGlobeSegments:pe.getSegmentsForLongitude(wr.center.lng);Na&&Ba.draw(N,re.TRIANGLES,Pt,sn.disabled,Ne,jt,Ca,x.id,ii,Ja,Na)}}else if(K){Pt=new Cr(re.LEQUAL,Cr.ReadOnly,N.depthRangeFor3D);const ii=N.globeSharedBuffers;if(ii){const[Ja,Na,Mn]=ii.getGridBuffers(Nr,!1);Ba.draw(N,re.TRIANGLES,Pt,ft||es,N.colorModeForRenderPass(),jt,Ca,x.id,Ja,Na,Mn)}}else{const{tileBoundsBuffer:ii,tileBoundsIndexBuffer:Ja,tileBoundsSegments:Na}=N.getTileBoundsBuffers(Ut);Ba.draw(N,re.TRIANGLES,Pt,es,Ne,tn.disabled,Ca,x.id,ii,Ja,Na)}}if(!(pe instanceof i.aU)&&K)for(const ht of gt){const At=ht.canonical.y===(1<>>16,2654435769),((ht=Math.imul(ht^ht>>>16,2654435769))>>>0)/4294967296},ft=1/1.1;for(let ht=0;hti.e9[es](ts));Yt.push(ts);const Pt=ts.canonical.x,is=ts.canonical.y;for(const es of Yt){const ks=Xe.getTile(At?es.wrapped():es);if(!ks)continue;const Gs=ks.rasterParticleState;if(!Gs)continue;const dr=es.canonical.x+(1<jt.tileID)),fe&&(te.activeTexture.set(re.TEXTURE0),N.imageManager.bind(N.context,x.scope));const gt=[];if(N.terrain&&N.terrain.renderingToTexture&&N.emissiveMode==="mrt-fallback"&>.push("USE_MRT1"),K){const jt=N.getOrCreateProgram(nt,{overrideFog:!1,overrideRtt:!0,defines:gt}),ft=new Float32Array(i.bA([])),ht=new i.aQ(0,0,0,0,0),At=fe?Hg(ft,U,F,N,0,x.scope,Ne,K,{tileID:ht,tileSize:me}):z_(ft,U,F,P.toPremultipliedRenderColor(R?null:x.lut));jt.draw(N,re.TRIANGLES,Le,Re,Ze,tn.disabled,At,x.id,N.viewportBuffer,N.quadTriangleIndexBuffer,N.viewportSegments)}else for(const jt of Mt){const ft=N.isTileAffectedByFog(jt),ht=N.getOrCreateProgram(nt,{overrideFog:ft,defines:gt}),At=jt.toUnwrapped(),Ut=C?jt.projMatrix:N.transform.calculateProjMatrix(At);N.prepareDrawTile();const Bt=u?u.getTile(jt):Xe?Xe[jt.key]:new uf(jt,me,pe.zoom,N),ts=fe?Hg(Ut,U,F,N,0,x.scope,Ne,K,{tileID:jt,tileSize:me}):z_(Ut,U,F,P.toPremultipliedRenderColor(R?null:x.lut));N.uploadCommonUniforms(te,ht,At);const{tileBoundsBuffer:rs,tileBoundsIndexBuffer:ms,tileBoundsSegments:Ds}=N.getTileBoundsBuffers(Bt);ht.draw(N,re.TRIANGLES,Le,Re,Ze,tn.disabled,ts,x.id,rs,ms,Ds)}},sky:function(N,u,x){const C=N._atmosphere?i.aj(N.transform.zoom):1,P=x.paint.get("sky-opacity")*C;if(P===0)return;const R=N.context,F=x.paint.get("sky-type"),U=new Cr(R.gl.LEQUAL,Cr.ReadOnly,[0,1]),K=N.frameCounter/1e3%1;F==="atmosphere"?N.renderPass==="offscreen"?x.needsSkyboxCapture(N)&&(function(te,re,pe,me){const fe=te.context,Ne=fe.gl;let we=re.skyboxFbo;if(!we){we=re.skyboxFbo=fe.createFramebuffer(32,32,1,null),re.skyboxGeometry=new kS(fe),re.skyboxTexture=fe.gl.createTexture(),Ne.bindTexture(Ne.TEXTURE_CUBE_MAP,re.skyboxTexture),Ne.texParameteri(Ne.TEXTURE_CUBE_MAP,Ne.TEXTURE_WRAP_S,Ne.CLAMP_TO_EDGE),Ne.texParameteri(Ne.TEXTURE_CUBE_MAP,Ne.TEXTURE_WRAP_T,Ne.CLAMP_TO_EDGE),Ne.texParameteri(Ne.TEXTURE_CUBE_MAP,Ne.TEXTURE_MIN_FILTER,Ne.LINEAR),Ne.texParameteri(Ne.TEXTURE_CUBE_MAP,Ne.TEXTURE_MAG_FILTER,Ne.LINEAR);for(let nt=0;nt<6;++nt)Ne.texImage2D(Ne.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0,Ne.RGBA,32,32,0,Ne.RGBA,Ne.UNSIGNED_BYTE,null)}fe.bindFramebuffer.set(we.framebuffer),fe.viewport.set([0,0,32,32]);const Re=re.getCenter(te,!0),Le=te.getOrCreateProgram("skyboxCapture"),Ze=new Float64Array(16);i.bA(Ze),i.en(Ze,Ze,.5*-Math.PI),uy(te,re,Le,Ze,Re,0),i.bA(Ze),i.en(Ze,Ze,.5*Math.PI),uy(te,re,Le,Ze,Re,1),i.bA(Ze),i.cU(Ze,Ze,.5*-Math.PI),uy(te,re,Le,Ze,Re,2),i.bA(Ze),i.cU(Ze,Ze,.5*Math.PI),uy(te,re,Le,Ze,Re,3),i.bA(Ze),uy(te,re,Le,Ze,Re,4),i.bA(Ze),i.en(Ze,Ze,Math.PI),uy(te,re,Le,Ze,Re,5),fe.viewport.set([0,0,te.width,te.height])}(N,x),x.markSkyboxValid(N)):N.renderPass==="sky"&&function(te,re,pe,me,fe){const Ne=te.context,we=Ne.gl,Re=te.transform,Le=te.getOrCreateProgram("skybox");Ne.activeTexture.set(we.TEXTURE0),we.bindTexture(we.TEXTURE_CUBE_MAP,re.skyboxTexture);const Ze=((nt,Xe,Mt,gt,jt)=>({u_matrix:nt,u_sun_direction:Xe,u_cubemap:0,u_opacity:gt,u_temporal_offset:jt}))(Re.skyboxMatrix,re.getCenter(te,!1),0,me,fe);te.uploadCommonUniforms(Ne,Le),Le.draw(te,we.TRIANGLES,pe,sn.disabled,te.colorModeForRenderPass(),tn.backCW,Ze,"skybox",re.skyboxGeometry.vertexBuffer,re.skyboxGeometry.indexBuffer,re.skyboxGeometry.segment)}(N,x,U,P,K):F==="gradient"&&N.renderPass==="sky"&&function(te,re,pe,me,fe){const Ne=te.context,we=Ne.gl,Re=te.transform,Le=te.getOrCreateProgram("skyboxGradient");re.skyboxGeometry||(re.skyboxGeometry=new kS(Ne)),Ne.activeTexture.set(we.TEXTURE0);let Ze=re.colorRampTexture;Ze||(Ze=re.colorRampTexture=new i.T(Ne,re.colorRamp,we.RGBA8)),Ze.bind(we.LINEAR,we.CLAMP_TO_EDGE);const nt=((Xe,Mt,gt,jt,ft)=>({u_matrix:Xe,u_color_ramp:0,u_center_direction:Mt,u_radius:i.an(gt),u_opacity:jt,u_temporal_offset:ft}))(Re.skyboxMatrix,re.getCenter(te,!1),re.paint.get("sky-gradient-radius"),me,fe);te.uploadCommonUniforms(Ne,Le),Le.draw(te,we.TRIANGLES,pe,sn.disabled,te.colorModeForRenderPass(),tn.backCW,nt,"skyboxGradient",re.skyboxGeometry.vertexBuffer,re.skyboxGeometry.indexBuffer,re.skyboxGeometry.segment)}(N,x,U,P,K)},custom:function(N,u,x,C){const P=N.context,R=x.implementation;if(!N.transform.projection.unsupportedLayers||!N.transform.projection.unsupportedLayers.includes("custom")||N.terrain&&(N.terrain.renderingToTexture||N.renderPass==="offscreen")&&x.isDraped(u)){if(N.renderPass==="offscreen"){const F=R.prerender;if(F){if(N.setCustomLayerDefaults(),P.setColorMode(N.colorModeForRenderPass()),N.transform.projection.name==="globe"){const U=N.transform.pointMerc;F.call(R,P.gl,N.transform.customLayerMatrix(),N.transform.getProjection(),N.transform.globeToMercatorMatrix(),i.aj(N.transform.zoom),[U.x,U.y],N.transform.pixelsPerMeterRatio)}else F.call(R,P.gl,N.transform.customLayerMatrix());P.setDirty(),N.setBaseState()}}else if(N.renderPass==="translucent"){if(N.terrain&&N.terrain.renderingToTexture){const U=R.renderToTile;if(U){const K=C[0].canonical,te={x:K.x+C[0].wrap*(R.wrapTileId?0:1<{te&&(te.useNormalOffset=!0,re||(te.enabled=!0))},me=u.getSource();if(N.renderPass==="light-beam"&&me.type!=="batched-model")return;if(me.type==="vector"||me.type==="geojson")return function(Xe,Mt,gt,jt,ft){const ht=Xe.transform,At=ht.projection.name==="globe",Ut=ht.getFreeCameraOptions().position;if(!Xe.modelManager)return;const Bt=Xe.modelManager;gt.modelManager=Bt;const ts=Xe.shadowRenderer;if(!gt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const rs=gt._unevaluatedLayout._values["model-id"],ms=Object.assign({},gt.layout.get("model-id").parameters),Ds=Xe.style.order.indexOf(gt.fqid),Yt=gt.paint.get("model-opacity").constantOr(1);for(const Pt of jt){const is=Mt.getTile(Pt).getBucket(gt);if(!is||is.projection.name!==ht.projection.name)continue;const es=is.getModelUris();if(es&&!is.modelsRequested&&(Bt.addModelsFromBucket(es,ft),is.modelsRequested=!0),At)ms.zoom=Pt.overscaledZ;else{const ir=Bd(Pt,ht);ms.zoom=ir}const ks=rs.possiblyEvaluate(ms);if(aD(Xe,is,Pt),vp.shadowUniformsInitialized=!1,vp.useSingleShadowCascade=!!ts&&ts.getMaxCascadeForTile(Pt.toUnwrapped())===0,Xe.renderPass==="shadow"&&ts){if(Xe.currentShadowCascade===1&&is.isInsideFirstShadowMapFrustum)continue;const ir=ht.calculatePosMatrix(Pt.toUnwrapped(),ht.worldSize);if(vp.tileMatrix.set(ir),vp.shadowTileMatrix=Float32Array.from(ts.calculateShadowPassMatrixFromMatrix(ir)),vp.aabb.min=[0,0,0],vp.aabb.max[0]=vp.aabb.max[1]=i.al,vp.aabb.max[2]=0,mce(is,vp,Xe,gt.scope))continue}const Gs=1<0&&Xe.style.isLayerClipped(gt,Mt.getSource())&&is.updateReplacement(Pt,Xe.replacementSource,Ds,gt.scope)&&(is.uploaded=!1,is.upload(Xe.context));let qs=0;const Os=new Array,wr=new Array,yr=new Array;for(let ir in is.instancesPerModel){const hr=is.instancesPerModel[ir];hr.features.length>0&&!At&&(ir=ks.evaluate(hr.features[0].feature,{}));const Fr=Bt.getModel(ir,ft);if(Fr||Bt.hasURLBeenRequested(ir)||is.modelUris.includes(ir)||(is.modelUris.push(ir),is.modelsRequested=!1),Fr&&Fr.uploaded)if(At){const _n=i.c5([],[Ut.x,Ut.y,Ut.z],Xe.transform.worldSize);i.ew(_n,_n);for(let ia=0;ia0&&Ca.elevationUpdate(ir.terrain,ia,Nr,Fr.source),Ca.needsReEvaluation(ir,Oa,Fr)&&Ca.evaluate(Fr))}})(Xe,Mt,gt,jt),function(){let ir,hr,Fr;Os?(ir=jt.length-1,hr=-1,Fr=-1):(ir=0,hr=jt.length,Fr=1);const _n=new Float64Array(16),ia=i.cA(),Oa=new i.P(0,0);for(let Nr=ir;Nr!==hr;Nr+=Fr){const Ca=jt[Nr],un=Mt.getTile(Ca).getBucket(gt);if(!un||!un.uploaded)continue;let Ba=!1;Ut&&(Ba=Ut.getMaxCascadeForTile(Ca.toUnwrapped())===0);const ii=ht.calculatePosMatrix(Ca.toUnwrapped(),ht.worldSize),Ja=un.modelTraits;!Gs&&Os&&(i.bl(_n,ii),i.af(ia,ts,_n),Oa.x=ia[0],Oa.y=ia[1]);const Na=[];un.setFilter(gt.filter);for(const Mn of un.getNodesInfo()){if(Mn.hiddenByReplacement||!Mn.node.meshes)continue;const Fa=Mn.node;let co=0;Xe.terrain&&Fa.elevation&&(co=Fa.elevation*Xe.terrain.exaggeration());const $i=(()=>{const td=Mn.aabb;return ks.min=[...td.min],ks.max=[...td.max],ks.min[2]+=co,ks.max[2]+=co,i.af(ks.min,ks.min,ii),i.af(ks.max,ks.max,ii),ks})(),$a=Mn.evaluatedScale;if($a[0]<=1&&$a[1]<=1&&$a[2]<=1&&$i.intersects(dr)===0)continue;if(!Gs&&Os){const td=.16666666666666666;Mn.cameraCollisionOpacity=ts[0]>$i.min[0]&&ts[0]<$i.max[0]&&ts[1]>$i.min[1]&&ts[1]<$i.max[1]&&ts[2]*Ds<$i.max[2]&&Fa.footprint&&i.c0(Oa,Fa.footprint)?Math.max(Mn.cameraCollisionOpacity-td,0):Math.min(1,Mn.cameraCollisionOpacity+td)}const ya=[...ii],Tn=1/i.d7(Ca.canonical),Ei=Fa.anchor?Fa.anchor[0]:0,jo=Fa.anchor?Fa.anchor[1]:0;i.br(ya,ya,[Ei*($a[0]-1)+Mn.evaluatedTranslation[0]*Tn,jo*($a[1]-1)+Mn.evaluatedTranslation[1]*Tn,co+Mn.evaluatedTranslation[2]]),i.cq($a,i.eE)||i.cS(ya,ya,$a);const no=i.aB([],ya,Fa.globalMatrix),pi=i.aB([],ht.expandedFarZProjMatrix,no),$d=i.aB([],ht.expandedFarZProjMatrix,ya),$c=i.aC([],[Ei,jo,co,1],pi)[2];Fa.hidden=!1;let cl=Pt;Gs||(Os&&(cl*=Mn.cameraCollisionOpacity,cl*=ea(ya,ht,Mn.aabb,qs)),cl*=Bi(wr,$c)),cl!==0?Na.push({nodeInfo:Mn,depth:$c,opacity:cl,wvpForNode:pi,wvpForTile:$d,nodeModelMatrix:no,tileModelMatrix:ya}):Fa.hidden=!0}Gs||Na.sort((Mn,Fa)=>!Os||Mn.opacity===1&&Fa.opacity===1?Mn.depthFa.depth?-1:1);for(const Mn of Na){const Fa=Mn.nodeInfo,co=Fa.node;let $i=i.aB([],Yt,Mn.tileModelMatrix);i.aB($i,ms,$i);const $a=i.bl([],$i);i.eg($a,$a),i.cS($a,$a,H_),$i=i.aB($i,$i,co.globalMatrix);const ya=Xe.renderPass==="light-beam",Tn=gt.paint.get("model-color-use-theme").constantOr("default")==="none",Ei=Ja&i.eI.HasMapboxMeshFeatures,jo=Ei?0:Fa.evaluatedRMEA[0][2];for(let no=0;no=ps||ao>=ps}}const gc=pi.material;let nh;gc.occlusionTexture&&gc.occlusionTexture.offsetScale&&(nh=gc.occlusionTexture.offsetScale,cl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const Uh=Xe.getOrCreateProgram("model",cl);!Gs&&Ut&&Ut.setupShadowsFromMatrix(Mn.tileModelMatrix,Uh,Ut.useNormalOffset),Xe.uploadCommonUniforms(ft,Uh,null,sd);const cu=gc.pbrMetallicRoughness;cu.metallicFactor=.9,cu.roughnessFactor=.5;const yo=iy(new Float32Array($c),new Float32Array($i),new Float32Array($a),new Float32Array(co.globalMatrix),Xe,Mn.opacity,cu.baseColorFactor,gc.emissiveFactor,cu.metallicFactor,cu.roughnessFactor,gc,jo,gt,[0,0,0],nh);!$d&&(Fa.hasTranslucentParts||Mn.opacity<1)&&Uh.draw(Xe,ft.gl.TRIANGLES,is,sn.disabled,Cn.disabled,tn.backCCW,yo,gt.id,pi.vertexBuffer,pi.indexBuffer,pi.segments,gt.paint,Xe.transform.zoom,void 0,td),Uh.draw(Xe,ft.gl.TRIANGLES,$d?es:is,sn.disabled,$d||Mn.opacity<1||Fa.hasTranslucentParts?Cn.alphaBlended:Cn.unblended,tn.backCCW,yo,gt.id,pi.vertexBuffer,pi.indexBuffer,pi.segments,gt.paint,Xe.transform.zoom,void 0,td)}}}}()}(N,u,x,C),void pe();if(me.type!=="model")return;const fe=me.getModels(),Ne=[],we=N.transform.getFreeCameraOptions().position,Re=i.c5([],[we.x,we.y,we.z],N.transform.worldSize);i.ew(Re,Re);const Le=[],Ze=[];let nt=0;for(const Xe of fe){const Mt=u.getFeatureState("",Xe.id),gt={type:"Unknown",id:Xe.id,properties:Xe.featureProperties},jt=x.paint.get("model-rotation").evaluate(gt,Mt),ft=x.paint.get("model-scale").evaluate(gt,Mt),ht=x.paint.get("model-translation").evaluate(gt,Mt),At=x.paint.get("model-opacity").evaluate(gt,Mt);sD(x,Xe.id,Mt,Xe.featureProperties,Xe.nodeOverrideNames,Xe.nodeOverrides),rD(x,Xe.id,Mt,Xe.featureProperties,Xe.materialOverrideNames,Xe.materialOverrides),Xe.nodeOverrides.size>0&&Xe.computeBoundsAndApplyParent(),Xe.computeModelMatrix(N,jt,ft,ht,U,F,!1);const Ut=i.bA([]),Bt=i.ef(Xe.position.lat,N.transform.zoom),ts=i.bq([],[1,1,1/Bt]);i.br(Ut,Ut,Re),Ne.push({zScaleMatrix:ts,negCameraPosMatrix:Ut});for(const rs of Xe.nodes)hy(N,rs,Xe.matrix,N.transform.expandedFarZProjMatrix,nt,Le,Ze,Xe.materialOverrides,At);nt++}if(Le.sort((Xe,Mt)=>Mt.depth-Xe.depth),N.renderPass!=="shadow")nD(N,x,Le,Ze,Ne),pe();else{for(const Xe of Ze)Nm(Xe.mesh,Xe.nodeModelMatrix,N,x);for(const Xe of Le)Nm(Xe.mesh,Xe.nodeModelMatrix,N,x);pe()}}},ES={line:function(N,u,x){if(N.hasElevatedBuckets=!1,N.hasNonElevatedBuckets=!1,N._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||N._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(u){const C=u.getVisibleCoordinates();for(const P of C){const R=u.getTile(P).getBucket(N);if(R&&(R.elevationType!=="none"?N.hasElevatedBuckets=!0:N.hasNonElevatedBuckets=!0,N.hasElevatedBuckets&&N.hasNonElevatedBuckets))break}}}else N.hasNonElevatedBuckets=!0},model:function(N,u,x){const C=u.getSource();if(!C.loaded())return;if(C.type==="vector"||C.type==="geojson")return void(x.modelManager&&x.modelManager.upload(x,V_(x,N)));if(C.type==="batched-model"||C.type!=="model")return;const P=C.getModels();for(const R of P)R.upload(x.context)},raster:function(N,u,x){const C=u.getSource();if(!(C instanceof zc&&C.loaded()))return;const P=N.sourceLayer||C.rasterLayerIds&&C.rasterLayerIds[0];if(!P)return;const R=N.paint.get("raster-array-band")||C.getInitialBand(P);if(R==null)return;const F=u.getIds().map(U=>u.getTileByID(U));for(const U of F)U.updateNeeded(N.id,R)&&C.prepareTile(U,P,N.id,R)},"raster-particle":function(N,u,x){const C=u.getSource();if(!(C instanceof zc&&C.loaded()))return;const P=N.sourceLayer||C.rasterLayerIds&&C.rasterLayerIds[0];if(!P)return;const R=N.paint.get("raster-particle-array-band")||C.getInitialBand(P);if(R==null)return;const F=u.getIds().map(U=>u.getTileByID(U));for(const U of F)U.updateNeeded(N.id,R)&&C.prepareTile(U,P,N.id,R)}},rh={fill:xS},IS={fill:function(N,u,x,C){if(!x.layout||x.layout.get("fill-elevation-reference")==="none"||x.paint.get("fill-opacity").constantOr(1)===0)return;const P=N.context.gl,R=new Cr(P.LEQUAL,Cr.ReadOnly,N.depthRangeFor3D),F=new sn({func:P.ALWAYS,mask:255},255,255,P.KEEP,P.KEEP,P.REPLACE),U=N.transform.getFreeCameraOptions().position,K=N.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const te of C){const re=u.getTile(te),pe=re.getBucket(x);if(!pe)continue;const me=pe.elevatedStructures;if(!me||me.depthSegments.segments[0].primitiveLength===0)continue;const fe=GL(te.toUnwrapped(),U),Ne=N.translatePosMatrix(te.projMatrix,re,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor")),we=ay(Ne,fe,0,1,0);K.draw(N,P.TRIANGLES,R,F,Cn.disabled,tn.disabled,we,x.id,me.vertexBuffer,me.indexBuffer,me.depthSegments,x.paint,N.transform.zoom)}}};class PS{constructor(u,x,C,P,R){this.context=new X0(u,x),this.transform=C,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 F=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const K of F)this._debugParams.enabledLayers[K]=!0;for(const K of F);this.occlusionParams=new J0,this.setup(),this.numSublayers=Dd.maxUnderzooming+Dd.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 z0(this),this._wireframeDebugCache=new Gg,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const U=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,U,u.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=P,this.worldview=R,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(u,x){const C=!!u&&!!u.terrain&&this.transform.projection.supportsTerrain;if(!(C||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new $M(this,u));const P=this._terrain;this.transform.elevation=C?P:null,P.update(u,this.transform,x),this.transform.elevation&&!P.enabled&&(this.transform.elevation=null)}_updateFog(u){const x=u.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[C,P]=x.getFovAdjustedRange(this.transform._fov);if(C>P)return void(this.transform.fogCullDistSq=null);const R=C+.78*(P-C);this.transform.fogCullDistSq=R*R}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(u){u&&!this._terrain&&(this._terrain=new $M(this,this.style)),this._forceTerrainMode=u}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(u,x){if(this.width=u*i.o.devicePixelRatio,this.height=x*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const C of this.style.order)this.style._mergedLayers[C].resize()}setup(){const u=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=u.createVertexBuffer(x,i.bf.members),this.tileExtentSegments=i.bg.simpleSegment(0,0,4,2);const C=new i.bd;C.emplaceBack(0,0),C.emplaceBack(i.al,0),C.emplaceBack(0,i.al),C.emplaceBack(i.al,i.al),this.debugBuffer=u.createVertexBuffer(C,i.bf.members),this.debugSegments=i.bg.simpleSegment(0,0,4,5);const P=new i.bd;P.emplaceBack(-1,-1),P.emplaceBack(1,-1),P.emplaceBack(-1,1),P.emplaceBack(1,1),this.viewportBuffer=u.createVertexBuffer(P,i.bf.members),this.viewportSegments=i.bg.simpleSegment(0,0,4,2);const R=new i.b1;R.emplaceBack(0,0,0,0),R.emplaceBack(i.al,0,i.al,0),R.emplaceBack(0,i.al,0,i.al),R.emplaceBack(i.al,i.al,i.al,i.al),this.mercatorBoundsBuffer=u.createVertexBuffer(R,i.bi.members),this.mercatorBoundsSegments=i.bg.simpleSegment(0,0,4,2);const F=new i.b0;F.emplaceBack(0,1,2),F.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=u.createIndexBuffer(F);const U=new i.be;for(const te of[0,1,3,2,0])U.emplaceBack(te);this.debugIndexBuffer=u.createIndexBuffer(U),this.emptyTexture=new i.T(u,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),u.gl.RGBA8),this.identityMat=i.bC();const K=this.context.gl;this.stencilClearMode=new sn({func:K.ALWAYS,mask:0},0,255,K.ZERO,K.ZERO,K.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(u){return u._makeTileBoundsBuffers(this.context,this.transform.projection),u._tileBoundsBuffer?{tileBoundsBuffer:u._tileBoundsBuffer,tileBoundsIndexBuffer:u._tileBoundsIndexBuffer,tileBoundsSegments:u._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const u=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,u.TRIANGLES,Cr.disabled,this.stencilClearMode,Cn.disabled,tn.disabled,O_(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(u,x,C){if(!x||this.currentStencilSource===x.id||!u.isTileClipped()||!C||C.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let U=!1;for(const K of C)if(this._tileClippingMaskIDs[K.key]===void 0){U=!0;break}if(!U)return}this.currentStencilSource=x.id;const P=this.context,R=P.gl;this.nextStencilID+C.length>256&&this.clearStencil(),P.setColorMode(Cn.disabled),P.setDepthMode(Cr.disabled);const F=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const U of C){const K=x.getTile(U),te=this._tileClippingMaskIDs[U.key]=this.nextStencilID++,{tileBoundsBuffer:re,tileBoundsIndexBuffer:pe,tileBoundsSegments:me}=this.getTileBoundsBuffers(K);F.draw(this,R.TRIANGLES,Cr.disabled,new sn({func:R.ALWAYS,mask:0},te,255,R.KEEP,R.KEEP,R.REPLACE),Cn.disabled,tn.disabled,O_(U.projMatrix),"$clipping",re,pe,me)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const u=this.nextStencilID++,x=this.context.gl;return new sn({func:x.NOTEQUAL,mask:255},u,255,x.KEEP,x.KEEP,x.REPLACE)}stencilModeForClipping(u){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(u);const x=this.context.gl;return new sn({func:x.EQUAL,mask:255},this._tileClippingMaskIDs[u.key],0,x.KEEP,x.KEEP,x.REPLACE)}stencilConfigForOverlap(u){const x=this.context.gl,C=u.sort((F,U)=>U.overscaledZ-F.overscaledZ),P=C[C.length-1].overscaledZ,R=C[0].overscaledZ-P+1;if(R>1){this.currentStencilSource=void 0,this.nextStencilID+R>256&&this.clearStencil();const F={};for(let U=0;Uthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((u,x)=>u+x/this._fpsHistory.length,0))}render(u,x){const C=i.o.now();this._dt=C-this._timeStamp,this._timeStamp=C,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=u.map.repaint,this.style=u,this.options=x;const P=this.style._mergedLayers,R=!(!this.terrain||!this.terrain.enabled),F=()=>this.style._getOrder(R).filter(Yt=>{const Pt=P[Yt];return!(Pt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Pt.type]});let U=F(),K=!1,te=!1,re=null,pe=0,me=!1;for(const Yt of U){const Pt=P[Yt];Pt.visibility!=="none"&&(Pt.type==="circle"?K=!0:Pt.type==="building"?(re=Pt,++pe):Pt.type==="symbol"&&(Pt.hasOcclusionOpacityProperties?te=!0:K=!0))}this.updateEmissiveMode();let fe=U.map(Yt=>P[Yt]);const Ne=this.style._mergedSourceCaches;this.imageManager=u.imageManager,this.modelManager=u.modelManager,this.symbolFadeChange=u.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Yt in Ne){const Pt=Ne[Yt];Pt.used&&(Pt.prepare(this.context),Pt.getSource().usedInConflation&&++pe)}let we=!1;for(const Yt of fe)Yt.isHidden(this.transform.zoom)||(Yt.type==="clip"&&(we=!0),this.prepareLayer(Yt));const Re={},Le={},Ze={},nt={},Xe={};for(const Yt in Ne){const Pt=Ne[Yt];Re[Yt]=Pt.getVisibleCoordinates(),Le[Yt]=Re[Yt].slice().reverse(),Ze[Yt]=Pt.getVisibleCoordinates(!0).reverse(),nt[Yt]=Pt.getShadowCasterCoordinates(),Xe[Yt]=Pt.sortCoordinatesByDistance(Re[Yt])}const Mt=Yt=>{const Pt=this.style.getLayerSourceCache(Yt);return Pt&&Pt.used?Pt.getSource():null};if(pe||we||this._clippingActiveLastFrame){const Yt=[],Pt=[];let is=0;for(const es of fe)this.isSourceForClippingOrConflation(es,Mt(es))&&(Yt.push(es),Pt.push(is)),is++;if(Yt&&(we||Yt.length>1)||this._clippingActiveLastFrame){we=!1;const es=[];for(let ks=0;ks0){const es=Mt(Pt);es&&(this.minCutoffZoom=Math.max(es.minzoom,this.minCutoffZoom)),Pt.minzoom&&(this.minCutoffZoom=Math.max(Pt.minzoom,this.minCutoffZoom))}Pt.is3D(R)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Yt),this._lastOcclusionLayer=Yt)}const gt=this.style&&this.style.fog;gt?(this._fogVisible=gt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=gt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(Ze),this.opaquePassCutoff=0,U=F(),fe=U.map(Yt=>P[Yt]));const jt=this._shadowRenderer;if(jt){jt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Yt in Ne)for(const Pt of Re[Yt]){let is={min:0,max:0};this.terrain&&(is=this.terrain.getMinMaxForTile(Pt)||is),jt.addShadowReceiver(Pt.toUnwrapped(),is.min,is.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 tD(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const ft=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),ht=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(ft&&!this._snow&&(this._snow=new rT(this)),!ft&&this._snow&&(this._snow.destroy(),delete this._snow),ht&&!this._rain&&(this._rain=new AS(this)),!ht&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),re){this.buildingTileBorderManager||(this.buildingTileBorderManager=new NS);const Yt=this.style.getLayerSourceCache(re);this.buildingTileBorderManager.updateBorders(Yt,re)}if(!et.has(this.context.gl))return;this.renderPass="offscreen";for(const Yt of fe){const Pt=u.getLayerSourceCache(Yt);if(!Yt.hasOffscreenPass()||Yt.isHidden(this.transform.zoom))continue;const is=Pt?Le[Pt.id]:void 0;(Yt.type==="custom"||Yt.type==="raster"||Yt.type==="raster-particle"||Yt.isSky()||is&&is.length)&&this.renderLayer(this,Pt,Yt,is)}this.depthRangeFor3D=[0,1-(fe.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,nt)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const At=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ut=(()=>{if(x.showOverdrawInspector)return i.ao.black;const Yt=this.style.fog;if(Yt&&this.transform.projection.supportsFog){const Pt=this.style.getLut(Yt.scope);if(!At){const is=Yt.properties.get("color-use-theme")==="none",es=Yt.properties.get("color").toNonPremultipliedRenderColor(is?null:Pt).toArray01();return new i.ao(...es)}if(At){const is=Yt.properties.get("space-color-use-theme")==="none",es=Yt.properties.get("space-color").toNonPremultipliedRenderColor(is?null:Pt).toArray01();return new i.ao(...es)}}return i.ao.transparent})();if(this.context.clear({color:Ut,depth:1}),this.clearStencil(),this._showOverdrawInspector=x.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&At&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=U.length-1;this.currentLayer>=0;this.currentLayer--){const Yt=fe[this.currentLayer],Pt=u.getLayerSourceCache(Yt);if(Yt.isSky())continue;const is=Pt?(Yt.is3D(R)?Xe:Le)[Pt.id]:void 0;this._renderTileClippingMasks(Yt,Pt,is),this.renderLayer(this,Pt,Yt,is)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&At&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.aj(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&Yt.hasShadowPass()&&--ts==0){{this.clearStencil(),this.resetStencilClippingMasks();const is=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const is=this.currentLayer;this.depthOcclusion=!0;for(const es of this.layersWithOcclusionOpacity){this.currentLayer=es;const ks=fe[this.currentLayer],Gs=u.getLayerSourceCache(ks),dr=Gs?Le[Gs.id]:void 0;this.terrain||this._renderTileClippingMasks(ks,Gs,Gs?Re[Gs.id]:void 0),this.renderLayer(this,Gs,ks,dr)}this.depthOcclusion=!1,this.currentLayer=is,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Yt=null;fe.forEach(Pt=>{const is=u.getLayerSourceCache(Pt);is&&!Pt.isHidden(this.transform.zoom)&&is.getVisibleCoordinates().length&&(!Yt||Yt.getSource().maxzoom0?x.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(u,x,C){const P=C===void 0?this.terrain&&this.terrain.renderingToTexture:C,R=[];return this.style&&this.style.enable3dLights()&&(u==="globeRaster"||u==="terrainRaster"?(R.push("LIGHTING_3D_MODE"),R.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):P||R.push("LIGHTING_3D_MODE")),this.renderPass==="shadow"&&(this._shadowMapDebug||R.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(R.push("TERRAIN"),this.linearFloatFilteringSupported()&&R.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&R.push("GLOBE"),!this._fogVisible||P||x!==void 0&&!x||R.push("FOG","FOG_DITHERING"),P&&R.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&R.push("OVERDRAW_INSPECTOR"),R}getOrCreateProgram(u,x){this.cache=this.cache||{};const C=x&&x.defines||[],P=x&&x.config,R=this.currentGlobalDefines(u,x&&x.overrideFog,x&&x.overrideRtt).concat(C),F=LL.cacheKey(MM[u],u,R,P);return this.cache[F]||(this.cache[F]=new LL(this.context,u,MM[u],P,gS[u],R)),this.cache[F]}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 u=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(u.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(u,x){if(this.style.enable3dLights()){const C=this.style.directionalLight,P=this.style.ambientLight;if(C&&P){const R=((F,U,K)=>{const te=F.properties.get("direction"),re=F.properties.get("color-use-theme")==="none",pe=F.properties.get("color").toNonPremultipliedRenderColor(re?null:K.getLut(F.scope)).toArray01(),me=F.properties.get("intensity"),fe=U.properties.get("color-use-theme")==="none",Ne=U.properties.get("color").toNonPremultipliedRenderColor(fe?null:K.getLut(U.scope)).toArray01(),we=U.properties.get("intensity"),Re=[te.x,te.y,te.z],Le=i.dN(Ne,we),Ze=i.dN(pe,me);return{u_lighting_ambient_color:Le,u_lighting_directional_dir:Re,u_lighting_directional_color:Ze,u_ground_radiance:K0(Re,Ze,Le)}})(C,P,this.style);x.setLightsUniformValues(u,R)}}}uploadCommonUniforms(u,x,C,P,R){if(this.uploadCommonLightUniforms(u,x),this.terrain&&this.terrain.renderingToTexture)return;const F=this.style.fog;if(F){const U=F.getOpacity(this.transform.pitch),K=((te,re,pe,me,fe,Ne,we,Re,Le,Ze,nt,Xe)=>{const Mt=te.transform,gt=re.properties.get("color-use-theme")==="none",jt=re.properties.get("color").toNonPremultipliedRenderColor(gt?null:te.style.getLut(re.scope)).toArray01();jt[3]=me;const ft=te.frameCounter/1e3%1,[ht,At]=re.properties.get("vertical-range");return{u_fog_matrix:pe?Mt.calculateFogTileMatrix(pe):Xe||te.identityMat,u_fog_range:re.getFovAdjustedRange(Mt._fov),u_fog_color:jt,u_fog_horizon_blend:re.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(ht,At),At],u_fog_temporal_offset:ft,u_frustum_tl:fe,u_frustum_tr:Ne,u_frustum_br:we,u_frustum_bl:Re,u_globe_pos:Le,u_globe_radius:Ze,u_viewport:nt,u_globe_transition:i.aj(Mt.zoom),u_is_globe:+(Mt.projection.name==="globe")}})(this,F,C,U,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],P);x.setFogUniformValues(u,K)}R&&x.setCutoffUniformValues(u,R.uniformValues)}setTileLoadedFlag(u){this.tileLoaded=u}saveCanvasCopy(){const u=this.canvasCopy();u&&(this.frameCopies.push(u),this.tileLoaded=!1)}canvasCopy(){const u=this.context.gl,x=u.createTexture();return u.bindTexture(u.TEXTURE_2D,x),u.copyTexImage2D(u.TEXTURE_2D,0,u.RGBA,0,0,u.drawingBufferWidth,u.drawingBufferHeight,0),x}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const u=this.style&&this.style.fog;return!!u&&u.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const u=this._backgroundTiles,x=this._backgroundTiles={},C=this.transform.coveringTiles({tileSize:512});for(const P of C)x[P.key]=u[P.key]||new uf(P,512,this.transform.tileZoom,this,void 0,this.worldview);return x}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(u,x){return!(!u.is3D(!(!this.terrain||!this.terrain.enabled))||u.type!=="clip"&&u.type!=="building"&&(u.minzoom&&u.minzoom>this.transform.zoom||(this.style._clipLayerPresent||u.sourceLayer!=="building"&&u.sourceLayer!=="procedural_buildings")&&(!x||x.type!=="batched-model")))}isTileAffectedByFog(u){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let x=this._cachedTileFogOpacities[u.key];return x||(this._cachedTileFogOpacities[u.key]=x=this.style.fog.getOpacityForTile(u)),x[0]>=ps||x[1]>=ps}setupDepthForOcclusion(u,x,C){const P=this.context,R=P.gl,F=!!C;var U;C||(C={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}),P.activeTexture.set(R.TEXTURE3),u&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(R.NEAREST,R.CLAMP_TO_EDGE),C.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],C.u_depth_range_unpack=[2/((U=this.depthRangeFor3D)[1]-U[0]),-1-2*U[0]/(U[1]-U[0])],C.u_occluder_half_size=.5*this.occlusionParams.occluderSize,C.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(R.NEAREST,R.CLAMP_TO_EDGE),P.activeTexture.set(R.TEXTURE0),F||x.setTerrainUniformValues(P,C)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const u=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=u?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function LS(N,u){let x=!1,C=null;const P=()=>{C=null,x&&(N(),C=setTimeout(P,u),x=!1)};return()=>(x=!0,C||P(),C)}class nT{constructor(u){this._hashName=u&&encodeURIComponent(u),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=LS(this._updateHashUnthrottled.bind(this),300)}addTo(u){return this._map=u,window.addEventListener("hashchange",this._onHashChange,!1),u.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 u=this._map;if(!u)return"";const x=ol(u);if(this._hashName){const C=this._hashName;let P=!1;const R=location.hash.slice(1).split("&").map(F=>{const U=F.split("=")[0];return U===C?(P=!0,`${U}=${x}`):F}).filter(F=>F);return P||R.push(`${C}=${x}`),`#${R.join("&")}`}return`#${x}`}_getCurrentHash(){const u=location.hash.replace("#","");if(this._hashName){let x;return u.split("&").map(C=>C.split("=")).forEach(C=>{C[0]===this._hashName&&(x=C)}),(x&&x[1]||"").split("/")}return u.split("/")}_onHashChange(){const u=this._map;if(!u)return!1;const x=this._getCurrentHash();if(x.length>=3&&!x.some(C=>isNaN(Number(C)))){const C=u.dragRotate.isEnabled()&&u.touchZoomRotate.isEnabled()?+(x[3]||0):u.getBearing();return u.jumpTo({center:[+x[2],+x[1]],zoom:+x[0],bearing:C,pitch:+(x[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function ol(N,u){const x=N.getCenter(),C=Math.round(100*N.getZoom())/100,P=Math.ceil((C*Math.LN2+Math.log(512/360/.5))/Math.LN10),R=Math.pow(10,P),F=Math.round(x.lng*R)/R,U=Math.round(x.lat*R)/R,K=N.getBearing(),te=N.getPitch();let re=u?`/${F}/${U}/${C}`:`${C}/${U}/${F}`;return(K||te)&&(re+="/"+Math.round(10*K)/10),te&&(re+=`/${Math.round(te)}`),re}const tv={linearity:.3,easing:i.eT(0,0,.3,1)},aT=Object.assign({deceleration:2500,maxSpeed:1400},tv),iT=Object.assign({deceleration:20,maxSpeed:1400},tv),py=Object.assign({deceleration:1e3,maxSpeed:360},tv),oT=Object.assign({deceleration:1e3,maxSpeed:90},tv);class lT{constructor(u){this._map=u,this.clear()}clear(){this._inertiaBuffer=[]}record(u){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.o.now(),settings:u})}_drainInertiaBuffer(){const u=this._inertiaBuffer,x=i.o.now();for(;u.length>0&&x-u[0].time>160;)u.shift()}_onMoveEnd(u){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:R}of this._inertiaBuffer)x.zoom+=R.zoomDelta||0,x.bearing+=R.bearingDelta||0,x.pitch+=R.pitchDelta||0,R.panDelta&&x.pan._add(R.panDelta),R.around&&(x.around=R.around),R.pinchAround&&(x.pinchAround=R.pinchAround);const C=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,P={};if(x.pan.mag()){const R=_p(x.pan.mag(),C,Object.assign({},aT,u||{}));P.offset=x.pan.mult(R.amount/x.pan.mag()),P.center=this._map.transform.center,sv(P,R)}if(x.zoom){const R=_p(x.zoom,C,iT);P.zoom=this._map.transform.zoom+R.amount,sv(P,R)}if(x.bearing){const R=_p(x.bearing,C,py);P.bearing=this._map.transform.bearing+i.aA(R.amount,-179,179),sv(P,R)}if(x.pitch){const R=_p(x.pitch,C,oT);P.pitch=this._map.transform.pitch+R.amount,sv(P,R)}if(P.zoom||P.bearing){const R=x.pinchAround===void 0?x.around:x.pinchAround;P.around=R?this._map.unproject(R):this._map.getCenter()}return this.clear(),P.noMoveStart=!0,P}}function sv(N,u){(!N.duration||N.durationx.unproject(K)),U=R.reduce((K,te,re,pe)=>K.add(te.div(pe.length)),new i.P(0,0));super(u,{points:R,point:U,lngLats:F,lngLat:x.unproject(U),originalEvent:C}),this._defaultPrevented=!1}}class cT extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(u,x){super("wheel",{originalEvent:x}),this._defaultPrevented=!1}}class DS{constructor(u,x){this._map=u,this._clickTolerance=x.clickTolerance}reset(){this._mousedownPos=void 0}wheel(u){return this._firePreventable(new cT(this._map,u))}mousedown(u,x){return this._mousedownPos=x,this._firePreventable(new lu(u.type,this._map,u))}mouseup(u){this._map.fire(new lu(u.type,this._map,u))}preclick(u){const x=new MouseEvent("preclick",u);this._map.fire(new lu(x.type,this._map,x))}click(u,x){this._mousedownPos&&this._mousedownPos.dist(x)>=this._clickTolerance||(this.preclick(u),this._map.fire(new lu(u.type,this._map,u)))}dblclick(u){return this._firePreventable(new lu(u.type,this._map,u))}mouseover(u){this._map.fire(new lu(u.type,this._map,u))}mouseout(u){this._map.fire(new lu(u.type,this._map,u))}touchstart(u){return this._firePreventable(new Zg(u.type,this._map,u))}touchmove(u){this._map.fire(new Zg(u.type,this._map,u))}touchend(u){this._map.fire(new Zg(u.type,this._map,u))}touchcancel(u){this._map.fire(new Zg(u.type,this._map,u))}_firePreventable(u){if(this._map.fire(u),u.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class dT{constructor(u){this._map=u}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(u){this._map.fire(new lu(u.type,this._map,u))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new lu("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(u){this._delayContextMenu?this._contextMenuEvent=u:this._map.fire(new lu(u.type,this._map,u)),this._map.listens("contextmenu")&&u.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class OS{constructor(u,x){this._map=u,this._el=u.getCanvasContainer(),this._container=u.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(u,x){this.isEnabled()&&u.shiftKey&&u.button===0&&(D(),this._startPos=this._lastPos=x,this._active=!0)}mousemoveWindow(u,x){if(!this._active)return;const C=x,P=this._startPos,R=this._lastPos;if(!P||!R||R.equals(C)||!this._box&&C.dist(P){this._box&&(this._box.style.transform=`translate(${F}px,${K}px)`,this._box.style.width=U-F+"px",this._box.style.height=te-K+"px")})}mouseupWindow(u,x){if(!this._active)return;const C=this._startPos,P=x;if(C&&u.button===0){if(this.reset(),$(),C.x!==P.x||C.y!==P.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:u})),{cameraAnimation:R=>R.fitScreenCoordinates(C,P,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",u)}}keydown(u){this._active&&u.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",u))}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(u,x){return this._map.fire(new i.z(u,{originalEvent:x}))}}function RS(N,u){const x={};for(let C=0;Cthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=u.timeStamp),C.length===this.numTouches&&(this.centroid=function(P){const R=new i.P(0,0);for(const F of P)R._add(F);return R.div(P.length)}(x),this.touches=RS(C,x)))}touchmove(u,x,C){if(this.aborted||!this.centroid)return;const P=RS(C,x);for(const R in this.touches){const F=P[R];(!F||F.dist(this.touches[R])>30)&&(this.aborted=!0)}}touchend(u,x,C){if((!this.centroid||u.timeStamp-this.startTime>500)&&(this.aborted=!0),C.length===0){const P=!this.aborted&&this.centroid;if(this.reset(),P)return P}}}class FS{constructor(u){this.singleTap=new lD(u),this.numTaps=u.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(u,x,C){this.singleTap.touchstart(u,x,C)}touchmove(u,x,C){this.singleTap.touchmove(u,x,C)}touchend(u,x,C){const P=this.singleTap.touchend(u,x,C);if(P){const R=u.timeStamp-this.lastTime<500,F=!this.lastTap||this.lastTap.dist(P)<30;if(R&&F||this.reset(),this.count++,this.lastTime=u.timeStamp,this.lastTap=P,this.count===this.numTaps)return this.reset(),P}}}class cD{constructor(){this._zoomIn=new FS({numTouches:1,numTaps:2}),this._zoomOut=new FS({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(u,x,C){this._zoomIn.touchstart(u,x,C),this._zoomOut.touchstart(u,x,C)}touchmove(u,x,C){this._zoomIn.touchmove(u,x,C),this._zoomOut.touchmove(u,x,C)}touchend(u,x,C){const P=this._zoomIn.touchend(u,x,C),R=this._zoomOut.touchend(u,x,C);return P?(this._active=!0,u.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:F=>F.easeTo({duration:300,zoom:F.getZoom()+1,around:F.unproject(P)},{originalEvent:u})}):R?(this._active=!0,u.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:F=>F.easeTo({duration:300,zoom:F.getZoom()-1,around:F.unproject(R)},{originalEvent:u})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const dD={0:1,2:2},uT={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class zS{constructor(u){this.reset(),this._clickTolerance=u.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(u,x){return!1}_move(u,x){return{}}mousedown(u,x){if(this._lastPoint)return;const C=G(u);this._correctButton(u,C)&&(this._lastPoint=x,this._eventButton=C)}mousemoveWindow(u,x){const C=this._lastPoint;if(C){if(u.preventDefault(),this._eventButton!=null&&function(P,R){const F=dD[R];return P.buttons===void 0||(P.buttons&F)!==F}(u,this._eventButton))this.reset();else if(this._moved||!(x.dist(C)0&&(this._active=!0);const P=RS(C,x),R=new i.P(0,0),F=new i.P(0,0);let U=0;for(const te in P){const re=P[te],pe=this._touches[te];pe&&(R._add(re),F._add(re.sub(pe)),U++,P[te]=re)}if(this._touches=P,U{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class BS{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(u){}_move(u,x,C){return{}}touchstart(u,x,C){this._firstTwoTouches||C.length<2||(this._firstTwoTouches=[C[0].identifier,C[1].identifier],this._start([x[0],x[1]]))}touchmove(u,x,C){const P=this._firstTwoTouches;if(!P)return;u.preventDefault();const[R,F]=P,U=W_(C,x,R),K=W_(C,x,F);if(!U||!K)return;const te=this._aroundCenter?null:U.add(K).div(2);return this._move([U,K],te,u)}touchend(u,x,C){if(!this._firstTwoTouches)return;const[P,R]=this._firstTwoTouches,F=W_(C,x,P),U=W_(C,x,R);F&&U||(this._active&&$(),this.reset())}touchcancel(){this.reset()}enable(u){this._enabled=!0,this._aroundCenter=!!u&&u.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function W_(N,u,x){for(let C=0;CMath.abs(N.x)}class fce extends BS{constructor(u){super(),this._map=u}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(u){this._lastPoints=u,$S(u[0].sub(u[1]))&&(this._valid=!1)}_move(u,x,C){const P=this._lastPoints;if(!P)return;const R=u[0].sub(P[0]),F=u[1].sub(P[1]);return this._map._cooperativeGestures&&!i.eU()&&C.touches.length<3||(this._valid=this.gestureBeginsVertically(R,F,C.timeStamp),!this._valid)?void 0:(this._lastPoints=u,this._active=!0,{pitchDelta:(R.y+F.y)/2*-.5})}gestureBeginsVertically(u,x,C){if(this._valid!==void 0)return this._valid;const P=u.mag()>=2,R=x.mag()>=2;if(!P&&!R)return;if(!P||!R)return this._firstMove==null&&(this._firstMove=C),C-this._firstMove<100&&void 0;const F=u.y>0==x.y>0;return $S(u)&&$S(x)&&F}}const gce={panStep:100,bearingStep:15,pitchStep:10};class xce{constructor(){const u=gce;this._panStep=u.panStep,this._bearingStep=u.bearingStep,this._pitchStep=u.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(u){if(u.altKey||u.ctrlKey||u.metaKey)return;let x=0,C=0,P=0,R=0,F=0;switch(u.keyCode){case 61:case 107:case 171:case 187:x=1;break;case 189:case 109:case 173:x=-1;break;case 37:u.shiftKey?C=-1:(u.preventDefault(),R=-1);break;case 39:u.shiftKey?C=1:(u.preventDefault(),R=1);break;case 38:u.shiftKey?P=1:(u.preventDefault(),F=-1);break;case 40:u.shiftKey?P=-1:(u.preventDefault(),F=1);break;default:return}return this._rotationDisabled&&(C=0,P=0),{cameraAnimation:U=>{const K=U.getZoom();U.easeTo({duration:300,easeId:"keyboardHandler",easing:G_,zoom:x?Math.round(K)+x*(u.shiftKey?2:1):K,bearing:U.getBearing()+C*this._bearingStep,pitch:U.getPitch()+P*this._pitchStep,offset:[-R*this._panStep,-F*this._panStep],center:U.getCenter()},{originalEvent:u})}}}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 G_(N){return N*(2-N)}const pT=4.000244140625,fT=1/450;class US{constructor(u,x){this._map=u,this._el=u.getCanvasContainer(),this._handler=x,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=fT,i.aY(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(u){this._defaultZoomRate=u}setWheelZoomRate(u){this._wheelZoomRate=u}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(u){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!u&&u.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(u){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(u.ctrlKey||u.metaKey||this.isZooming()||i.eU()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let x=u.deltaMode===WheelEvent.DOM_DELTA_LINE?40*u.deltaY:u.deltaY;const C=i.o.now(),P=C-(this._lastWheelEventTime||0);this._lastWheelEventTime=C,x!==0&&x%pT==0?this._type="wheel":x!==0&&Math.abs(x)<4?this._type="trackpad":P>400?(this._type=null,this._lastValue=x,this._timeout=window.setTimeout(this._onTimeout,40,u)):this._type||(this._type=Math.abs(P*x)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,x+=this._lastValue)),u.shiftKey&&x&&(x/=4),this._type&&(this._lastWheelEvent=u,this._delta-=x,this._active||this._start(u)),u.preventDefault()}_onTimeout(u){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(u)}_start(u){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=V(this._el,u);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 u=this._map.transform;this._type==="wheel"&&u.projection.wrap&&(u._center.lng>=180||u._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const x=()=>u._terrainEnabled()&&this._aroundCoord?u.computeZoomRelativeTo(this._aroundCoord):u.zoom;if(this._delta!==0){const te=this._type==="wheel"&&Math.abs(this._delta)>pT?this._wheelZoomRate:this._defaultZoomRate;let re=2/(1+Math.exp(-Math.abs(this._delta*te)));this._delta<0&&re!==0&&(re=1/re);const pe=x(),me=Math.pow(2,pe),fe=typeof this._targetZoom=="number"?u.zoomScale(this._targetZoom):me;this._targetZoom=Math.min(u.maxZoom,Math.max(u.minZoom,u.scaleZoom(fe*re))),this._type==="wheel"&&(this._startZoom=pe,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const C=typeof this._targetZoom=="number"?this._targetZoom:x(),P=this._startZoom,R=this._easing;let F,U=!1;if(this._type==="wheel"&&P&&R){const te=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),re=R(te);F=i.ak(P,C,re),te<1?this._frameId||(this._frameId=!0):U=!0}else F=C,U=!0;this._active=!0,U&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let K=F-x();return K*this._lastDelta<0&&(K=0),{noInertia:!0,needsRenderFrame:!U,zoomDelta:K,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(u){let x=i.eV;if(this._prevEase){const C=this._prevEase,P=(i.o.now()-C.start)/C.duration,R=C.easing(P+.01)-C.easing(P),F=.27/Math.sqrt(R*R+1e-4)*.01,U=Math.sqrt(.0729-F*F);x=i.eT(F,U,.25,1)}return this._prevEase={start:i.o.now(),duration:u,easing:x},x}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=w("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class wf{constructor(u,x){this._clickZoom=u,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 qS{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(u,x){return u.preventDefault(),{cameraAnimation:C=>{C.easeTo({duration:300,zoom:C.getZoom()+(u.shiftKey?-1:1),around:C.unproject(x)},{originalEvent:u})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ll{constructor(){this._tap=new FS({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(u,x,C){this._swipePoint||(this._tapTime&&u.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?C.length>0&&(this._swipePoint=x[0],this._swipeTouch=C[0].identifier):this._tap.touchstart(u,x,C))}touchmove(u,x,C){if(this._tapTime){if(this._swipePoint){if(C[0].identifier!==this._swipeTouch)return;const P=x[0],R=P.y-this._swipePoint.y;return this._swipePoint=P,u.preventDefault(),this._active=!0,{zoomDelta:R/128}}}else this._tap.touchmove(u,x,C)}touchend(u,x,C){this._tapTime?this._swipePoint&&C.length===0&&this.reset():this._tap.touchend(u,x,C)&&(this._tapTime=u.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class bp{constructor(u,x,C){this._el=u,this._mousePan=x,this._touchPan=C}enable(u){this._inertiaOptions=u||{},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 K_{constructor(u,x,C){this._pitchWithRotate=u.pitchWithRotate,this._mouseRotate=x,this._mousePitch=C}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 VS{constructor(u,x,C,P){this._el=u,this._touchZoom=x,this._touchRotate=C,this._tapDragZoom=P,this._rotationDisabled=!1,this._enabled=!0}enable(u){this._touchZoom.enable(u),this._rotationDisabled||this._touchRotate.enable(u),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 Z_=N=>N.zoom||N.drag||N.pitch||N.rotate;class yce extends i.z{}class Y_{constructor(){this.constants=[1,1,.01],this.radius=0}setup(u,x){const C=i.av([],x,u);this.radius=i.ag(C[2]<0?i.eX([],C,this.constants):[C[0],C[1],0])}projectRay(u){i.eX(u,u,this.constants),i.aw(u,u),i.eY(u,u,this.constants);const x=i.c5([],u,this.radius);if(x[2]>0){const C=i.c5([],[0,0,1],i.bJ(x,[0,0,1])),P=i.c5([],i.aw([],[x[0],x[1],0]),this.radius),R=i.d8([],x,i.c5([],i.av([],i.d8([],P,C),x),2));x[0]=R[0],x[1]=R[1]}return x}}function HS(N){return N.panDelta&&N.panDelta.mag()||N.zoomDelta||N.bearingDelta||N.pitchDelta}class vce{constructor(u,x){this._map=u,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new lT(u),this._bearingSnap=x.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Y_,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(x),i.aY(["handleEvent","handleWindowEvent"],this);const C=this._el;this._listeners=[[C,"touchstart",{passive:!0}],[C,"touchmove",{passive:!1}],[C,"touchend",void 0],[C,"touchcancel",void 0],[C,"mousedown",void 0],[C,"mousemove",void 0],[C,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[C,"mouseover",void 0],[C,"mouseout",void 0],[C,"dblclick",void 0],[C,"click",void 0],[C,"keydown",{capture:!1}],[C,"keyup",void 0],[C,"wheel",{passive:!1}],[C,"contextmenu",void 0],[window,"blur",void 0]];for(const[P,R,F]of this._listeners){const U=P===document?this.handleWindowEvent:this.handleEvent;P.addEventListener(R,U,F)}}destroy(){for(const[u,x,C]of this._listeners){const P=u===document?this.handleWindowEvent:this.handleEvent;u.removeEventListener(x,P,C)}}_addDefaultHandlers(u){const x=this._map,C=x.getCanvasContainer();this._add("mapEvent",new DS(x,u));const P=x.boxZoom=new OS(x,u);this._add("boxZoom",P);const R=new cD,F=new qS;x.doubleClickZoom=new wf(F,R),this._add("tapZoom",R),this._add("clickZoom",F);const U=new ll;this._add("tapDragZoom",U);const K=x.touchPitch=new fce(x);this._add("touchPitch",K);const te=new hT(u),re=new mT(u);x.dragRotate=new K_(u,te,re),this._add("mouseRotate",te,["mousePitch"]),this._add("mousePitch",re,["mouseRotate"]);const pe=new uD(u),me=new hD(x,u);x.dragPan=new bp(C,pe,me),this._add("mousePan",pe),this._add("touchPan",me,["touchZoom","touchRotate"]);const fe=new ro,Ne=new pce;x.touchZoomRotate=new VS(C,Ne,fe,U),this._add("touchRotate",fe,["touchPan","touchZoom"]),this._add("touchZoom",Ne,["touchPan","touchRotate"]),this._add("blockableMapEvent",new dT(x));const we=x.scrollZoom=new US(x,this);this._add("scrollZoom",we,["mousePan"]);const Re=x.keyboard=new xce;this._add("keyboard",Re);for(const Le of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])u.interactive&&u[Le]&&x[Le].enable(u[Le])}_add(u,x,C){this._handlers.push({handlerName:u,handler:x,allowed:C}),this._handlersById[u]=x}stop(u){if(!this._updatingCamera){for(const{handler:x}of this._handlers)x.reset();this._inertia.clear(),this._fireEvents({},{},u),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:u}of this._handlers)if(u.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Z_(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(u,x,C){for(const P in u)if(P!==C&&(!x||x.indexOf(P)<0))return!0;return!1}handleWindowEvent(u){this.handleEvent(u,`${u.type}Window`)}_getMapTouches(u){const x=[];for(const C of u)this._el.contains(C.target)&&x.push(C);return x}handleEvent(u,x){this._updatingCamera=!0;const C=u.type==="renderFrame",P=C?void 0:u,R={needsRenderFrame:!1},F={},U={},K=u.touches?this._getMapTouches(u.touches):void 0,te=K?W(this._el,K):C?void 0:V(this._el,u);for(const{handlerName:me,handler:fe,allowed:Ne}of this._handlers){if(!fe.isEnabled())continue;let we;this._blockedByActive(U,Ne,me)?fe.reset():fe[x||u.type]&&(we=fe[x||u.type](u,te,K),this.mergeHandlerResult(R,F,we,me,P),we&&we.needsRenderFrame&&this._triggerRenderFrame()),(we||fe.isActive())&&(U[me]=fe)}const re={};for(const me in this._previousActiveHandlers)U[me]||(re[me]=P);this._previousActiveHandlers=U,(Object.keys(re).length||HS(R))&&(this._changes.push([R,F,re]),this._triggerRenderFrame()),(Object.keys(U).length||HS(R))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:pe}=R;pe&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],pe(this._map))}mergeHandlerResult(u,x,C,P,R){if(!C)return;Object.assign(u,C);const F={handlerName:P,originalEvent:C.originalEvent||R};C.zoomDelta!==void 0&&(x.zoom=F),C.panDelta!==void 0&&(x.drag=F),C.pitchDelta!==void 0&&(x.pitch=F),C.bearingDelta!==void 0&&(x.rotate=F)}_applyChanges(){const u={},x={},C={};for(const[P,R,F]of this._changes)P.panDelta&&(u.panDelta=(u.panDelta||new i.P(0,0))._add(P.panDelta)),P.zoomDelta&&(u.zoomDelta=(u.zoomDelta||0)+P.zoomDelta),P.bearingDelta&&(u.bearingDelta=(u.bearingDelta||0)+P.bearingDelta),P.pitchDelta&&(u.pitchDelta=(u.pitchDelta||0)+P.pitchDelta),P.around!==void 0&&(u.around=P.around),P.aroundCoord!==void 0&&(u.aroundCoord=P.aroundCoord),P.pinchAround!==void 0&&(u.pinchAround=P.pinchAround),P.noInertia&&(u.noInertia=P.noInertia),Object.assign(x,R),Object.assign(C,F);this._updateMapTransform(u,x,C),this._changes=[]}_updateMapTransform(u,x,C){const P=this._map,R=P.transform,F=Ze=>[Ze.x,Ze.y,Ze.z];if((Ze=>{const nt=this._eventsInProgress.drag;return nt&&!this._handlersById[nt.handlerName].isActive()})()&&!HS(u)){const Ze=R.zoom;R.cameraElevationReference="sea",this._originalZoom!=null&&R._orthographicProjectionAtLowPitch&&R.projection.name!=="globe"&&R.pitch===0?(R.cameraElevationReference="ground",R.zoom=this._originalZoom):(R.recenterOnTerrain(),R.cameraElevationReference="ground"),Ze!==R.zoom&&this._map._update(!0)}if(R._isCameraConstrained&&P._stop(!0),!HS(u))return void this._fireEvents(x,C,!0);let{panDelta:U,zoomDelta:K,bearingDelta:te,pitchDelta:re,around:pe,aroundCoord:me,pinchAround:fe}=u;R._isCameraConstrained&&(K>0&&(K=0),R._isCameraConstrained=!1),fe!==void 0&&(pe=fe),(K||(Ze=>x[Ze]&&!this._eventsInProgress[Ze])("drag"))&&pe&&(this._dragOrigin=F(R.pointCoordinate3D(pe)),this._originalZoom=R.zoom,this._trackingEllipsoid.setup(R._camera.position,this._dragOrigin)),R.cameraElevationReference="sea",P._stop(!0),pe=pe||P.transform.centerPoint,te&&(R.bearing+=te),re&&(R.pitch+=re),R._updateCameraState();const Ne=[0,0,0];if(U)if(R.projection.name==="mercator"){const Ze=this._trackingEllipsoid.projectRay(R.screenPointToMercatorRay(pe).dir),nt=this._trackingEllipsoid.projectRay(R.screenPointToMercatorRay(pe.sub(U)).dir);Ne[0]=nt[0]-Ze[0],Ne[1]=nt[1]-Ze[1]}else{const Ze=R.pointCoordinate(pe);if(R.projection.name==="globe"){U=U.rotate(-R.angle);const nt=R._pixelsPerMercatorPixel/R.worldSize;Ne[0]=-U.x*i.eW(i.a$(Ze.y))*nt,Ne[1]=-U.y*i.eW(R.center.lat)*nt}else{const nt=R.pointCoordinate(pe.sub(U));Ze&&nt&&(Ne[0]=nt.x-Ze.x,Ne[1]=nt.y-Ze.y)}}const we=R.zoom,Re=[0,0,0];if(K){const Ze=F(me||R.pointCoordinate3D(pe)),nt={dir:i.aw([],i.av([],Ze,R._camera.position))};if(nt.dir[2]<0){const Xe=R.zoomDeltaToMovement(Ze,K);i.c5(Re,nt.dir,Xe)}}const Le=i.d8(Ne,Ne,Re);R._translateCameraConstrained(Le),K&&Math.abs(R.zoom-we)>1e-4&&R.recenterOnTerrain(),R.cameraElevationReference="ground",this._map._update(),u.noInertia||this._inertia.record(u),this._fireEvents(x,C,!0)}_fireEvents(u,x,C){const P=Z_(this._eventsInProgress),R=Z_(u),F={};for(const re in u){const{originalEvent:pe}=u[re];this._eventsInProgress[re]||(F[`${re}start`]=pe),this._eventsInProgress[re]=u[re]}!P&&R&&this._fireEvent("movestart",R.originalEvent);for(const re in F)this._fireEvent(re,F[re]);R&&this._fireEvent("move",R.originalEvent);for(const re in u){const{originalEvent:pe}=u[re];this._fireEvent(re,pe)}const U={};let K;for(const re in this._eventsInProgress){const{handlerName:pe,originalEvent:me}=this._eventsInProgress[re];this._handlersById[pe].isActive()||(delete this._eventsInProgress[re],K=x[pe]||me,U[`${re}end`]=K)}for(const re in U)this._fireEvent(re,U[re]);const te=Z_(this._eventsInProgress);if(C&&(P||R)&&!te){this._updatingCamera=!0;const re=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),pe=me=>me!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new yce("renderFrame",{timeStamp:u})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const WS="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class gT extends i.E{constructor(u,x){super(),this._moving=!1,this._zooming=!1,this.transform=u,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(u,x){return this.jumpTo({center:u},x)}panBy(u,x,C){return u=i.P.convert(u).mult(-1),this.panTo(this.transform.center,Object.assign({offset:u},x),C)}panTo(u,x,C){return this.easeTo(Object.assign({center:u},x),C)}getZoom(){return this.transform.zoom}setZoom(u,x){return this.jumpTo({zoom:u},x),this}zoomTo(u,x,C){return this.easeTo(Object.assign({zoom:u},x),C)}zoomIn(u,x){return this.zoomTo(this.getZoom()+1,u,x),this}zoomOut(u,x){return this.zoomTo(this.getZoom()-1,u,x),this}getBearing(){return this.transform.bearing}setBearing(u,x){return this.jumpTo({bearing:u},x),this}getPadding(){return this.transform.padding}setPadding(u,x){return this.jumpTo({padding:u},x),this}rotateTo(u,x,C){return this.easeTo(Object.assign({bearing:u},x),C)}resetNorth(u,x){return this.rotateTo(0,Object.assign({duration:1e3},u),x),this}resetNorthPitch(u,x){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},u),x),this}snapToNorth(u,x){return Math.abs(this.getBearing())u.aspect?C/(2*Math.tan(.5*u.fovX)*u.aspect):P/(2*Math.tan(.5*u.fovY)*u.aspect)}_cameraForBoundsOnGlobe(u,x,C,P,R,F){const U=u.clone(),K=this._extendCameraOptions(F);U.bearing=P,U.pitch=R;const te=i.aT.convert(x),re=i.aT.convert(C),pe=.5*(te.lat+re.lat),me=.5*(te.lng+re.lng),fe=i.eZ(pe,me),Ne=i.aw([],fe),we=i.aw([],i.bI([],Ne,[0,1,0])),Re=i.bI([],we,Ne),Le=[we[0],we[1],we[2],0,Re[0],Re[1],Re[2],0,Ne[0],Ne[1],Ne[2],0,0,0,0,1],Ze=[fe,i.eZ(te.lat,te.lng),i.eZ(re.lat,te.lng),i.eZ(re.lat,re.lng),i.eZ(te.lat,re.lng),i.eZ(pe,te.lng),i.eZ(pe,re.lng),i.eZ(te.lat,me),i.eZ(re.lat,me)];let nt=i.d9.fromPoints(Ze.map(es=>[i.bJ(we,es),i.bJ(Re,es),i.bJ(Ne,es)]));const Xe=i.af([],nt.center,Le);i.e_(Xe)===0&&i.e$(Xe,0,0,1),i.aw(Xe,Xe),i.c5(Xe,Xe,i.aD),U.center=i.f0(Xe);const Mt=U.getWorldToCameraMatrix(),gt=i.bl(new Float64Array(16),Mt);nt=i.d9.applyTransform(nt,i.aB([],Mt,Le));const jt=this._extendAABB(nt,U,K,P);if(!jt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");nt=jt,i.af(Xe,Xe,Mt);const ft=.5*(nt.max[2]-nt.min[2]),ht=this._minimumAABBFrustumDistance(U,nt),At=i.c5([],[0,0,1],ft),Ut=i.d8(At,Xe,At),Bt=ht+(U.pitch===0?0:i.bG(Xe,Ut)),ts=U.globeCenterInViewSpace,rs=i.av([],Xe,[ts[0],ts[1],ts[2]]);i.aw(rs,rs),i.c5(rs,rs,Bt);const ms=i.d8([],Xe,rs);i.af(ms,ms,gt);const Ds=i.eM/i.aD,Yt=i.ag(ms),Pt=i.cf(Math.max(Yt*Ds-i.eM,Number.EPSILON),0),is=Math.min(U.zoomFromMercatorZAdjusted(Pt),K.maxZoom);return is>.5*(i.c_+i.cL)?(U.setProjection({name:"mercator"}),U.zoom=is,this._cameraForBounds(U,x,C,P,R,F)):{center:U.center,zoom:is,bearing:P,pitch:R}}_extendAABB(u,x,C,P){const R=.5*((C.padding.left||0)+(C.padding.right||0)),F=.5*((C.padding.top||0)+(C.padding.bottom||0)),U=F,K=R,te=R,re=F,pe=x.width-(K+te),me=x.height-(U+re),fe=i.av([],u.max,u.min),Ne=Math.min(pe/fe[0],me/fe[1]),we=Math.min(x.scaleZoom(x.scale*Ne),C.maxZoom);if(isNaN(we))return null;const Re=x.scale/x.zoomScale(we),Le=new i.d9([u.min[0]-K*Re,u.min[1]-re*Re,u.min[2]],[u.max[0]+te*Re,u.max[1]+U*Re,u.max[2]]),Ze=(typeof C.offset.x=="number"&&typeof C.offset.y=="number"?new i.P(C.offset.x,C.offset.y):i.P.convert(C.offset)).rotate(-i.an(P));return Le.center[0]-=Ze.x*Re,Le.center[1]+=Ze.y*Re,Le}queryTerrainElevation(u,x){const C=this.transform.elevation;return C?(x=Object.assign({},{exaggerated:!0},x),C.getAtPoint(i.ae.fromLngLat(u),null,x.exaggerated)):null}_cameraForBounds(u,x,C,P,R,F){if(u.projection.name==="globe")return this._cameraForBoundsOnGlobe(u,x,C,P,R,F);const U=u.clone(),K=this._extendCameraOptions(F);U.bearing=P,U.pitch=R;const te=i.aT.convert(x),re=i.aT.convert(C),pe=new i.aT(te.lng,re.lat),me=new i.aT(re.lng,te.lat),fe=U.project(te),Ne=U.project(re),we=this.queryTerrainElevation(te),Re=this.queryTerrainElevation(re),Le=this.queryTerrainElevation(pe),Ze=this.queryTerrainElevation(me),nt=[[fe.x,fe.y,Math.min(we||0,Re||0,Le||0,Ze||0)],[Ne.x,Ne.y,Math.max(we||0,Re||0,Le||0,Ze||0)]];let Xe=i.d9.fromPoints(nt);const Mt=U.getWorldToCameraMatrix(),gt=i.bl(new Float64Array(16),Mt);Xe=i.d9.applyTransform(Xe,Mt);const jt=this._extendAABB(Xe,U,K,P);if(!jt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Xe=jt;const ft=.5*i.av([],Xe.max,Xe.min)[2],ht=this._minimumAABBFrustumDistance(U,Xe),At=[0,0,1,0];i.aC(At,At,Mt),i.f1(At,At);const Ut=i.c5([],At,ht+ft),Bt=i.d8([],Xe.center,Ut);i.af(Xe.center,Xe.center,gt),i.af(Bt,Bt,gt);const ts=U.unproject(new i.P(Xe.center[0],Xe.center[1])),rs=i.f2(U.projection,ts),ms=Math.pow(2,rs),Ds=Math.min(U._zoomFromMercatorZ(Bt[2]*U.pixelsPerMeter*ms/U.worldSize),K.maxZoom);return U.mercatorFromTransition&&Ds<.5*(i.c_+i.cL)?(U.setProjection({name:"globe"}),U.zoom=Ds,this._cameraForBounds(U,x,C,P,R,F)):{center:ts,zoom:Ds,bearing:P,pitch:R}}fitBounds(u,x,C){const P=this.cameraForBounds(u,x);return this._fitInternal(P,x,C)}fitScreenCoordinates(u,x,C,P,R){const F=i.P.convert(u),U=i.P.convert(x),K=new i.P(Math.min(F.x,U.x),Math.min(F.y,U.y)),te=new i.P(Math.max(F.x,U.x),Math.max(F.y,U.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(F,U))return this;const re=this.transform.pointLocation3D(K),pe=this.transform.pointLocation3D(te),me=this.transform.pointLocation3D(new i.P(K.x,te.y)),fe=this.transform.pointLocation3D(new i.P(te.x,K.y)),Ne=[Math.min(re.lng,pe.lng,me.lng,fe.lng),Math.min(re.lat,pe.lat,me.lat,fe.lat)],we=[Math.max(re.lng,pe.lng,me.lng,fe.lng),Math.max(re.lat,pe.lat,me.lat,fe.lat)],Re=P&&P.pitch?P.pitch:this.getPitch(),Le=this._cameraForBounds(this.transform,Ne,we,C,Re,P);return this._fitInternal(Le,P,R)}_fitInternal(u,x,C){return u?(x=Object.assign(u,x)).linear?this.easeTo(x,C):this.flyTo(x,C):this}jumpTo(u,x){this.stop();const C=u.preloadOnly?this.transform.clone():this.transform;let P=!1,R=!1,F=!1;"zoom"in u&&C.zoom!==+u.zoom&&(P=!0,C.zoom=+u.zoom),u.center!==void 0&&(C.center=i.aT.convert(u.center)),"bearing"in u&&C.bearing!==+u.bearing&&(R=!0,C.bearing=+u.bearing),"pitch"in u&&C.pitch!==+u.pitch&&(F=!0,C.pitch=+u.pitch);const U=typeof u.padding=="number"?this._extendPadding(u.padding):u.padding;if(u.padding!=null&&!C.isPaddingEqual(U))if(u.retainPadding===!1){const K=C.clone();K.padding=U,C.setLocationAtPoint(C.center,K.centerPoint)}else C.padding=U;return u.preloadOnly?(this._preloadTiles(C),this):(this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),P&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),R&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),F&&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(WS),this.transform.getFreeCameraOptions()}setFreeCameraOptions(u,x){const C=this.transform;if(!C.projection.supportsFreeCamera)return i.w(WS),this;this.stop();const P=C.zoom,R=C.pitch,F=C.bearing;C.setFreeCameraOptions(u);const U=P!==C.zoom,K=R!==C.pitch,te=F!==C.bearing;return this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),U&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),te&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),K&&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(u,x){this._stop(!1,u.easeId),((u=Object.assign({offset:[0,0],duration:500,easing:i.eV},u)).animate===!1||this._prefersReducedMotion(u))&&(u.duration=0);const C=this.transform,P=this.getZoom(),R=this.getBearing(),F=this.getPitch(),U=this.getPadding(),K="zoom"in u?+u.zoom:P,te="bearing"in u?this._normalizeBearing(u.bearing,R):R,re="pitch"in u?+u.pitch:F,pe=this._extendPadding(u.padding),me=i.P.convert(u.offset);let fe,Ne,we;if(C.projection.name==="globe"){const At=i.ae.fromLngLat(C.center),Ut=me.rotate(-C.angle);At.x+=Ut.x/C.worldSize,At.y+=Ut.y/C.worldSize;const Bt=At.toLngLat(),ts=i.aT.convert(u.center||Bt);this._normalizeCenter(ts),fe=C.centerPoint.add(Ut),Ne=new i.P(At.x,At.y).mult(C.worldSize),we=new i.P(i.aF(ts.lng),i.aJ(ts.lat)).mult(C.worldSize).sub(Ne)}else{fe=C.centerPoint.add(me);const At=C.pointLocation(fe),Ut=i.aT.convert(u.center||At);this._normalizeCenter(Ut),Ne=C.project(At),we=C.project(Ut).sub(Ne)}const Re=C.zoomScale(K-P);let Le,Ze;u.around&&(Le=i.aT.convert(u.around),Ze=C.locationPoint(Le));const nt=this._zooming||K!==P,Xe=this._rotating||R!==te,Mt=this._pitching||re!==F,gt=!C.isPaddingEqual(pe),jt=u.retainPadding===!1?C.clone():C,ft=At=>Ut=>{if(nt&&(At.zoom=i.ak(P,K,Ut)),Xe&&(At.bearing=i.ak(R,te,Ut)),Mt&&(At.pitch=i.ak(F,re,Ut)),gt&&(jt.interpolatePadding(U,pe,Ut),fe=jt.centerPoint.add(me)),Le)At.setLocationAtPoint(Le,Ze);else{const Bt=At.zoomScale(At.zoom-P),ts=K>P?Math.min(2,Re):Math.max(.5,Re),rs=Math.pow(ts,1-Ut),ms=At.unproject(Ne.add(we.mult(Ut*rs)).mult(Bt));At.setLocationAtPoint(At.renderWorldCopies?ms.wrap():ms,fe)}return u.preloadOnly||this._fireMoveEvents(x),At};if(u.preloadOnly){const At=this._emulate(ft,u.duration,C);return this._preloadTiles(At),this}const ht={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=nt,this._rotating=Xe,this._pitching=Mt,this._padding=gt,this._easeId=u.easeId,this._prepareEase(x,u.noMoveStart,ht),this._ease(ft(C),At=>{C.cameraElevationReference==="sea"&&C.recenterOnTerrain(),this._afterEase(x,At)},u),this}_prepareEase(u,x,C={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),x||C.moving||this.fire(new i.z("movestart",u)),this._zooming&&!C.zooming&&this.fire(new i.z("zoomstart",u)),this._rotating&&!C.rotating&&this.fire(new i.z("rotatestart",u)),this._pitching&&!C.pitching&&this.fire(new i.z("pitchstart",u))}_fireMoveEvents(u){this.fire(new i.z("move",u)),this._zooming&&this.fire(new i.z("zoom",u)),this._rotating&&this.fire(new i.z("rotate",u)),this._pitching&&this.fire(new i.z("pitch",u))}_afterEase(u,x){if(this._easeId&&x&&this._easeId===x)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const C=this._zooming,P=this._rotating,R=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,C&&this.fire(new i.z("zoomend",u)),P&&this.fire(new i.z("rotateend",u)),R&&this.fire(new i.z("pitchend",u)),this.fire(new i.z("moveend",u))}flyTo(u,x){if(this._prefersReducedMotion(u)){const es=i.aH(u,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(es,x)}this.stop(),u=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},u);const C=this.transform,P=this.getZoom(),R=this.getBearing(),F=this.getPitch(),U=this.getPadding(),K="zoom"in u?i.aA(+u.zoom,C.minZoom,C.maxZoom):P,te="bearing"in u?this._normalizeBearing(u.bearing,R):R,re="pitch"in u?+u.pitch:F,pe=this._extendPadding(u.padding),me=C.zoomScale(K-P),fe=i.P.convert(u.offset);let Ne=C.centerPoint.add(fe);const we=C.pointLocation(Ne),Re=i.aT.convert(u.center||we);this._normalizeCenter(Re);const Le=C.project(we),Ze=C.project(Re).sub(Le);let nt=u.curve;const Xe=Math.max(C.width,C.height),Mt=Xe/me,gt=Ze.mag();if("minZoom"in u){const es=i.aA(Math.min(u.minZoom,P,K),C.minZoom,C.maxZoom),ks=Xe/C.zoomScale(es-P);nt=Math.sqrt(ks/gt*2)}const jt=nt*nt;function ft(es){const ks=(Mt*Mt-Xe*Xe+(es?-1:1)*jt*jt*gt*gt)/(2*(es?Mt:Xe)*jt*gt);return Math.log(Math.sqrt(ks*ks+1)-ks)}function ht(es){return(Math.exp(es)-Math.exp(-es))/2}function At(es){return(Math.exp(es)+Math.exp(-es))/2}const Ut=ft(0);let Bt=function(es){return At(Ut)/At(Ut+nt*es)},ts=function(es){return Xe*((At(Ut)*(ht(ks=Ut+nt*es)/At(ks))-ht(Ut))/jt)/gt;var ks},rs=(ft(1)-Ut)/nt;if(Math.abs(gt)<1e-6||!isFinite(rs)){if(Math.abs(Xe-Mt)<1e-6)return this.easeTo(u,x);const es=Mtu.maxDuration&&(u.duration=0);const ms=R!==te,Ds=re!==F,Yt=!C.isPaddingEqual(pe),Pt=u.retainPadding===!1?C.clone():C,is=es=>ks=>{const Gs=ks*rs,dr=1/Bt(Gs);es.zoom=ks===1?K:P+es.scaleZoom(dr),ms&&(es.bearing=i.ak(R,te,ks)),Ds&&(es.pitch=i.ak(F,re,ks)),Yt&&(Pt.interpolatePadding(U,pe,ks),Ne=Pt.centerPoint.add(fe));const qs=ks===1?Re:es.unproject(Le.add(Ze.mult(ts(Gs))).mult(dr));return es.setLocationAtPoint(es.renderWorldCopies?qs.wrap():qs,Ne),es._updateCameraOnTerrain(),u.preloadOnly||this._fireMoveEvents(x),es};if(u.preloadOnly){const es=this._emulate(is,u.duration,C);return this._preloadTiles(es),this}return this._zooming=!0,this._rotating=ms,this._pitching=Ds,this._padding=Yt,this._prepareEase(x,!1),this._ease(is(C),()=>this._afterEase(x),u),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(u){}_cancelRenderFrame(u){}_stop(u,x){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const C=this._onEaseEnd;this._onEaseEnd=void 0,C.call(this,x)}if(!u){const C=this.handlers;C&&C.stop(!1)}return this}_ease(u,x,C){C.animate===!1||C.duration===0?(u(1),x()):(this._easeStart=i.o.now(),this._easeOptions=C,this._onEaseFrame=u,this._onEaseEnd=x,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const u=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),x=this._onEaseFrame;x&&x(this._easeOptions.easing(u)),u<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(u,x){u=i.bT(u,-180,180);const C=Math.abs(u-x);return Math.abs(u-360-x)180?-360:C<-180?360:0}_prefersReducedMotion(u){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(u&&u.essential)}_emulate(u,x,C){const P=Math.ceil(15*x/1e3),R=[],F=u(C.clone());for(let U=0;U<=P;U++){const K=F(U/P);R.push(K.clone())}return R}_preloadTiles(u,x){}}class X_{constructor(u={}){this.options=u,i.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(u){const x=this.options&&this.options.compact,C=u._getUIString("AttributionControl.ToggleAttribution");this._map=u,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=w("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",C);const P=w("span","mapboxgl-ctrl-icon",this._compactButton);return P.setAttribute("aria-hidden","true"),P.setAttribute("title",C),this._innerContainer=w("div","mapboxgl-ctrl-attrib-inner",this._container),x&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),x===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let u=this._editLink;u||(u=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(u){const C=x.reduce((P,R,F)=>(R.value&&(P+=`${R.key}=${R.value}${FP.length-R.length),u=u.filter((P,R)=>{for(let F=R+1;F=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?u=[...this.options.customAttribution,...u]:u.unshift(this.options.customAttribution));const C=u.map(P=>function(R){const F=new DOMParser().parseFromString(R,"text/html");return Array.from(F.body.querySelectorAll("*")).forEach(U=>{const K=U.textContent||"";if(U.tagName!=="A")return void U.replaceWith(F.createTextNode(K));const te=U.getAttribute("href");if(!te||!/^(https?:|mailto:)/i.test(te))return void U.replaceWith(F.createTextNode(K));const re=F.createElement("a");re.href=te,re.textContent=K,re.rel="noopener nofollow";const pe=U.getAttribute("class");pe&&(re.className=pe),U.replaceWith(re)}),F.body.innerHTML}(P)).join(" | ");C!==this._attribHTML&&(this._attribHTML=C,u.length?(this._innerContainer.innerHTML=C,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 Q_{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(u){this._map=u,this._container=w("div","mapboxgl-ctrl");const x=w("a","mapboxgl-ctrl-logo");return x.target="_blank",x.rel="noopener nofollow",x.href="https://www.mapbox.com/",x.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),x.setAttribute("rel","noopener nofollow"),this._container.appendChild(x),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(u){u&&u.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const u=this._map.style._sourceCaches;if(Object.entries(u).length===0)return!0;for(const x in u){const C=u[x].getSource();if(C.hasOwnProperty("mapbox_logo")&&!C.mapbox_logo)return!1}return!0}_updateCompact(){const u=this._container.children;if(u.length){const x=u[0];this._map.getCanvasContainer().offsetWidth<250?x.classList.add("mapboxgl-compact"):x.classList.remove("mapboxgl-compact")}}}class rv{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(u){return this._map=u,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",x=>this._onIndoorUpdate(x)),this._container}_createButton(u,x){const C=w("button",u,this._container);return C.type="button",C.addEventListener("click",x),C}_createSeparator(){return w("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(u,x){this._map&&(u.setAttribute("aria-label",x),u.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(u){if(!u||!u.floors)return this._model=u,void(this._container.style.display="none");const x=this._model;this._model=u,this._container.style.display="inline-block",this._container.style.borderRadius="8px",x&&Array.from(this._container.children).forEach(C=>C.remove()),u.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(u.floors,u.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const u=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const x=this._map;this._model&&x&&x._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});w("span","mapboxgl-ctrl-icon",u).setAttribute("aria-hidden","true"),u.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&u.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(u),this._createSeparator()}_updateBuildingsButtonState(){const u=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");u&&this._model&&(this._model.activeFloorsVisible?u.classList.remove("mapboxgl-ctrl-level-button-selected"):u.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(u,x){for(let C=0;C{this._map._selectIndoorFloor(P.id)});this._setButtonTitle(R,P.zIndex.toString()),this._model&&P.id===this._model.selectedFloorId&&x&&R.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(R),C=this._endTime)return this._end;const x=i.dD((u-this._startTime)/(this._endTime-this._startTime));return this._start*(1-x)+this._end*x}isEasing(u){return u>=this._startTime&&u<=this._endTime}jumpTo(u){this._startTime=-1/0,this._endTime=-1/0,this._start=u,this._end=u}easeTo(u,x,C){this._start=this.getValue(x),this._end=u,this._startTime=x,this._endTime=x+C}}const Nf={"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 Yg extends i.z{constructor(u,x,C,P){const{point:R,lngLat:F,originalEvent:U,target:K}=u;super(u.type,{point:R,lngLat:F,originalEvent:U,target:K}),this.preventDefault=()=>{u.preventDefault()},this.id=x,this.interaction=C,this.feature=P}}class Sm{constructor(u){this.map=u,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(u,x){if(this.typeById.has(u))throw new Error(`Interaction id "${u}" already exists.`);const C=x.filter;let P=x.type;C&&this.filters.set(u,i.b6(C)),P==="mouseover"&&(P="mouseenter"),P==="mouseout"&&(P="mouseleave");const R=this.interactionsByType.get(P)||new Map;P==="mouseenter"||P==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(u,x)):R.size===0&&this.map.on(P,this.handleType),R.size===0&&this.interactionsByType.set(P,R),R.set(u,x),this.typeById.set(u,P)}get(u){const x=this.typeById.get(u);if(!x)return;const C=this.interactionsByType.get(x);return C?C.get(u):void 0}remove(u){const x=this.typeById.get(u);if(!x)return;this.typeById.delete(u),this.filters.delete(u);const C=this.interactionsByType.get(x);C&&(C.delete(u),x==="mouseenter"||x==="mouseleave"?(this.delegatedInteractions.delete(u),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):C.size===0&&this.map.off(x,this.handleType))}queryTargets(u,x){const C=[];for(const[P,R]of x)R.target&&C.push({targetId:P,target:R.target,filter:this.filters.get(P)});return this.map.style.queryRenderedTargets(u,C,this.map.transform)}handleMove(u){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const x=this.queryTargets(u.point,Array.from(this.delegatedInteractions).reverse());x.length&&(u.type="mouseenter",this.handleType(u,x));const C=new Map;for(const[P,{feature:R}]of this.prevHoveredFeatures)this.hoveredFeatures.has(P)||C.set(R.id,R);C.size&&(u.type="mouseleave",this.handleType(u,Array.from(C.values())))}handleOut(u){const x=Array.from(this.hoveredFeatures.values()).map(({feature:C})=>C);x.length&&(u.type="mouseleave",this.handleType(u,x)),this.hoveredFeatures.clear()}handleType(u,x){const C=u.type==="mouseenter";if(C&&!this.interactionsByType.has(u.type))return void i.w("mouseenter interaction required for mouseleave to work.");const P=Array.from(this.interactionsByType.get(u.type)).reverse(),R=!!x;x=x||this.queryTargets(u.point,P);let F=!1;const U=new Set;for(const K of x){for(const[te,re]of P){if(!re.target)continue;const pe=K.variants?K.variants[te]:null;if(pe){for(const me of pe){if(Lg(me,K,U,te))continue;const fe=new i.dx(K,me),Ne=df(me,K,te);R&&fe.id!==void 0&&(fe.state=this.map.getFeatureState(fe));const we=C?this.prevHoveredFeatures.get(Ne):null,Re=new Yg(u,te,re,fe),Le=we?we.stop:re.handler(Re);if(C&&this.hoveredFeatures.set(Ne,{feature:K,stop:Le}),Le!==!1){F=!0;break}}if(F)break}}if(F)break}if(!F)for(const[K,te]of P){const{handler:re,target:pe}=te;if(!pe&&re(new Yg(u,K,te,null))!==!1)break}}}function _ce(N,u){if(Array.isArray(N)&&Array.isArray(u)){const x=new Set(N),C=new Set(u);return x.size===C.size&&N.every(P=>C.has(P))}return i.by(N,u)}const bce={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"},wce={showCompass:!0,showZoom:!0,visualizePitch:!1};class jce{constructor(u,x,C=!1){this._clickTolerance=10,this.element=x,this.mouseRotate=new hT({clickTolerance:u.dragRotate._mouseRotate._clickTolerance}),this.map=u,C&&(this.mousePitch=new mT({clickTolerance:u.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(u,x){this.mouseRotate.mousedown(u,x),this.mousePitch&&this.mousePitch.mousedown(u,x),D()}move(u,x){const C=this.map,P=this.mouseRotate.mousemoveWindow(u,x),R=P&&P.bearingDelta;if(R&&C.setBearing(C.getBearing()+R),this.mousePitch){const F=this.mousePitch.mousemoveWindow(u,x),U=F&&F.pitchDelta;U&&C.setPitch(C.getPitch()+U)}}off(){const u=this.element;u.removeEventListener("mousedown",this.mousedown),u.removeEventListener("touchstart",this.touchstart),u.removeEventListener("touchmove",this.touchmove),u.removeEventListener("touchend",this.touchend),u.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){L(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(u){this.down(Object.assign({},u,{ctrlKey:!0,preventDefault:()=>u.preventDefault()}),V(this.element,u)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(u){this.move(u,V(this.element,u))}mouseup(u){this.mouseRotate.mouseupWindow(u),this.mousePitch&&this.mousePitch.mouseupWindow(u),this.offTemp()}touchstart(u){u.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=W(this.element,u.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>u.preventDefault()},this._startPos))}touchmove(u){u.targetTouches.length!==1?this.reset():(this._lastPos=W(this.element,u.targetTouches)[0],this.move({preventDefault:()=>u.preventDefault()},this._lastPos))}touchend(u){u.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)x.width||u.y>x.height;x.locationPoint3D(C).distSqr(u)180;){const C=x.locationPoint3D(N);if(C.x>=0&&C.y>=0&&C.x<=x.width&&C.y<=x.height)break;N.lng>x.center.lng?N.lng-=360:N.lng+=360}return N}const ed={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%)"},zh={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class GS extends i.E{constructor(u,x){super(),(u instanceof HTMLElement||x)&&(u=Object.assign({element:u},x)),i.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:C="center",color:P="#3FB1CE",scale:R=1,draggable:F=!1,clickTolerance:U=0,rotation:K=zh.rotation,rotationAlignment:te=zh.rotationAlignment,pitchAlignment:re=zh.pitchAlignment,occludedOpacity:pe=zh.occludedOpacity,altitude:me=zh.altitude}=u||{};this._anchor=C,this._color=P,this._scale=R,this._draggable=F,this._clickTolerance=U,this._rotation=K,this._rotationAlignment=te,this._pitchAlignment=re,this._occludedOpacity=pe,this._altitude=me,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),u&&u.element?(this._element=u.element,this._offset=i.P.convert(u&&u.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=i.P.convert(u&&u.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",we=>{we.preventDefault()}),this._element.addEventListener("mousedown",we=>{we.preventDefault()});const fe=this._element.classList;for(const we in ed)fe.remove(`mapboxgl-marker-anchor-${we}`);fe.add(`mapboxgl-marker-anchor-${this._anchor}`);const Ne=u&&u.className?u.className.trim().split(/\s+/):[];fe.add(...Ne),this._popup=null}_createDefaultMarker(){const u=w("div"),x=k("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},u);if(this._altitude===0){const C=k("radialGradient",{id:"shadowGradient"},k("defs",{},x));k("stop",{offset:"10%","stop-opacity":.4},C),k("stop",{offset:"100%","stop-opacity":.05},C),k("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},x)}return k("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),k("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),k("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},x),u}addTo(u){return u===this._map||(this.remove(),this._map=u,u.getCanvasContainer().appendChild(this._element),u.on("move",this._updateMoving),u.on("moveend",this._update),u.on("remove",this._clearFadeTimer),u._addMarker(this),this.setDraggable(this._draggable),this._update(),u.on("click",this._onMapClick)),this}remove(){const u=this._map;return u&&(u.off("click",this._onMapClick),u.off("move",this._updateMoving),u.off("moveend",this._update),u.off("mousedown",this._addDragHandler),u.off("touchstart",this._addDragHandler),u.off("mouseup",this._onUp),u.off("touchend",this._onUp),u.off("mousemove",this._onMove),u.off("touchmove",this._onMove),u.off("remove",this._clearFadeTimer),u._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(u){return this._lngLat=i.aT.convert(u),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(u){return u===this._altitude||(this._defaultMarker&&(this._altitude===0&&u!==0||this._altitude!==0&&u===0)&&(this._element=this._createDefaultMarker()),this._altitude=u||zh.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(u){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")),u){if(!("offset"in u.options)){const P=Math.sqrt(Math.pow(13.5,2)/2);u.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[P,-1*(38.1-13.5+P)],"bottom-right":[-P,-1*(38.1-13.5+P)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=u,u._marker=this,u._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(u){const x=u.code,C=u.charCode||u.keyCode;x!=="Space"&&x!=="Enter"&&C!==32&&C!==13||this.togglePopup()}_onMapClick(u){const x=u.originalEvent.target,C=this._element;this._popup&&(x===C||C.contains(x))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const u=this._popup;return u?(u.isOpen()?(u.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(u.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const u=this._map,x=this._pos;if(!u||!x)return!1;const C=u.unproject(x,this._altitude),P=u.getFreeCameraOptions();if(!P.position)return!1;const R=P.position.toLngLat();return R.distanceTo(C)<.9*R.distanceTo(this._lngLat)}_evaluateOpacity(){const u=this._map;if(!u)return;const x=this._pos;if(!x||x.x<0||x.x>u.transform.width||x.y<0||x.y>u.transform.height)return void this._clearFadeTimer();const C=u.unproject(x,this._altitude);let P;u._showingGlobe()&&i.f5(u.transform,this._lngLat)?P=0:(P=1-u._queryFogOpacity(C),u.transform._terrainEnabled()&&u.getTerrain()&&this._behindTerrain()&&(P*=this._occludedOpacity)),this._element.style.opacity=`${P}`,this._element.style.pointerEvents=P>0?"auto":"none",this._popup&&this._popup._setOpacity(P),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const u=this._pos;if(!u||!this._map)return;const x=this._offset.mult(this._scale);this._element.style.transform=` translate(${u.x}px,${u.y}px) ${ed[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${x.x}px,${x.y}px) `}_calculateXYTransform(){const u=this._pos,x=this._map,C=this.getPitchAlignment();if(!x||!u||C!=="map")return"";if(!x._showingGlobe()){const K=x.getPitch();return K?`rotateX(${K}deg)`:""}const P=i.cX(i.f6(x.transform,this._lngLat)),R=u.sub(i.f7(x.transform)),F=Math.abs(R.x)+Math.abs(R.y);if(F===0)return"";const U=P/F;return`rotateX(${-R.y*U}deg) rotateY(${R.x*U}deg)`}_calculateZTransform(){const u=this._pos,x=this._map;if(!x||!u)return"";let C=0;const P=this.getRotationAlignment();if(P==="map")if(x._showingGlobe()){const R=x.project(new i.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),F=x.project(new i.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(R);C=i.cX(Math.atan2(F.y,F.x))-90}else C=-x.getBearing();else if(P==="horizon"){const R=i.ah(4,6,x.getZoom()),F=i.f7(x.transform);F.y+=R*x.transform.height;const U=u.sub(F),K=i.cX(Math.atan2(U.y,U.x));C=(K>90?K-270:K+90)*(1-R)}return C+=this._rotation,C?`rotateZ(${C}deg)`:""}_update(u){cancelAnimationFrame(this._updateFrameId);const x=this._map;x&&(x.transform.renderWorldCopies&&(this._lngLat=xT(this._lngLat,this._pos,x.transform)),this._pos=x.project(this._lngLat,this._altitude),u===!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(u){return this._offset=i.P.convert(u),this._update(),this}addClassName(u){return this._element.classList.add(u),this}removeClassName(u){return this._element.classList.remove(u),this}toggleClassName(u){return this._element.classList.toggle(u)}_onMove(u){const x=this._map;if(!x)return;const C=this._pointerdownPos,P=this._positionDelta;if(C&&P){if(!this._isDragging){const R=this._clickTolerance||x._clickTolerance;if(u.point.dist(C)N.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(N.minPitch!=null&&N.maxPitch!=null&&N.minPitch>N.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(N.minPitch!=null&&N.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(N.maxPitch!=null&&N.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(N.antialias&&i.f3(window)&&(N.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 bM(N.minZoom,N.maxZoom,N.minPitch,N.maxPitch,N.renderWorldCopies,null,null),N),this._repaint=!!N.repaint,this._interactive=N.interactive,this._minTileCacheSize=N.minTileCacheSize,this._maxTileCacheSize=N.maxTileCacheSize,this._failIfMajorPerformanceCaveat=N.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=N.preserveDrawingBuffer,this._antialias=N.antialias,this._trackResize=N.trackResize,this._bearingSnap=N.bearingSnap,this._refreshExpiredTiles=N.refreshExpiredTiles,this._fadeDuration=N.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=N.crossSourceCollisions,this._collectResourceTiming=N.collectResourceTiming,this._language=this._parseLanguage(N.language),this._worldview=N.worldview,this._renderTaskQueue=new jf,this._domRenderTaskQueue=new jf,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},Nf,N.locale),this._clickTolerance=N.clickTolerance,this._cooperativeGestures=N.cooperativeGestures,this._performanceMetricsCollection=N.performanceMetricsCollection,this._tessellationStep=N.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=N.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new kf(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=N.scaleFactor,this._requestManager=new ee(N.transformRequest,N.accessToken,N.testMode),this._silenceAuthErrors=!!N.testMode,this._contextCreateOptions=N.contextCreateOptions?Object.assign({},N.contextCreateOptions):{},typeof N.container=="string"){const x=document.getElementById(N.container);if(!x)throw new Error(`Container '${N.container.toString()}' not found.`);this._container=x}else{if(!(N.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=N.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."),N.maxBounds&&this.setMaxBounds(N.maxBounds),this._spriteFormat=N.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 vce(this,N),this._localFontFamily=N.localFontFamily,this._localIdeographFontFamily=N.localIdeographFontFamily,(N.style||!N.testMode)&&this.setStyle(N.style||i.e.DEFAULT_STYLE,{config:N.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),N.projection&&this.setProjection(N.projection),N.hash&&(this._hash=new nT(typeof N.hash=="string"&&N.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){u.center==null&&u.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:N.center,zoom:N.zoom,bearing:N.bearing,pitch:N.pitch});const x=N.bounds;x&&(this.resize(),this.fitBounds(x,Object.assign({},N.fitBoundsOptions,{duration:0})))}this.resize(),N.attributionControl&&this.addControl(new X_({customAttribution:N.customAttribution})),this._logoControl=new Q_,this.addControl(this._logoControl,N.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 Sm(this)}_getMapId(){return this._mapId}addControl(N,u){if(u===void 0&&(u=N.getDefaultPosition?N.getDefaultPosition():"top-right"),!N||!N.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=N.onAdd(this);this._controls.push(N);const C=this._controlPositions[u];return u.indexOf("bottom")!==-1?C.insertBefore(x,C.firstChild):C.appendChild(x),this}removeControl(N){if(!N||!N.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 u=this._controls.indexOf(N);return u>-1&&this._controls.splice(u,1),N.onRemove(this),this}hasControl(N){return this._controls.indexOf(N)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(N){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 u=!this._moving;return u&&this.fire(new i.z("movestart",N)).fire(new i.z("move",N)),this.fire(new i.z("resize",N)),u&&this.fire(new i.z("moveend",N)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(N){return this.transform.setMaxBounds(i.aI.convert(N)),this._update()}setMinZoom(N){if((N=N??-2)>=-2&&N<=this.transform.maxZoom)return this.transform.minZoom=N,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=N,this._update(),this.getZoom()>N?this.setZoom(N):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(N){if((N=N??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(N>=0&&N<=this.transform.maxPitch)return this.transform.minPitch=N,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(N>=this.transform.minPitch)return this.transform.maxPitch=N,this._update(),this.getPitch()>N?this.setPitch(N):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(N){return this._scaleFactor=N,this.painter.scaleFactor=N,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(u=>u.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(N){return this.transform.renderWorldCopies=N,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(N){return N==="auto"?navigator.language:Array.isArray(N)?N.length===0?void 0:N.map(u=>u==="auto"?navigator.language:u):N}setLanguage(N){const u=this._parseLanguage(N);if(!this.style||u===this._language)return this;this._language=u,this.style.reloadSources();for(const x of this._controls)x._setLanguage&&x._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(N){return this.style&&N!==this._worldview?(this._worldview=N,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(N){return this._lazyInitEmptyStyle(),N?typeof N=="string"&&(N={name:N}):N=null,this._useExplicitProjection=!!N,this._prioritizeAndUpdateProjection(N,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const N=this.transform,u=N.projection.name;let x;u==="globe"&&N.zoom>=i.cL?(N.setMercatorFromTransition(),x=!0):u==="mercator"&&N.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(N),this.style.applyProjectionUpdate();const C=this.transform.getProjection().name==="mercator"&&x!==this.transform.mercatorFromTransition;return(u||C)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(N,u){return this.transform.locationPoint3D(i.aT.convert(N),u)}unproject(N,u){return this.transform.pointLocation3D(i.P.convert(N),u)}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(N,u,x){const C=P=>{let R=[];if(Array.isArray(u)){const F=u.filter(U=>this.getLayer(U));R=F.length?this.queryRenderedFeatures(P,{layers:F}):[]}else R=this.queryRenderedFeatures(P,{target:u});return R};if(N==="mouseenter"||N==="mouseover"){let P=!1;return{listener:x,targets:u,delegates:{mousemove:F=>{const U=C(F.point);U.length?P||(P=!0,x.call(this,new lu(N,this,F.originalEvent,{features:U}))):P=!1},mouseout:()=>{P=!1}}}}if(N==="mouseleave"||N==="mouseout"){let P=!1;return{listener:x,targets:u,delegates:{mousemove:U=>{C(U.point).length?P=!0:P&&(P=!1,x.call(this,new lu(N,this,U.originalEvent)))},mouseout:U=>{P&&(P=!1,x.call(this,new lu(N,this,U.originalEvent)))}}}}{const P=R=>{const F=C(R.point);F.length&&(R.features=F,x.call(this,R),delete R.features)};return{listener:x,targets:u,delegates:{[N]:P}}}}on(N,u,x){if(typeof u=="function"||x===void 0)return super.on(N,u);if(typeof u=="string"&&(u=[u]),!this._areTargetsValid(u))return this;const C=this._createDelegatedListener(N,u,x);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[N]=this._delegatedListeners[N]||[],this._delegatedListeners[N].push(C);for(const P in C.delegates)this.on(P,C.delegates[P]);return this}once(N,u,x){if(typeof u=="function"||x===void 0)return super.once(N,u);if(typeof u=="string"&&(u=[u]),!this._areTargetsValid(u))return this;const C=this._createDelegatedListener(N,u,x);for(const P in C.delegates)this.once(P,C.delegates[P]);return this}off(N,u,x){if(typeof u=="function"||x===void 0)return super.off(N,u);if(typeof u=="string"&&(u=[u]),!this._areTargetsValid(u))return this;const C=this._delegatedListeners?this._delegatedListeners[N]:void 0;return C&&(P=>{for(let R=0;R{if(x){const P=typeof x=="string"?x:x instanceof Error?x.message:x.error;i.w(`Unable to perform style diff: ${P}. Rebuilding the style from scratch.`),this._updateStyle(N,u)}else C&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=u.localIdeographFontFamily,this._localFontFamily=u.localFontFamily,this._updateStyle(N,u))}_getUIString(N){const u=this._locale[N];if(u==null)throw new Error(`Missing UI string '${N}'`);return u}_updateStyle(N,u){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),N){const x=Object.assign({},u);u&&u.config&&(x.initialConfig=u.config,delete x.config),this.style=new Fh(this,x).load(N),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Fh(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(N){return N==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(N)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${N}".`))),!1)}_isTargetValid(N){return"featuresetId"in N?this._isValidId("importId"in N?N.importId:N.featuresetId):"layerId"in N&&this._isValidId(N.layerId)}_areTargetsValid(N){if(Array.isArray(N)){for(const u of N)if(!this._isValidId(u))return!1;return!0}return this._isTargetValid(N)}addSource(N,u){return this._isValidId(N)?(this._lazyInitEmptyStyle(),this.style.addSource(N,u),this._update(!0)):this}isSourceLoaded(N){return!!this._isValidId(N)&&!!this.style&&this.style._isSourceCacheLoaded(N)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(N,u,x){this._lazyInitEmptyStyle(),this.style.addSourceType(N,u,x)}removeSource(N){return this._isValidId(N)?(this.style.removeSource(N),this._updateTerrain(),this._update(!0)):this}getSource(N){return this._isValidId(N)?this.style.getOwnSource(N):null}addImage(N,u,{pixelRatio:x=1,sdf:C=!1,stretchX:P,stretchY:R,content:F}={}){this._lazyInitEmptyStyle();const U=i.I.from(N);if(u instanceof HTMLImageElement||ImageBitmap&&u instanceof ImageBitmap){const{width:K,height:te,data:re}=i.o.getImageData(u);this.style.addImage(U,{data:new i.q({width:K,height:te},re),pixelRatio:x,stretchX:P,stretchY:R,content:F,sdf:C,version:0,usvg:!1})}else if(u.width===void 0||u.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:K,height:te}=u,re=u;this.style.addImage(U,{data:new i.q({width:K,height:te},new Uint8Array(re.data)),pixelRatio:x,stretchX:P,stretchY:R,content:F,sdf:C,usvg:!1,version:0,userImage:re}),re.onAdd&&re.onAdd(this,N)}}updateImage(N,u){this._lazyInitEmptyStyle();const x=i.I.from(N),C=this.style.getImage(x);if(!C)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 P=u instanceof HTMLImageElement||ImageBitmap&&u instanceof ImageBitmap?i.o.getImageData(u):u,{width:R,height:F,data:U}=P;if(R===void 0||F===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(R!==(C.usvg?C.icon.usvg_tree.width:C.data.width)||F!==(C.usvg?C.icon.usvg_tree.height:C.data.height))return void this.fire(new i.y(new Error(`The width and height of the updated image (${R}, ${F}) must be that same as the previous version of the image (${C.data.width}, ${C.data.height})`)));const K=!(u instanceof HTMLImageElement||ImageBitmap&&u instanceof ImageBitmap);let te=!1;C.usvg?(C.data=new i.q({width:R,height:F},new Uint8Array(U)),C.usvg=!1,C.icon=void 0,te=!0):C.data.replace(U,K),this.style.updateImage(x,C,te)}hasImage(N){return N?!!this.style&&!!this.style.getImage(i.I.from(N)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(N){this.style.removeImage(i.I.from(N))}loadImage(N,u){i.n(this._requestManager.transformRequest(N,i.R.Image),(x,C)=>{u(x,C instanceof HTMLImageElement?i.o.getImageData(C):C)})}listImages(){return this.style.listImages().map(N=>N.name)}addModel(N,u){this._lazyInitEmptyStyle(),this.style.addModel(N,u)}hasModel(N){return N?this.style.hasModel(N):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(N){this.style.removeModel(N)}listModels(){return this.style.listModels()}addLayer(N,u){return this._isValidId(N.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(N,u),this._update(!0)):this}getSlot(N){const u=this.getLayer(N);return u&&u.slot||null}setSlot(N,u){return this.style.setSlot(N,u),this.style.mergeLayers(),this._update(!0)}addImport(N,u){return this.style.addImport(N,u).catch(x=>this.fire(new i.y(new Error("Failed to add import",x)))),this}updateImport(N,u){return typeof u!="string"&&u.id!==N?(this.removeImport(N),this.addImport(u)):(this.style.updateImport(N,u),this._update(!0))}removeImport(N){return this.style.removeImport(N),this}moveImport(N,u){return this.style.moveImport(N,u),this._update(!0)}moveLayer(N,u){return this._isValidId(N)?(this.style.moveLayer(N,u),this._update(!0)):this}removeLayer(N){return this._isValidId(N)?(this.style.removeLayer(N),this._update(!0)):this}getLayer(N){if(!this._isValidId(N))return null;const u=this.style.getOwnLayer(N);return u?u.type==="custom"?u.implementation:u.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(N,u,x){return this._isValidId(N)?(this.style.setLayerZoomRange(N,u,x),this._update(!0)):this}setFilter(N,u,x={}){return this._isValidId(N)?(this.style.setFilter(N,u,x),this._update(!0)):this}getFilter(N){return this._isValidId(N)?this.style.getFilter(N):null}setPaintProperty(N,u,x,C={}){return this._isValidId(N)?(this.style.setPaintProperty(N,u,x,C),this._update(!0)):this}getPaintProperty(N,u){return this._isValidId(N)?this.style.getPaintProperty(N,u):null}setLayoutProperty(N,u,x,C={}){return this._isValidId(N)?(this.style.setLayoutProperty(N,u,x,C),this._update(!0)):this}getLayoutProperty(N,u){return this._isValidId(N)?this.style.getLayoutProperty(N,u):null}setLayerProperty(N,u,x,C={}){return this._isValidId(N)?(u==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(N,u,x,C),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(N){return this.style.setGlyphsUrl(N),this._update(!0)}getSchema(N){return this.style.getSchema(N)}setSchema(N,u){return this.style.setSchema(N,u),this._update(!0)}getConfig(N){return this.style.getConfig(N)}setConfig(N,u){return this.style.setConfig(N,u),this._update(!0)}getConfigProperty(N,u){return this.style.getConfigProperty(N,u)}setConfigProperty(N,u,x){return this.style.setConfigProperty(N,u,x),this._update(!0)}getFeaturesetDescriptors(N){return this.style.getFeaturesetDescriptors(N)}setLights(N){if(this._lazyInitEmptyStyle(),N&&N.length===1&&N[0].type==="flat"){const u=N[0];u.properties?this.style.setFlatLight(u.properties,u.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(N),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const N=this.style.getLights()||[];return N.length===0&&N.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),N}setLight(N,u={}){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:N}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(N){return this._lazyInitEmptyStyle(),!N&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(N),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(N){return this._lazyInitEmptyStyle(),this.style.setFog(N),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(N){return this._lazyInitEmptyStyle(),this.style.setSnow(N),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(N){return this._lazyInitEmptyStyle(),this.style.setRain(N),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(N){return this._lazyInitEmptyStyle(),this.style.setColorTheme(N),this._update(!0)}setImportColorTheme(N,u){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(N,u),this._update(!0)}setCamera(N){return this.style.setCamera(N),this._triggerCameraUpdate(N)}_triggerCameraUpdate(N){return this._update(this.transform.setOrthographicProjectionAtLowPitch(N["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(N){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(N),this.transform):0}setFeatureState(N,u){return N.source&&!this._isValidId(N.source)?this:(this.style.setFeatureState(N,u),this._update())}removeFeatureState(N,u){return N.source&&!this._isValidId(N.source)?this:(this.style.removeFeatureState(N,u),this._update())}getFeatureState(N){return N.source&&!this._isValidId(N.source)?null:this.style.getFeatureState(N)}_selectIndoorFloor(N){this.indoor.selectFloor(N)}_setIndoorActiveFloorsVisibility(N){this.indoor.setActiveFloorsVisibility(N)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new rv),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const N=this._container.getBoundingClientRect().width||400,u=this._container.getBoundingClientRect().height||300;let x,C,P,R=this._container;for(;R&&(!C||!P);){const F=window.getComputedStyle(R).transform;F&&F!=="none"&&(x=F.match(/matrix.*\((.+)\)/)[1].split(", "),x[0]&&x[0]!=="0"&&x[0]!=="1"&&(C=x[0]),x[3]&&x[3]!=="0"&&x[3]!=="1"&&(P=x[3])),R=R.parentElement}this._containerWidth=C?Math.abs(N/C):N,this._containerHeight=P?Math.abs(u/P):u}_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 wL(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 N=this._container;N.classList.add("mapboxgl-map"),(this._missingCSSCanary=w("div","mapboxgl-canary",N)).style.visibility="hidden",this._detectMissingCSS();const u=this._canvasContainer=w("div","mapboxgl-canvas-container",N);this._canvas=w("canvas","mapboxgl-canvas",u),this._interactive&&(u.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const x=this._controlContainer=w("div","mapboxgl-control-container",N),C=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(P=>{C[P]=w("div",`mapboxgl-ctrl-${P}`,x)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(N,u){const x=i.o.devicePixelRatio||1;this._canvas.width=x*Math.ceil(N),this._canvas.height=x*Math.ceil(u),this._canvas.style.width=`${N}px`,this._canvas.style.height=`${u}px`}_addMarker(N){this._markers.push(N)}_removeMarker(N){const u=this._markers.indexOf(N);u!==-1&&this._markers.splice(u,1)}_addPopup(N){this._popups.push(N)}_removePopup(N){const u=this._popups.indexOf(N);u!==-1&&this._popups.splice(u,1)}_setupPainter(){const N=Object.assign({},j.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),u=this._canvas.getContext("webgl2",N);u?(Ye(u,!0),this.painter=new PS(u,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",x=>{x.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.k.testSupport(u)):this.fire(new i.y(new Error("Failed to initialize WebGL")))}_contextLost(N){N.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:N}))}_contextRestored(N){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:N}))}_onMapScroll(N){if(N.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(N){return this.style?(this._styleDirty=this._styleDirty||N,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(N){return this._update(),this._renderTaskQueue.add(N)}_cancelRenderFrame(N){this._renderTaskQueue.remove(N)}_requestDomTask(N){!this.loaded()||this.loaded()&&!this.isMoving()?N():this._domRenderTaskQueue.add(N)}_render(N){let u;this.fire(new i.z("renderstart")),++this._frameId;const x=this.painter.context.extTimerQuery,C=i.o.now(),P=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(u=P.createQuery(),P.beginQuery(x.TIME_ELAPSED_EXT,u)),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(N),this._domRenderTaskQueue.run(N),this._removed)return;this._updateProjectionTransition();const R=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const te=this.transform.zoom,re=this.transform.pitch,pe=i.o.now(),me=new i.ac(te,{now:pe,fadeDuration:R,pitch:re,transition:this.style.transition,worldview:this._worldview});this.style.update(me)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let F=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),F=this._updateAverageElevation(C),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):F=this._updateAverageElevation(C);const U=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,R,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),U&&(this._placementDirty=U.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:R,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,f.mark(h.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(),u){const te=i.o.now()-C;P.endQuery(x.TIME_ELAPSED_EXT),setTimeout(()=>{const re=P.getQueryParameter(u,P.QUERY_RESULT)/1e6;P.deleteQuery(u),this.fire(new i.z("gpu-timing-frame",{cpuTime:te,gpuTime:re}))},50)}if(this.listens("gpu-timing-layer")){const te=this.painter.collectGpuTimers();setTimeout(()=>{const re=this.painter.queryGpuTimers(te);this.fire(new i.z("gpu-timing-layer",{layerTimes:re}))},50)}if(this.listens("gpu-timing-deferred-render")){const te=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const re=this.painter.queryGpuTimeDeferredRender(te);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:re}))},50)}const K=this._sourcesDirty||this._styleDirty||this._placementDirty||F;if(K||this._repaint)this.triggerRepaint();else{const te=this.idle();if(te&&(F=this._updateAverageElevation(C,!0)),F)this.triggerRepaint();else if(this._triggerFrame(!1),te&&(this.fire(new i.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const re=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:re})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||K||(this._fullyLoaded=!0,f.mark(h.fullLoad),this._performanceMetricsCollection&&st(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(N){for(const u of this._markers)N&&!this.getRenderWorldCopies()&&(u._lngLat=u._lngLat.wrap()),u._update();for(const u of this._popups)!N||this.getRenderWorldCopies()||u._trackPointer||(u._lngLat=u._lngLat.wrap()),u._update()}_updateAverageElevation(N,u=!1){const x=P=>(this.transform.averageElevation=P,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&x(0);const C=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(C||(u||N-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(N)){const P=this.transform.averageElevation;let R=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(R)?R=0:this._averageElevationLastSampledAt=N;const F=Math.abs(P-R);if(F>1){if(this._isInitialLoad||C)return this._averageElevation.jumpTo(R),x(R);this._averageElevation.easeTo(R,N,300)}else if(F>1e-4)return this._averageElevation.jumpTo(R),x(R)}return!!this._averageElevation.isEasing(N)&&x(this._averageElevation.getValue(N))}_authenticate(){We(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,N=>{if(N&&(N.message===ie||N.status===401)){const u=this.painter.context.gl;Ye(u,!1),this._logoControl instanceof Q_&&this._logoControl._updateLogo(),u&&u.clear(u.DEPTH_BUFFER_BIT|u.COLOR_BUFFER_BIT|u.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/")))}}),Ae(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&He(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&De(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){wt(this._requestManager._customAccessToken)}_updateTerrain(){const N=this._isDragging();this.painter.updateTerrain(this.style,N)}_calculateSpeedIndex(){const N=this.painter.canvasCopy(),u=this.painter.getCanvasCopiesAndTimestamps();u.timeStamps.push(performance.now());const x=this.painter.context.gl,C=x.createFramebuffer();function P(R){x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,R,0);const F=new Uint8Array(x.drawingBufferWidth*x.drawingBufferHeight*4);return x.readPixels(0,0,x.drawingBufferWidth,x.drawingBufferHeight,x.RGBA,x.UNSIGNED_BYTE,F),F}return x.bindFramebuffer(x.FRAMEBUFFER,C),this._canvasPixelComparison(P(N),u.canvasCopies.map(P),u.timeStamps)}_canvasPixelComparison(N,u,x){let C=x[1]-x[0];const P=N.length/4;for(let R=0;R{const x=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,x&&this._render(u)}))}_preloadTiles(N){const u=this.style?this.style.getSourceCaches():[];return i.bw(u,(x,C)=>x._preloadTiles(N,C),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(N){this._trackResize&&this.resize({originalEvent:N})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(N){this._showTileBoundaries!==N&&(this._showTileBoundaries=N,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(N){this._showParseStatus!==N&&(this._showParseStatus=N,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(N){this._showTerrainWireframe!==N&&(this._showTerrainWireframe=N,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(N){this._showLayers2DWireframe!==N&&(this._showLayers2DWireframe=N,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(N){this._showLayers3DWireframe!==N&&(this._showLayers3DWireframe=N,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(N){this._speedIndexTiming!==N&&(this._speedIndexTiming=N,this._update())}get showPadding(){return!!this._showPadding}set showPadding(N){this._showPadding!==N&&(this._showPadding=N,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(N){this._showCollisionBoxes!==N&&(this._showCollisionBoxes=N,this.style&&N?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(N){this._showOverdrawInspector!==N&&(this._showOverdrawInspector=N,this._update())}get repaint(){return!!this._repaint}set repaint(N){this._repaint!==N&&(this._repaint=N,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(N){this._vertices=N,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(N){this._showTileAABBs!==N&&(this._showTileAABBs=N,N&&this._update())}_setCacheLimits(N,u){i.f4(N,u)}get version(){return d}},NavigationControl:class{constructor(N={}){this.options=Object.assign({},wce,N),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",u=>u.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",u=>{this._map&&this._map.zoomIn({},{originalEvent:u})}),w("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",u=>{this._map&&this._map.zoomOut({},{originalEvent:u})}),w("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",u=>{const x=this._map;x&&(this.options.visualizePitch?x.resetNorthPitch({},{originalEvent:u}):x.resetNorth({},{originalEvent:u}))}),this._compassIcon=w("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const N=this._map;if(!N)return;const u=N.getZoom(),x=u===N.getMaxZoom(),C=u===N.getMinZoom();this._zoomInButton.disabled=x,this._zoomOutButton.disabled=C,this._zoomInButton.setAttribute("aria-disabled",x.toString()),this._zoomOutButton.setAttribute("aria-disabled",C.toString())}_rotateCompassArrow(){const N=this._map;if(!N)return;const u=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(N.transform.pitch*(Math.PI/180)),.5)}) rotateX(${N.transform.pitch}deg) rotateZ(${N.transform.angle*(180/Math.PI)}deg)`:`rotate(${N.transform.angle*(180/Math.PI)}deg)`;N._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=u)})}onAdd(N){return this._map=N,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),N.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&N.on("pitch",this._rotateCompassArrow),N.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new jce(N,this._compass,this.options.visualizePitch)),this._container}onRemove(){const N=this._map;N&&(this._container.remove(),this.options.showZoom&&N.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&N.off("pitch",this._rotateCompassArrow),N.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(N,u){const x=w("button",N,this._container);return x.type="button",x.addEventListener("click",u),x}_setButtonTitle(N,u){if(!this._map)return;const x=this._map._getUIString(`NavigationControl.${u}`);N.setAttribute("aria-label",x),N.firstElementChild&&N.firstElementChild.setAttribute("title",x)}},GeolocateControl:class extends i.E{constructor(N={}){super();const u=navigator.geolocation;this.options=Object.assign({geolocation:u},kce,N),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=LS(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(N){return this._map=N,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(N){const u=(x=!!this.options.geolocation)=>{this._supportsGeolocation=x,N(x)};this._supportsGeolocation!==void 0?N(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(x=>u(x.state!=="denied")).catch(()=>u()):u()}_isOutOfMapMaxBounds(N){const u=this._map.getMaxBounds(),x=N.coords;return!!u&&(x.longitudeu.getEast()||x.latitudeu.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(N){if(this._map){if(this._isOutOfMapMaxBounds(N))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",N)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=N,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(N),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(N),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:N.coords,timestamp:N.timestamp},N.toJSON?{toJSON:N.toJSON.bind(N)}:{}))),this._finish()}}_updateCamera(N){const u=new i.aT(N.coords.longitude,N.coords.latitude),x=N.coords.accuracy,C=this._map.getBearing(),P=Object.assign({bearing:C},this.options.fitBoundsOptions);this._map.fitBounds(u.toBounds(x),P,{geolocateSource:!0})}_updateMarker(N){if(N){const u=new i.aT(N.coords.longitude,N.coords.latitude);this._accuracyCircleMarker.setLngLat(u).addTo(this._map),this._userLocationDotMarker.setLngLat(u).addTo(this._map),this._accuracy=N.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const N=this._map.transform,u=i.cf(1,N._center.lat)*N.worldSize,x=Math.ceil(2*this._accuracy*u);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(N){if(this._map){if(this.options.trackUserLocation)if(N.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 u=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",u),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",u),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(N.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",N)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(N){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",u=>u.preventDefault()),this._geolocateButton=w("button","mapboxgl-ctrl-geolocate",this._container),w("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",N===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const u=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",u),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",u)}else{const u=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",u),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",u)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=w("div","mapboxgl-user-location"),this._dotElement.appendChild(w("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(w("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new GS({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=w("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new GS({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",u=>{u.geolocateSource||this._watchState!=="ACTIVE_LOCK"||u.originalEvent&&u.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(N){this._userLocationDotMarker&&(N.webkitCompassHeading?this._heading=N.webkitCompassHeading:N.absolute===!0&&(this._heading=-1*N.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 N;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(N={maximumAge:6e5,timeout:0},this._noTimeout=!0):(N=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,N),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 N=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};typeof DeviceMotionEvent<"u"&&typeof DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(u=>{u==="granted"&&N()}).catch(console.error):N()}_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:X_,ScaleControl:class{constructor(N={}){this.options=Object.assign({},nv,N),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const N=this.options.maxWidth||100,u=this._map,x=u._containerHeight/2,C=u._containerWidth/2-N/2,P=u.unproject([C,x]),R=u.unproject([C+N,x]),F=P.distanceTo(R);if(this.options.unit==="imperial"){const U=3.2808*F;U>5280?this._setScale(N,U/5280,"mile"):this._setScale(N,U,"foot")}else this.options.unit==="nautical"?this._setScale(N,F/1852,"nautical-mile"):F>=1e3?this._setScale(N,F/1e3,"kilometer"):this._setScale(N,F,"meter")}_setScale(N,u,x){this._map._requestDomTask(()=>{const C=function(R){const F=Math.pow(10,`${Math.floor(R)}`.length-1);let U=R/F;return U=U>=10?10:U>=5?5:U>=3?3:U>=2?2:U>=1?1:function(K){const te=Math.pow(10,Math.ceil(-Math.log(K)/Math.LN10));return Math.round(K*te)/te}(U),F*U}(u),P=C/u;this._container.innerHTML=x!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:x}).format(C):`${C} ${yT[x]}`,this._container.style.width=N*P+"px"})}onAdd(N){return this._map=N,this._language=N.getLanguage(),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-scale",N.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(N){this._language=N,this._update()}setUnit(N){this.options.unit=N,this._update()}},FullscreenControl:class{constructor(N={}){this._fullscreen=!1,N&&N.container&&(N.container instanceof HTMLElement?this._container=N.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(N){return this._map=N,this._container||(this._container=this._map.getContainer()),this._controlContainer=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const N=this._fullscreenButton=w("button","mapboxgl-ctrl-fullscreen",this._controlContainer);w("span","mapboxgl-ctrl-icon",N).setAttribute("aria-hidden","true"),N.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const N=this._getTitle();this._fullscreenButton.setAttribute("aria-label",N),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",N)}_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:rv,Popup:class extends i.E{constructor(N){super(),this.options=Object.assign(Object.create(Bh),N),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(N&&N.className?N.className.trim().split(/\s+/):[])}addTo(N){return this._map&&this.remove(),this._map=N,this.options.closeOnClick&&N.on("preclick",this._onClose),this.options.closeOnMove&&N.on("move",this._onClose),N.on("remove",this.remove),this._update(),N._addPopup(this),this._focusFirstElement(),this._trackPointer?(N.on("mousemove",this._onMouseEvent),N.on("mouseup",this._onMouseEvent),N._canvasContainer.classList.add("mapboxgl-track-pointer")):N.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 N=this._map;return N&&(N.off("move",this._update),N.off("move",this._onClose),N.off("preclick",this._onClose),N.off("click",this._onClose),N.off("remove",this.remove),N.off("mousemove",this._onMouseEvent),N.off("mouseup",this._onMouseEvent),N.off("drag",this._onMouseEvent),N._canvasContainer&&N._canvasContainer.classList.remove("mapboxgl-track-pointer"),N._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(N){this._lngLat=i.aT.convert(N),this._pos=null,this._trackPointer=!1,this._update();const u=this._map;return u&&(u.on("move",this._update),u.off("mousemove",this._onMouseEvent),u._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(N){return this._altitude=N,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const N=this._map;return N&&(N.off("move",this._update),N.on("mousemove",this._onMouseEvent),N.on("drag",this._onMouseEvent),N._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(N){return this.setDOMContent(document.createTextNode(N))}setHTML(N){const u=document.createDocumentFragment(),x=document.createElement("body");let C;for(x.innerHTML=N;C=x.firstChild,C;)u.appendChild(C);return this.setDOMContent(u)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(N){return this.options.maxWidth=N,this._update(),this}setDOMContent(N){let u=this._content;if(u)for(;u.hasChildNodes();)u.firstChild&&u.removeChild(u.firstChild);else u=this._content=w("div","mapboxgl-popup-content",this._container||void 0);if(u.appendChild(N),this.options.closeButton){const x=this._closeButton=w("button","mapboxgl-popup-close-button",u);x.type="button",x.setAttribute("aria-label","Close popup"),x.innerHTML='',x.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(N){return this._classList.add(N),this._updateClassList(),this}removeClassName(N){return this._classList.delete(N),this._updateClassList(),this}setOffset(N){return this.options.offset=N,this._update(),this}toggleClassName(N){let u;return this._classList.delete(N)?u=!1:(this._classList.add(N),u=!0),this._updateClassList(),u}_onMouseEvent(N){this._update(N.point)}_getAnchor(N){if(this.options.anchor)return this.options.anchor;const u=this._map,x=this._container,C=this._pos;if(!u||!x||!C)return"bottom";const P=x.offsetWidth,R=x.offsetHeight,F=C.x

u.transform.width-P/2;if(C.y+Nu.transform.height-R){if(F)return"bottom-left";if(U)return"bottom-right"}return F?"left":U?"right":"bottom"}_updateClassList(){const N=this._container;if(!N)return;const u=[...this._classList];u.push("mapboxgl-popup"),this._anchor&&u.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&u.push("mapboxgl-popup-track-pointer"),N.className=u.join(" ")}_update(N){const u=this._map,x=this._content;if(!u||!this._lngLat&&!this._trackPointer||!x)return;let C=this._container;if(C||(C=this._container=w("div","mapboxgl-popup",u.getContainer()),this._tip=w("div","mapboxgl-popup-tip",C),C.appendChild(x)),this.options.maxWidth&&C.style.maxWidth!==this.options.maxWidth&&(C.style.maxWidth=this.options.maxWidth),u.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=xT(this._lngLat,this._pos,u.transform)),!this._trackPointer||N){const P=this._pos=this._trackPointer&&N instanceof i.P?N:u.project(this._lngLat,this._altitude),R=fy(this.options.offset),F=this._anchor=this._getAnchor(R.y),U=fy(this.options.offset,F),K=P.add(U).round();u._requestDomTask(()=>{this._container&&F&&(this._container.style.transform=`${ed[F]} translate(${K.x}px,${K.y}px)`)})}if(!this._marker&&u._showingGlobe()){const P=i.f5(u.transform,this._lngLat)?0:1;this._setOpacity(P)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const N=this._container.querySelector($h);N&&N.focus()}_onClose(){this.remove()}_setOpacity(N){this._container&&(this._container.style.opacity=`${N}`),this._content&&(this._content.style.pointerEvents=N?"auto":"none")}},Marker:GS,Style:Fh,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:Fd,Evented:i.E,config:i.e,prewarm:i.f9,clearPrewarmedResources:i.f8,get accessToken(){return i.e.ACCESS_TOKEN},set accessToken(N){i.e.ACCESS_TOKEN=N},get baseApiUrl(){return i.e.API_URL},set baseApiUrl(N){i.e.API_URL=N},get workerCount(){return i.fi.workerCount},set workerCount(N){i.fi.workerCount=N},get maxParallelImageRequests(){return i.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(N){i.e.MAX_PARALLEL_IMAGE_REQUESTS=N},clearStorage(N){i.fh(N)},get workerUrl(){return i.fg.workerUrl},set workerUrl(N){i.fg.workerUrl=N},get workerClass(){return i.fg.workerClass},set workerClass(N){i.fg.workerClass=N},get workerParams(){return i.fg.workerParams},set workerParams(N){i.fg.workerParams=N},get dracoUrl(){return i.ff()},set dracoUrl(N){i.fe(N)},get meshoptUrl(){return i.fd()},set meshoptUrl(N){i.fc(N)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(Fze);var Kft=Fze.exports;const Mc=fo(Kft);function ys({className:t,...s}){return e.jsx("div",{className:$t("animate-pulse rounded-md bg-muted",t),...s})}const v4e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},_4e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Zft(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Yft({listings:t,isLoading:s}){const r=Yr(),n=T.useRef(null),a=T.useRef(null),o=T.useRef([]),[l,i]=T.useState(""),[d,h]=T.useState(!0);return T.useEffect(()=>{(async()=>{h(!0);try{const{data:v}=await Z.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)}h(!1)})()},[]),T.useEffect(()=>{if(!n.current||!l||a.current)return;Mc.accessToken=l;const g=t.filter(j=>j.latitude!=null&&j.longitude!=null);let v=[-98.5795,39.8283],_=4;if(g.length>0){const j=g.reduce((k,M)=>k+M.longitude,0)/g.length,w=g.reduce((k,M)=>k+M.latitude,0)/g.length;v=[j,w],_=g.length===1?12:10}return a.current=new Mc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:v}),a.current.addControl(new Mc.NavigationControl,"top-right"),()=>{var j;(j=a.current)==null||j.remove(),a.current=null}},[l]),T.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 D,L,B;const _=v4e[v.status]||"#10B981",j=((D=v.photos)==null?void 0:D.find($=>$.is_primary))||((L=v.photos)==null?void 0:L[0]),k=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${v.slug||v.id}`:`/public/listing/${v.slug||v.id}`,M=document.createElement("div");M.className="cursor-pointer",M.innerHTML=`

`;const S=new Mc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${j!=null&&j.photo_url?``:""}
${Zft(v.price)}
${v.property_address||""}
${v.city}, ${v.state}
${_4e[v.status]||v.status} ${v.bedrooms?`${v.bedrooms} bed`:""} ${v.bathrooms?`${v.bathrooms} bath`:""}
${(B=v.agent)!=null&&B.name?`
Listed by ${v.agent.name}
`:""}
Click to view details →
`),E=new Mc.Marker(M).setLngLat([v.longitude,v.latitude]).setPopup(S).addTo(a.current);o.current.push(E)}),g.length>1){const v=new Mc.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]),T.useEffect(()=>(window.__navigateToPublicListing__=g=>{r(g)},()=>{delete window.__navigateToPublicListing__}),[r]),d||s?e.jsx(ys,{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(v4e).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:_4e[g]})]},g))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function iP(t,[s,r]){return Math.min(r,Math.max(s,t))}function O6(t){const s=T.useRef({value:t,previous:t});return T.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var Xft=[" ","Enter","ArrowUp","ArrowDown"],Qft=[" ","Enter"],sN="Select",[Lie,Die,Jft]=b6(sN),[U3]=Dc(sN,[Jft,Wx]),Oie=Wx(),[egt,l_]=U3(sN),[tgt,sgt]=U3(sN),Bze=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:h,name:f,autoComplete:g,disabled:v,required:_,form:j}=t,w=Oie(s),[k,M]=T.useState(null),[S,E]=T.useState(null),[D,L]=T.useState(!1),B=jN(h),[$,V]=Sh({prop:n,defaultProp:a??!1,onChange:o,caller:sN}),[W,G]=Sh({prop:l,defaultProp:i,onChange:d,caller:sN}),J=T.useRef(null),ne=k?j||!!k.closest("form"):!0,[ie,ee]=T.useState(new Set),de=Array.from(ie).map(oe=>oe.props.value).join(";");return e.jsx(N6,{...w,children:e.jsxs(egt,{required:_,scope:s,trigger:k,onTriggerChange:M,valueNode:S,onValueNodeChange:E,valueNodeHasChildren:D,onValueNodeHasChildrenChange:L,contentId:Id(),value:W,onValueChange:G,open:$,onOpenChange:V,dir:B,triggerPointerDownPosRef:J,disabled:v,children:[e.jsx(Lie.Provider,{scope:s,children:e.jsx(tgt,{scope:t.__scopeSelect,onNativeOptionAdd:T.useCallback(oe=>{ee(ue=>new Set(ue).add(oe))},[]),onNativeOptionRemove:T.useCallback(oe=>{ee(ue=>{const ce=new Set(ue);return ce.delete(oe),ce})},[]),children:r})}),ne?e.jsxs(d7e,{"aria-hidden":!0,required:_,tabIndex:-1,name:f,autoComplete:g,value:W,onChange:oe=>G(oe.target.value),disabled:v,form:j,children:[W===void 0?e.jsx("option",{value:""}):null,Array.from(ie)]},de):null]})})};Bze.displayName=sN;var $ze="SelectTrigger",Uze=T.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Oie(r),l=l_($ze,r),i=l.disabled||n,d=ba(s,l.onTriggerChange),h=Die(r),f=T.useRef("touch"),[g,v,_]=h7e(w=>{const k=h().filter(E=>!E.disabled),M=k.find(E=>E.value===l.value),S=m7e(k,w,M);S!==void 0&&l.onValueChange(S.value)}),j=w=>{i||(l.onOpenChange(!0),_()),w&&(l.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return e.jsx(I3,{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":u7e(l.value)?"":void 0,...a,ref:d,onClick:kr(a.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&j(w)}),onPointerDown:kr(a.onPointerDown,w=>{f.current=w.pointerType;const k=w.target;k.hasPointerCapture(w.pointerId)&&k.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(j(w),w.preventDefault())}),onKeyDown:kr(a.onKeyDown,w=>{const k=g.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&v(w.key),!(k&&w.key===" ")&&Xft.includes(w.key)&&(j(),w.preventDefault())})})})});Uze.displayName=$ze;var qze="SelectValue",Vze=T.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,d=l_(qze,r),{onValueNodeHasChildrenChange:h}=d,f=o!==void 0,g=ba(s,d.onValueNodeChange);return Pc(()=>{h(f)},[h,f]),e.jsx(Qr.span,{...i,ref:g,style:{pointerEvents:"none"},children:u7e(d.value)?e.jsx(e.Fragment,{children:l}):o})});Vze.displayName=qze;var rgt="SelectIcon",Hze=T.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(Qr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});Hze.displayName=rgt;var ngt="SelectPortal",Wze=t=>e.jsx(C3,{asChild:!0,...t});Wze.displayName=ngt;var rN="SelectContent",Gze=T.forwardRef((t,s)=>{const r=l_(rN,t.__scopeSelect),[n,a]=T.useState();if(Pc(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?Qh.createPortal(e.jsx(Kze,{scope:t.__scopeSelect,children:e.jsx(Lie.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(Zze,{...t,ref:s})});Gze.displayName=rN;var qf=10,[Kze,c_]=U3(rN),agt="SelectContentImpl",igt=W1("SelectContent.RemoveScroll"),Zze=T.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:d,align:h,alignOffset:f,arrowPadding:g,collisionBoundary:v,collisionPadding:_,sticky:j,hideWhenDetached:w,avoidCollisions:k,...M}=t,S=l_(rN,r),[E,D]=T.useState(null),[L,B]=T.useState(null),$=ba(s,He=>D(He)),[V,W]=T.useState(null),[G,J]=T.useState(null),ne=Die(r),[ie,ee]=T.useState(!1),de=T.useRef(!1);T.useEffect(()=>{if(E)return Nie(E)},[E]),kie();const oe=T.useCallback(He=>{const[Ue,...De]=ne().map(Ie=>Ie.ref.current),[Ge]=De.slice(-1),wt=document.activeElement;for(const Ie of He)if(Ie===wt||(Ie==null||Ie.scrollIntoView({block:"nearest"}),Ie===Ue&&L&&(L.scrollTop=0),Ie===Ge&&L&&(L.scrollTop=L.scrollHeight),Ie==null||Ie.focus(),document.activeElement!==wt))return},[ne,L]),ue=T.useCallback(()=>oe([V,E]),[oe,V,E]);T.useEffect(()=>{ie&&ue()},[ie,ue]);const{onOpenChange:ce,triggerPointerDownPosRef:ge}=S;T.useEffect(()=>{if(E){let He={x:0,y:0};const Ue=Ge=>{var wt,Ie;He={x:Math.abs(Math.round(Ge.pageX)-(((wt=ge.current)==null?void 0:wt.x)??0)),y:Math.abs(Math.round(Ge.pageY)-(((Ie=ge.current)==null?void 0:Ie.y)??0))}},De=Ge=>{He.x<=10&&He.y<=10?Ge.preventDefault():E.contains(Ge.target)||ce(!1),document.removeEventListener("pointermove",Ue),ge.current=null};return ge.current!==null&&(document.addEventListener("pointermove",Ue),document.addEventListener("pointerup",De,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Ue),document.removeEventListener("pointerup",De,{capture:!0})}}},[E,ce,ge]),T.useEffect(()=>{const He=()=>ce(!1);return window.addEventListener("blur",He),window.addEventListener("resize",He),()=>{window.removeEventListener("blur",He),window.removeEventListener("resize",He)}},[ce]);const[Te,ve]=h7e(He=>{const Ue=ne().filter(wt=>!wt.disabled),De=Ue.find(wt=>wt.ref.current===document.activeElement),Ge=m7e(Ue,He,De);Ge&&setTimeout(()=>Ge.ref.current.focus())}),ye=T.useCallback((He,Ue,De)=>{const Ge=!de.current&&!De;(S.value!==void 0&&S.value===Ue||Ge)&&(W(He),Ge&&(de.current=!0))},[S.value]),Se=T.useCallback(()=>E==null?void 0:E.focus(),[E]),Ke=T.useCallback((He,Ue,De)=>{const Ge=!de.current&&!De;(S.value!==void 0&&S.value===Ue||Ge)&&J(He)},[S.value]),Ae=n==="popper"?Efe:Yze,Ee=Ae===Efe?{side:i,sideOffset:d,align:h,alignOffset:f,arrowPadding:g,collisionBoundary:v,collisionPadding:_,sticky:j,hideWhenDetached:w,avoidCollisions:k}:{};return e.jsx(Kze,{scope:r,content:E,viewport:L,onViewportChange:B,itemRefCallback:ye,selectedItem:V,onItemLeave:Se,itemTextRefCallback:Ke,focusSelectedItem:ue,selectedItemText:G,position:n,isPositioned:ie,searchRef:Te,children:e.jsx(E6,{as:igt,allowPinchZoom:!0,children:e.jsx(T6,{asChild:!0,trapped:S.open,onMountAutoFocus:He=>{He.preventDefault()},onUnmountAutoFocus:kr(a,He=>{var Ue;(Ue=S.trigger)==null||Ue.focus({preventScroll:!0}),He.preventDefault()}),children:e.jsx(n_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:He=>He.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(Ae,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:He=>He.preventDefault(),...M,...Ee,onPlaced:()=>ee(!0),ref:$,style:{display:"flex",flexDirection:"column",outline:"none",...M.style},onKeyDown:kr(M.onKeyDown,He=>{const Ue=He.ctrlKey||He.altKey||He.metaKey;if(He.key==="Tab"&&He.preventDefault(),!Ue&&He.key.length===1&&ve(He.key),["ArrowUp","ArrowDown","Home","End"].includes(He.key)){let Ge=ne().filter(wt=>!wt.disabled).map(wt=>wt.ref.current);if(["ArrowUp","End"].includes(He.key)&&(Ge=Ge.slice().reverse()),["ArrowUp","ArrowDown"].includes(He.key)){const wt=He.target,Ie=Ge.indexOf(wt);Ge=Ge.slice(Ie+1)}setTimeout(()=>oe(Ge)),He.preventDefault()}})})})})})})});Zze.displayName=agt;var ogt="SelectItemAlignedPosition",Yze=T.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=l_(rN,r),l=c_(rN,r),[i,d]=T.useState(null),[h,f]=T.useState(null),g=ba(s,$=>f($)),v=Die(r),_=T.useRef(!1),j=T.useRef(!0),{viewport:w,selectedItem:k,selectedItemText:M,focusSelectedItem:S}=l,E=T.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&h&&w&&k&&M){const $=o.trigger.getBoundingClientRect(),V=h.getBoundingClientRect(),W=o.valueNode.getBoundingClientRect(),G=M.getBoundingClientRect();if(o.dir!=="rtl"){const wt=G.left-V.left,Ie=W.left-wt,st=$.left-Ie,he=$.width+st,We=Math.max(he,V.width),et=window.innerWidth-qf,Ye=iP(Ie,[qf,Math.max(qf,et-We)]);i.style.minWidth=he+"px",i.style.left=Ye+"px"}else{const wt=V.right-G.right,Ie=window.innerWidth-W.right-wt,st=window.innerWidth-$.right-Ie,he=$.width+st,We=Math.max(he,V.width),et=window.innerWidth-qf,Ye=iP(Ie,[qf,Math.max(qf,et-We)]);i.style.minWidth=he+"px",i.style.right=Ye+"px"}const J=v(),ne=window.innerHeight-qf*2,ie=w.scrollHeight,ee=window.getComputedStyle(h),de=parseInt(ee.borderTopWidth,10),oe=parseInt(ee.paddingTop,10),ue=parseInt(ee.borderBottomWidth,10),ce=parseInt(ee.paddingBottom,10),ge=de+oe+ie+ce+ue,Te=Math.min(k.offsetHeight*5,ge),ve=window.getComputedStyle(w),ye=parseInt(ve.paddingTop,10),Se=parseInt(ve.paddingBottom,10),Ke=$.top+$.height/2-qf,Ae=ne-Ke,Ee=k.offsetHeight/2,He=k.offsetTop+Ee,Ue=de+oe+He,De=ge-Ue;if(Ue<=Ke){const wt=J.length>0&&k===J[J.length-1].ref.current;i.style.bottom="0px";const Ie=h.clientHeight-w.offsetTop-w.offsetHeight,st=Math.max(Ae,Ee+(wt?Se:0)+Ie+ue),he=Ue+st;i.style.height=he+"px"}else{const wt=J.length>0&&k===J[0].ref.current;i.style.top="0px";const st=Math.max(Ke,de+w.offsetTop+(wt?ye:0)+Ee)+De;i.style.height=st+"px",w.scrollTop=Ue-Ke+w.offsetTop}i.style.margin=`${qf}px 0`,i.style.minHeight=Te+"px",i.style.maxHeight=ne+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[v,o.trigger,o.valueNode,i,h,w,k,M,o.dir,n]);Pc(()=>E(),[E]);const[D,L]=T.useState();Pc(()=>{h&&L(window.getComputedStyle(h).zIndex)},[h]);const B=T.useCallback($=>{$&&j.current===!0&&(E(),S==null||S(),j.current=!1)},[E,S]);return e.jsx(cgt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:B,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:D},children:e.jsx(Qr.div,{...a,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Yze.displayName=ogt;var lgt="SelectPopperPosition",Efe=T.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=qf,...o}=t,l=Oie(r);return e.jsx(S6,{...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)"}})});Efe.displayName=lgt;var[cgt,Gve]=U3(rN,{}),Ife="SelectViewport",Xze=T.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=c_(Ife,r),l=Gve(Ife,r),i=ba(s,o.onViewportChange),d=T.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(Lie.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:kr(a.onScroll,h=>{const f=h.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:v}=l;if(v!=null&&v.current&&g){const _=Math.abs(d.current-f.scrollTop);if(_>0){const j=window.innerHeight-qf*2,w=parseFloat(g.style.minHeight),k=parseFloat(g.style.height),M=Math.max(w,k);if(M0?D:0,g.style.justifyContent="flex-end")}}}d.current=f.scrollTop})})})]})});Xze.displayName=Ife;var Qze="SelectGroup",[dgt,ugt]=U3(Qze),hgt=T.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Id();return e.jsx(dgt,{scope:r,id:a,children:e.jsx(Qr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});hgt.displayName=Qze;var Jze="SelectLabel",e7e=T.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=ugt(Jze,r);return e.jsx(Qr.div,{id:a.id,...n,ref:s})});e7e.displayName=Jze;var Mre="SelectItem",[mgt,t7e]=U3(Mre),s7e=T.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=l_(Mre,r),d=c_(Mre,r),h=i.value===n,[f,g]=T.useState(o??""),[v,_]=T.useState(!1),j=ba(s,S=>{var E;return(E=d.itemRefCallback)==null?void 0:E.call(d,S,n,a)}),w=Id(),k=T.useRef("touch"),M=()=>{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(mgt,{scope:r,value:n,disabled:a,textId:w,isSelected:h,onItemTextChange:T.useCallback(S=>{g(E=>E||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(Lie.ItemSlot,{scope:r,value:n,disabled:a,textValue:f,children:e.jsx(Qr.div,{role:"option","aria-labelledby":w,"data-highlighted":v?"":void 0,"aria-selected":h&&v,"data-state":h?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:j,onFocus:kr(l.onFocus,()=>_(!0)),onBlur:kr(l.onBlur,()=>_(!1)),onClick:kr(l.onClick,()=>{k.current!=="mouse"&&M()}),onPointerUp:kr(l.onPointerUp,()=>{k.current==="mouse"&&M()}),onPointerDown:kr(l.onPointerDown,S=>{k.current=S.pointerType}),onPointerMove:kr(l.onPointerMove,S=>{var E;k.current=S.pointerType,a?(E=d.onItemLeave)==null||E.call(d):k.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:kr(l.onPointerLeave,S=>{var E;S.currentTarget===document.activeElement&&((E=d.onItemLeave)==null||E.call(d))}),onKeyDown:kr(l.onKeyDown,S=>{var D;((D=d.searchRef)==null?void 0:D.current)!==""&&S.key===" "||(Qft.includes(S.key)&&M(),S.key===" "&&S.preventDefault())})})})})});s7e.displayName=Mre;var JA="SelectItemText",r7e=T.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=l_(JA,r),i=c_(JA,r),d=t7e(JA,r),h=sgt(JA,r),[f,g]=T.useState(null),v=ba(s,M=>g(M),d.onItemTextChange,M=>{var S;return(S=i.itemTextRefCallback)==null?void 0:S.call(i,M,d.value,d.disabled)}),_=f==null?void 0:f.textContent,j=T.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:w,onNativeOptionRemove:k}=h;return Pc(()=>(w(j),()=>k(j)),[w,k,j]),e.jsxs(e.Fragment,{children:[e.jsx(Qr.span,{id:d.textId,...o,ref:v}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Qh.createPortal(o.children,l.valueNode):null]})});r7e.displayName=JA;var n7e="SelectItemIndicator",a7e=T.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return t7e(n7e,r).isSelected?e.jsx(Qr.span,{"aria-hidden":!0,...n,ref:s}):null});a7e.displayName=n7e;var Pfe="SelectScrollUpButton",i7e=T.forwardRef((t,s)=>{const r=c_(Pfe,t.__scopeSelect),n=Gve(Pfe,t.__scopeSelect),[a,o]=T.useState(!1),l=ba(s,n.onScrollButtonChange);return Pc(()=>{if(r.viewport&&r.isPositioned){let i=function(){const h=d.scrollTop>0;o(h)};const d=r.viewport;return i(),d.addEventListener("scroll",i),()=>d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(l7e,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});i7e.displayName=Pfe;var Lfe="SelectScrollDownButton",o7e=T.forwardRef((t,s)=>{const r=c_(Lfe,t.__scopeSelect),n=Gve(Lfe,t.__scopeSelect),[a,o]=T.useState(!1),l=ba(s,n.onScrollButtonChange);return Pc(()=>{if(r.viewport&&r.isPositioned){let i=function(){const h=d.scrollHeight-d.clientHeight,f=Math.ceil(d.scrollTop)d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(l7e,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});o7e.displayName=Lfe;var l7e=T.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=c_("SelectScrollButton",r),l=T.useRef(null),i=Die(r),d=T.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return T.useEffect(()=>()=>d(),[d]),Pc(()=>{var f;const h=i().find(g=>g.ref.current===document.activeElement);(f=h==null?void 0:h.ref.current)==null||f.scrollIntoView({block:"nearest"})},[i]),e.jsx(Qr.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:kr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:kr(a.onPointerMove,()=>{var h;(h=o.onItemLeave)==null||h.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:kr(a.onPointerLeave,()=>{d()})})}),pgt="SelectSeparator",c7e=T.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Qr.div,{"aria-hidden":!0,...n,ref:s})});c7e.displayName=pgt;var Dfe="SelectArrow",fgt=T.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Oie(r),o=l_(Dfe,r),l=c_(Dfe,r);return o.open&&l.position==="popper"?e.jsx(C6,{...a,...n,ref:s}):null});fgt.displayName=Dfe;var ggt="SelectBubbleInput",d7e=T.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=T.useRef(null),o=ba(n,a),l=O6(s);return T.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&f){const g=new Event("change",{bubbles:!0});f.call(i,s),i.dispatchEvent(g)}},[l,s]),e.jsx(Qr.select,{...r,style:{...iOe,...r.style},ref:o,defaultValue:s})});d7e.displayName=ggt;function u7e(t){return t===""||t===void 0}function h7e(t){const s=Ac(t),r=T.useRef(""),n=T.useRef(0),a=T.useCallback(l=>{const i=r.current+l;s(i),function d(h){r.current=h,window.clearTimeout(n.current),h!==""&&(n.current=window.setTimeout(()=>d(""),1e3))}(i)},[s]),o=T.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return T.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function m7e(t,s,r){const a=s.length>1&&Array.from(s).every(h=>h===s[0])?s[0]:s,o=r?t.indexOf(r):-1;let l=xgt(t,Math.max(o,0));a.length===1&&(l=l.filter(h=>h!==r));const d=l.find(h=>h.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function xgt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var ygt=Bze,p7e=Uze,vgt=Vze,_gt=Hze,bgt=Wze,f7e=Gze,wgt=Xze,g7e=e7e,x7e=s7e,jgt=r7e,kgt=a7e,y7e=i7e,v7e=o7e,_7e=c7e;const er=ygt,tr=vgt,Qs=T.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(p7e,{ref:n,className:$t("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(_gt,{asChild:!0,children:e.jsx(Gc,{className:"h-4 w-4 opacity-50"})})]}));Qs.displayName=p7e.displayName;const b7e=T.forwardRef(({className:t,...s},r)=>e.jsx(y7e,{ref:r,className:$t("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(kx,{className:"h-4 w-4"})}));b7e.displayName=y7e.displayName;const w7e=T.forwardRef(({className:t,...s},r)=>e.jsx(v7e,{ref:r,className:$t("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Gc,{className:"h-4 w-4"})}));w7e.displayName=v7e.displayName;const Js=T.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(bgt,{children:e.jsxs(f7e,{ref:a,className:$t("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(b7e,{}),e.jsx(wgt,{className:$t("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(w7e,{})]})}));Js.displayName=f7e.displayName;const Ngt=T.forwardRef(({className:t,...s},r)=>e.jsx(g7e,{ref:r,className:$t("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));Ngt.displayName=g7e.displayName;const Et=T.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(x7e,{ref:n,className:$t("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(kgt,{children:e.jsx(ma,{className:"h-4 w-4"})})}),e.jsx(jgt,{children:s})]}));Et.displayName=x7e.displayName;const Sgt=T.forwardRef(({className:t,...s},r)=>e.jsx(_7e,{ref:r,className:$t("-mx-1 my-1 h-px bg-muted",t),...s}));Sgt.displayName=_7e.displayName;const Cgt=t=>zt({queryKey:["public-listings",t],queryFn:async()=>{let s=Z.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}}),j7e=t=>zt({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=Z.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}),k7e=()=>Wt({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 Z.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:h,error:f}=await Z.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(f)throw f;const{error:g}=await Z.functions.invoke("process-listing-lead",{body:{leadId:h.id}});return g&&console.error("Error processing lead:",g),h}}),Mgt=()=>Wt({mutationFn:async t=>{const{error:s}=await Z.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),Tgt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},b4e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},Agt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function N7e(){const[t,s]=T.useState(""),[r,n]=T.useState(!1),[a,o]=T.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=Cgt({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),h=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},f=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(Ih,{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(bo,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:Rze,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(${Gft})`},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(On,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(Be,{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(Y,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(On,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(Y,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(HE,{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(er,{value:a.status||"all",onValueChange:g=>o({...a,status:g==="all"?"":g}),children:[e.jsx(Qs,{className:"bg-white",children:e.jsx(tr,{placeholder:"Any status"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"Any status"}),Object.entries(b4e).map(([g,v])=>e.jsx(Et,{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(er,{value:a.propertyType||"all",onValueChange:g=>o({...a,propertyType:g==="all"?"":g}),children:[e.jsx(Qs,{className:"bg-white",children:e.jsx(tr,{placeholder:"Any type"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"Any type"}),Object.entries(Agt).map(([g,v])=>e.jsx(Et,{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(Be,{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(Be,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:g=>o({...a,maxPrice:g.target.value}),className:"bg-white"})]})]}),f&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(Y,{variant:"ghost",size:"sm",onClick:h,className:"gap-1 text-gray-500",children:[e.jsx(Xr,{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(Yft,{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(ys,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ys,{className:"h-7 w-28"}),e.jsx(ys,{className:"h-4 w-full"}),e.jsx(ys,{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 w,k,M;const v=((w=g.photos)==null?void 0:w.find(S=>S.is_primary))||((k=g.photos)==null?void 0:k[0]),j=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${g.slug||g.id}`:`/public/listing/${g.slug||g.id}`;return e.jsx(bo,{to:j,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(Zn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(ct,{className:`absolute top-2 left-2 ${Tgt[g.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:b4e[g.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:S=>S.preventDefault(),children:e.jsx(Ti,{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}),((M=g.agent.brokerage)==null?void 0:M.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(Zn,{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:f?"Try adjusting your search or filters":"Check back soon for new listings"}),f&&e.jsx(Y,{variant:"outline",onClick:h,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:Wve,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 Oe=T.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:$t("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Oe.displayName="Card";const Ht=T.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:$t("flex flex-col space-y-1.5 p-6",t),...s}));Ht.displayName="CardHeader";const Gt=T.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:$t("text-2xl font-semibold leading-none tracking-tight",t),...s}));Gt.displayName="CardTitle";const Tr=T.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:$t("text-sm text-muted-foreground",t),...s}));Tr.displayName="CardDescription";const $e=T.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:$t("p-6 pt-0",t),...s}));$e.displayName="CardContent";const rI=T.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:$t("flex items-center p-6 pt-0",t),...s}));rI.displayName="CardFooter";var Egt="Label",S7e=T.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())}}));S7e.displayName=Egt;var C7e=S7e;const Igt=M3("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),je=T.forwardRef(({className:t,...s},r)=>e.jsx(C7e,{ref:r,className:$t(Igt(),t),...s}));je.displayName=C7e.displayName;const Tre="/assets/levelup-logo-color-D3mY9gCJ.png";function Pgt(){const t=pm(),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(N7e,{}):n.startsWith("public/")?null:e.jsx(Lgt,{slug:n})}function Lgt({slug:t}){return e.jsx(Rgt,{slug:t})}const Dgt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Ogt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},w4e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Rgt({slug:t}){var W,G;const{data:s,isLoading:r}=j7e(t),n=k7e(),[a,o]=T.useState(""),[l,i]=T.useState(""),[d,h]=T.useState(""),[f,g]=T.useState(""),[v,_]=T.useState(!1),[j,w]=T.useState(!1),[k,M]=T.useState(null),S=J=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(J),E=async J=>{if(J.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:f.trim()}),w(!0),be.success("Thanks! The agent will be in touch soon.")}catch(ne){console.error("Lead submission error:",ne),be.error(`Failed to submit: ${ne.message||"Please try again"}`)}finally{_(!1)}}},D=(s==null?void 0:s.photos)||[],L=D.find(J=>J.is_primary)||D[0],B=()=>{k!==null&&M(k===0?D.length-1:k-1)},$=()=>{k!==null&&M(k===D.length-1?0:k+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(ys,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ys,{className:"h-10 w-48 mb-6"}),e.jsx(ys,{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(ys,{className:"h-12 w-48"}),e.jsx(ys,{className:"h-6 w-full"}),e.jsx(ys,{className:"h-6 w-3/4"})]}),e.jsx(ys,{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:Tre,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Zn,{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(Y,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const V=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(Ih,{children:[e.jsxs("title",{children:[V," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${w4e[s.property_type]} in ${s.city}, ${s.state}. ${((W=s.description)==null?void 0:W.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:V}),e.jsx("meta",{property:"og:description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),L&&e.jsx("meta",{property:"og:image",content:L.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:Tre,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(bi,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),D.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:()=>M(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:D.slice(1,5).map((J,ne)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>M(ne+1),children:[e.jsx("img",{src:J.photo_url,alt:`Photo ${ne+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),ne===3&&D.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",D.length-5," more"]})]},J.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(ct,{className:`${Dgt[s.status]} text-white border-0`,children:Ogt[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:S(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Gi,{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(k1,{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(j1,{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(Tx,{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(xn,{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(ct,{variant:"secondary",children:[e.jsx(Ya,{className:"h-3 w-3 mr-1"}),w4e[s.property_type]]}),s.lot_size&&e.jsxs(ct,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(ct,{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(Y,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Wo,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs($e,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((G=s.agent.brokerage)==null?void 0:G.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Oe,{className:"border-primary",children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx($e,{children:j?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(zr,{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:E,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Be,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:J=>o(J.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Be,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:J=>i(J.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"email",children:"Email *"}),e.jsx(Be,{id:"email",type:"email",placeholder:"you@example.com",value:d,onChange:J=>h(J.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"phone",children:"Phone"}),e.jsx(Be,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:f,onChange:J=>g(J.target.value)})]}),e.jsx(Y,{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(js,{open:k!==null,onOpenChange:()=>M(null),children:e.jsxs(_s,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Ls,{className:"sr-only",children:e.jsx(Ps,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>M(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(Xr,{className:"h-5 w-5"})}),k!==null&&D[k]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:D[k].photo_url,alt:`Photo ${k+1}`,className:"w-full max-h-[80vh] object-contain"}),D.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:B,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(hc,{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(Ri,{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:[k+1," / ",D.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 Rie({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 M7e=t=>zt({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await Z.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await Z.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 Z.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 Z.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 Z.storage.from("avatars").list(`${s.user_id}`);if(d&&d.length>0){const{data:h}=Z.storage.from("avatars").getPublicUrl(`${s.user_id}/${d[0].name}`);o=`${h.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}),Fgt=()=>zt({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await Z.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),zgt=t=>zt({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await Z.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),T7e=()=>{const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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"]}),be.success("Agent card created")},onError:s=>be.error(s.message)})},A7e=()=>{const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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"]}),be.success("Agent card updated")},onError:s=>be.error(s.message)})},eo=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await Z.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:{}})},Bgt=async(t,s)=>{const{error:r}=await Z.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},E7e=t=>zt({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await Z.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 Z.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 Fie({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=T.useState(""),[i,d]=T.useState(""),[h,f]=T.useState(""),[g,v]=T.useState(""),[_,j]=T.useState(""),[w,k]=T.useState(!1),M=async S=>{if(S.preventDefault(),!o.trim()){be.error("Please enter your name");return}k(!0);try{await Bgt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:h.trim()||void 0,message:_.trim()||void 0,intent:g||void 0}),eo(r,"lead_submitted",n),Z.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:h.trim()||void 0,message:_.trim()||void 0,intent:g||void 0}}).catch(E=>console.error("Card lead notify failed:",E)),be.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(""),f(""),v(""),j("")}catch{be.error("Something went wrong. Please try again.")}finally{k(!1)}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(en,{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:M,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"lead-name",children:"Name *"}),e.jsx(Be,{id:"lead-name",value:o,onChange:S=>l(S.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(Be,{id:"lead-phone",type:"tel",value:h,onChange:S=>f(S.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"lead-email",children:"Email"}),e.jsx(Be,{id:"lead-email",type:"email",value:i,onChange:S=>d(S.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(je,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(er,{value:g,onValueChange:v,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select one"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"buy",children:"Buy a home"}),e.jsx(Et,{value:"sell",children:"Sell my home"}),e.jsx(Et,{value:"both",children:"Buy & Sell"}),e.jsx(Et,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(je,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(Be,{id:"lead-message",value:_,onChange:S=>j(S.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(Y,{type:"submit",className:"w-full rounded-2xl",disabled:w,children:w?"Sending...":"Submit"})]})]})})}const $gt=t=>zt({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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}),Ugt=t=>zt({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),qgt=()=>{const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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]}),be.success("Block added")},onError:s=>be.error(s.message)})},Vgt=()=>{const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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"]}),be.success("Block updated")},onError:s=>be.error(s.message)})},Hgt=()=>{const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),be.success("Block removed")},onError:s=>be.error(s.message)})};function Wgt(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 Ggt(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 Kgt={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 Zgt({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=Ggt(r.video_url),o=n||!!a,l=n?Wgt(r.video_url):a||r.video_url;return e.jsx("div",{className:Kgt[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 Ygt={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 Xgt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=T.useState(0);if(n.length===0)return null;const l=Ygt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(U4,{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(hc,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((d,h)=>e.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${h===a?l.dot:l.dotInactive}`,onClick:()=>o(h)},h))}),e.jsx("button",{onClick:()=>o(d=>(d+1)%n.length),className:l.nav,children:e.jsx(Ri,{className:"h-4 w-4"})})]})]})}const Qgt={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 Jgt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=Qgt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const ext={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 txt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=ext[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:()=>eo(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(bn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const Ofe={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 sxt({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 rxt={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 nxt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=rxt[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=Ofe[l.platform.toLowerCase()];return!d||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>eo(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:e.jsx(sxt,{path:d.icon,color:d.color})},i)})})]})}function zie({cardId:t,variant:s}){const{data:r}=$gt(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(Zgt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(Xgt,{block:l,variant:s},l.id);case"specialties":return e.jsx(Jgt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(txt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(nxt,{block:o,cardId:t,variant:s})]})}async function axt(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 ixt(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 Bie(t){const{first:s,last:r}=ixt(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 axt(t.avatarUrl);if(i){const h={"image/jpeg":"JPEG","image/jpg":"JPEG","image/png":"PNG","image/gif":"GIF","image/webp":"JPEG"}[i.mimeType]||"JPEG";n.push(`PHOTO;ENCODING=b;TYPE=${h}:${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),be.success("Contact saved!")}function oxt({card:t}){var M;const[s,r]=T.useState(!1),[n,a]=T.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,E)=>{eo(t.id,"button_click",S),E()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:be.error("Phone number not available")}),h=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:be.error("Phone number not available")}),f=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:be.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),eo(t.id,"button_click","book"))},v=()=>{var S,E;eo(t.id,"contact_saved"),Bie({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(E=t.profile)==null?void 0:E.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(eo(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),be.success("Link copied!")},j=()=>{a("referral"),r(!0),eo(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),eo(t.id,"button_click","connect")},k={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(_a,{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(Y,{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(Ha,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(Y,{onClick:h,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(Eo,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(Y,{onClick:f,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(zr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(Y,{onClick:g,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(xn,{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(qn,{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(Rie,{card:t,variant:"standard"}),e.jsx(zie,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(Y,{variant:"ghost",onClick:v,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Vi,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(Y,{variant:"ghost",onClick:()=>{eo(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(qn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(Y,{variant:"ghost",onClick:j,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(br,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(Y,{variant:"ghost",onClick:w,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Zc,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(Y,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Kc,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,E)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>eo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:k[S.platform.toLowerCase()]||"🔗"},E))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(Fie,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function lxt({card:t}){var M;const[s,r]=T.useState(!1),[n,a]=T.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,E)=>{eo(t.id,"button_click",S),E()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:be.error("Phone number not available")}),h=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:be.error("Phone number not available")}),f=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:be.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),eo(t.id,"button_click","book"))},v=()=>{var S,E;eo(t.id,"contact_saved"),Bie({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(E=t.profile)==null?void 0:E.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(eo(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),be.success("Link copied!")},j=()=>{a("referral"),r(!0),eo(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),eo(t.id,"button_click","connect")},k={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(_a,{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:Ha,label:"Call",handler:d},{icon:Eo,label:"Text",handler:h},{icon:zr,label:"Email",handler:f}].map(({icon:S,label:E,handler:D})=>e.jsxs("button",{onClick:D,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(S,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:E})]},E))}),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(xn,{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(qn,{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(Rie,{card:t,variant:"luxury"}),e.jsx(zie,{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(Vi,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{eo(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(qn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(br,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Zc,{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(Kc,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,E)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>eo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:k[S.platform.toLowerCase()]||"🔗"},E))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(Fie,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function cxt({card:t}){var E,D,L,B;const[s,r]=T.useState(!1),[n,a]=T.useState("booking"),o=((E=t.profile)==null?void 0:E.name)||"Agent",l=o.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2),i={accent:((D=t.bold_theme_colors)==null?void 0:D.accent)||"#ff5722",dark:((L=t.bold_theme_colors)==null?void 0:L.dark)||"#1a1a2e",button:((B=t.bold_theme_colors)==null?void 0:B.button)||"#ff5722"},d=($,V)=>{const W=parseInt($.replace("#",""),16),G=Math.max(0,(W>>16)-V),J=Math.max(0,(W>>8&255)-V),ne=Math.max(0,(W&255)-V);return`#${(G<<16|J<<8|ne).toString(16).padStart(6,"0")}`};d(i.accent,25),d(i.dark,-20),d(i.button,25);const h=($,V)=>{eo(t.id,"button_click",$),V()},f=()=>h("call",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`tel:${t.profile.phone}`:be.error("Phone number not available")}),g=()=>h("text",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`sms:${t.profile.phone}`:be.error("Phone number not available")}),v=()=>h("email",()=>{var $;($=t.profile)!=null&&$.email?window.location.href=`mailto:${t.profile.email}`:be.error("Email not available")}),_=()=>{t.booking_url?h("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),eo(t.id,"button_click","book"))},j=()=>{var $,V;eo(t.id,"contact_saved"),Bie({name:o,phone:($=t.profile)==null?void 0:$.phone,email:(V=t.profile)==null?void 0:V.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},w=async()=>{if(eo(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),be.success("Link copied!")},k=()=>{a("referral"),r(!0),eo(t.id,"button_click","refer")},M=()=>{a("connect"),r(!0),eo(t.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(fn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(_a,{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:Ha,label:"Call",handler:f},{icon:Eo,label:"Text",handler:g},{icon:zr,label:"Email",handler:v}].map(({icon:$,label:V,handler:W})=>e.jsxs("button",{onClick:W,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:V})]},V))}),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(xn,{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(qn,{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(Rie,{card:t,variant:"bold"}),e.jsx(zie,{cardId:t.id,variant:"bold"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&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(Vi,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{eo(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(qn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(br,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:M,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(Zc,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Kc,{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(($,V)=>e.jsx("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>eo(t.id,"button_click",`social_${$.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:S[$.platform.toLowerCase()]||"🔗"},V))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(Fie,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function dxt({card:t}){var M;const[s,r]=T.useState(!1),[n,a]=T.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,E)=>{eo(t.id,"button_click",S),E()},d=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:be.error("Phone number not available")}),h=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:be.error("Phone number not available")}),f=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:be.error("Email not available")}),g=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),eo(t.id,"button_click","book"))},v=()=>{var S,E;eo(t.id,"contact_saved"),Bie({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(E=t.profile)==null?void 0:E.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(eo(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),be.success("Link copied!")},j=()=>{a("referral"),r(!0),eo(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),eo(t.id,"button_click","connect")},k={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(_a,{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:Ha,label:"Call",handler:d},{icon:Eo,label:"Text",handler:h},{icon:zr,label:"Email",handler:f}].map(({icon:S,label:E,handler:D})=>e.jsxs("button",{onClick:D,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(S,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:E})]},E))}),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(xn,{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(qn,{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(Rie,{card:t,variant:"classic"}),e.jsx(zie,{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(Vi,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{eo(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(qn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_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(br,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Zc,{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(Kc,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,E)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>eo(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:k[S.platform.toLowerCase()]||"🔗"},E))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(Fie,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Kve({card:t}){switch(t.theme){case"luxury":return e.jsx(lxt,{card:t});case"bold":return e.jsx(cxt,{card:t});case"classic":return e.jsx(dxt,{card:t});case"standard":default:return e.jsx(oxt,{card:t})}}function uxt(){const t=pm();T.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(hxt,{slug:s})}function hxt({slug:t}){return e.jsx(mxt,{slug:t})}function mxt({slug:t}){var o;const{data:s,isLoading:r,error:n}=M7e(t);if(T.useEffect(()=>{s!=null&&s.id&&eo(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(ys,{className:"h-28 w-28 rounded-full"}),e.jsx(ys,{className:"h-6 w-48"}),e.jsx(ys,{className:"h-4 w-36"})]}),e.jsx(ys,{className:"h-12 w-full"}),e.jsx(ys,{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(Ih,{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(Kve,{card:s})]})}function I7e({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=T.useState(n||""),[d,h]=T.useState(a||""),[f,g]=T.useState(o||""),[v,_]=T.useState(""),[j,w]=T.useState(""),[k,M]=T.useState(!1),[S,E]=T.useState(!1),D=async L=>{if(L.preventDefault(),!l.trim()){be.error("Please enter your name");return}M(!0);try{const{error:B}=await Z.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:d.trim()||null,phone:f.trim()||null,intent:v||null,message:j.trim()||null});if(B)throw B;try{await Z.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{}Z.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:d.trim()||void 0,phone:f.trim()||void 0,intent:v||void 0,message:j.trim()||void 0}}).catch($=>console.error("Presentation lead notify failed:",$)),E(!0)}catch{be.error("Something went wrong. Please try again.")}finally{M(!1)}};return S?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ma,{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:D,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(Be,{id:"pres-lead-name",value:l,onChange:L=>i(L.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(Be,{id:"pres-lead-phone",type:"tel",value:f,onChange:L=>g(L.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(Be,{id:"pres-lead-email",type:"email",value:d,onChange:L=>h(L.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(er,{value:v,onValueChange:_,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select one"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"buy",children:"Buy a home"}),e.jsx(Et,{value:"sell",children:"Sell my home"}),e.jsx(Et,{value:"both",children:"Buy & Sell"}),e.jsx(Et,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(Be,{id:"pres-lead-message",value:j,onChange:L=>w(L.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(Y,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:k,children:k?"Sending...":s})]})}function pxt(){const t=pm();T.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(fxt,{shareToken:s})}function fxt({shareToken:t}){var j;const[s,r]=T.useState(null),[n,a]=T.useState(!0),[o,l]=T.useState(0),[i,d]=T.useState(!1);T.useEffect(()=>{h()},[t]);const h=async()=>{const{data:w,error:k}=await Z.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(k||!w){d(!0),a(!1);return}const{data:M}=await Z.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let S;if(M!=null&&M.brokerage_id){const{data:D}=await Z.from("brokerages").select("name").eq("id",M.brokerage_id).single();S=(D==null?void 0:D.name)||void 0}let E=null;if(w.contact_id){const{data:D}=await Z.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();E=D}r({...w,owner_name:M==null?void 0:M.name,owner_email:M==null?void 0:M.email,owner_phone:M==null?void 0:M.phone,owner_avatar:M==null?void 0:M.avatar_url,owner_title:(M==null?void 0:M.title)||void 0,brokerage_name:S,contact_name:E?[E.first_name,E.last_name].filter(Boolean).join(" "):void 0,contact_email:(E==null?void 0:E.email)||void 0,contact_phone:(E==null?void 0:E.phone)||void 0}),a(!1);try{await Z.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{}},f=async()=>{if(s){try{await Z.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=w=>{const k=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(k)return`https://www.youtube.com/embed/${k[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const E=w.replace("/play/","/embed/"),D=E.includes("?")?"&":"?";return`${E}${D}responsive=true`}if(w.includes("iframe.mediadelivery.net")){const E=w.includes("?")?"&":"?";return`${w}${E}responsive=true`}const M=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(M)return`https://www.loom.com/embed/${M[1]}`;const S=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return S?`https://iframe.mediadelivery.net/embed/${S[1]}/${S[2]}?responsive=true`:w};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(ys,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{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(w=>w.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((w,k)=>e.jsx("button",{onClick:()=>l(k),className:$t("w-full text-left p-4 rounded-xl border transition-all",o===k?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(k+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children: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})]})]})},k))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(j=s.cta_url)!=null&&j.trim()?e.jsxs(Y,{size:"lg",onClick:f,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(bn,{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(I7e,{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 gxt(){const{user:t}=Ys();return zt({queryKey:["open-houses",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.from("open_houses").select("*").order("event_date",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function xxt(t){const{user:s}=Ys(),r=vs();return T.useEffect(()=>{if(!t)return;const n=Z.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()=>{Z.removeChannel(n)}},[t,r]),zt({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await Z.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 yxt(){const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{data:n,error:a}=await Z.from("open_houses").insert({...r,agent_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),pn({title:"Open house created!"})},onError:r=>{pn({title:"Error",description:r.message,variant:"destructive"})}})}function P7e(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{error:n}=await Z.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 vxt(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),pn({title:"Open house deleted"})}})}function L7e(t){return zt({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await Z.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 Z.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 D7e(){return Wt({mutationFn:async t=>{const{error:s}=await Z.from("open_house_visitors").insert(t);if(s)throw s}})}var $ie="Switch",[_xt]=Dc($ie),[bxt,wxt]=_xt($ie),O7e=T.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:h,form:f,...g}=t,[v,_]=T.useState(null),j=ba(s,E=>_(E)),w=T.useRef(!1),k=v?f||!!v.closest("form"):!0,[M,S]=Sh({prop:a,defaultProp:o??!1,onChange:h,caller:$ie});return e.jsxs(bxt,{scope:r,checked:M,disabled:i,children:[e.jsx(Qr.button,{type:"button",role:"switch","aria-checked":M,"aria-required":l,"data-state":B7e(M),"data-disabled":i?"":void 0,disabled:i,value:d,...g,ref:j,onClick:kr(t.onClick,E=>{S(D=>!D),k&&(w.current=E.isPropagationStopped(),w.current||E.stopPropagation())})}),k&&e.jsx(z7e,{control:v,bubbles:!w.current,name:n,value:d,checked:M,required:l,disabled:i,form:f,style:{transform:"translateX(-100%)"}})]})});O7e.displayName=$ie;var R7e="SwitchThumb",F7e=T.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=wxt(R7e,r);return e.jsx(Qr.span,{"data-state":B7e(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});F7e.displayName=R7e;var jxt="SwitchBubbleInput",z7e=T.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=T.useRef(null),i=ba(l,o),d=O6(r),h=k6(s);return T.useEffect(()=>{const f=l.current;if(!f)return;const g=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(g,"checked").set;if(d!==r&&_){const j=new Event("click",{bubbles:n});_.call(f,r),f.dispatchEvent(j)}},[d,r,n]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});z7e.displayName=jxt;function B7e(t){return t?"checked":"unchecked"}var $7e=O7e,kxt=F7e;const ln=T.forwardRef(({className:t,...s},r)=>e.jsx($7e,{className:$t("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(kxt,{className:$t("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")})}));ln.displayName=$7e.displayName;function Rn(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function qo(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Ul(t,s){const r=Rn(t);return isNaN(s)?qo(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Ch(t,s){const r=Rn(t);if(isNaN(s))return qo(t,NaN);if(!s)return r;const n=r.getDate(),a=qo(t,r.getTime());a.setMonth(r.getMonth()+s+1,0);const o=a.getDate();return n>=o?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}function U7e(t,s){const r=+Rn(t);return qo(t,r+s)}const Zve=6048e5,Nxt=864e5,Uie=6e4,R6=36e5,Sxt=1e3,HO=43200,j4e=1440;function k4e(t,s){return U7e(t,s*R6)}let Cxt={};function d_(){return Cxt}function Uu(t,s){var i,d,h,f;const r=d_(),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??((f=(h=r.locale)==null?void 0:h.options)==null?void 0:f.weekStartsOn)??0,a=Rn(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function ip(t){const s=Rn(t);return s.setHours(0,0,0,0),s}function Z1(t){const s=Rn(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 ig(t,s){const r=ip(t),n=ip(s),a=+r-Z1(r),o=+n-Z1(n);return Math.round((a-o)/Nxt)}function Mxt(t){const s=q7e(t),r=qo(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),y0(r)}function N4e(t,s){return U7e(t,s*Uie)}function Gj(t,s){const r=s*7;return Ul(t,r)}function Txt(t,s){return Ch(t,s*12)}function Axt(t){let s;return t.forEach(function(r){const n=Rn(r);(s===void 0||s{const n=Rn(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function wse(t,s){const r=Rn(t),n=Rn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function Yve(t){return qo(t,Date.now())}function Vl(t,s){const r=ip(t),n=ip(s);return+r==+n}function Xve(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Rfe(t){if(!Xve(t)&&typeof t!="number")return!1;const s=Rn(t);return!isNaN(Number(s))}function R5(t,s){const r=Rn(t),n=Rn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function Ixt(t,s,r){const n=Uu(t,r),a=Uu(s,r),o=+n-Z1(n),l=+a-Z1(a);return Math.round((o-l)/Zve)}function bg(t,s){const r=Rn(t),n=Rn(s),a=S4e(r,n),o=Math.abs(ig(r,n));r.setDate(r.getDate()-a*o);const l=+(S4e(r,n)===-a),i=a*(o-l);return i===0?0:i}function S4e(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 V7e(t){return s=>{const r=Math.trunc,n=r(s);return n===0?0:n}}function H7e(t,s){return+Rn(t)-+Rn(s)}function Pxt(t,s,r){const n=H7e(t,s)/R6;return V7e()(n)}function Lxt(t){const s=Rn(t);return s.setHours(23,59,59,999),s}function F6(t){const s=Rn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function Dxt(t){const s=Rn(t);return+Lxt(s)==+F6(s)}function Oxt(t,s){const r=Rn(t),n=Rn(s),a=wse(r,n),o=Math.abs(R5(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=wse(r,n)===-a;Dxt(Rn(t))&&o===1&&wse(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function Rxt(t,s,r){const n=H7e(t,s)/1e3;return V7e()(n)}function Fxt(t,s){const r=Rn(t.start),n=Rn(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(Rn(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?d.reverse():d}function Nh(t){const s=Rn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function W7e(t){const s=Rn(t),r=qo(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function qie(t,s){var i,d,h,f;const r=d_(),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??((f=(h=r.locale)==null?void 0:h.options)==null?void 0:f.weekStartsOn)??0,a=Rn(t),o=a.getDay(),l=(o{let n;const a=zxt[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 Gue(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const $xt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Uxt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},qxt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Vxt={date:Gue({formats:$xt,defaultWidth:"full"}),time:Gue({formats:Uxt,defaultWidth:"full"}),dateTime:Gue({formats:qxt,defaultWidth:"full"})},Hxt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Wxt=(t,s,r,n)=>Hxt[t];function _A(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 Gxt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Kxt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Zxt={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"]},Yxt={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"]},Xxt={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"}},Qxt={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"}},Jxt=(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"},eyt={ordinalNumber:Jxt,era:_A({values:Gxt,defaultWidth:"wide"}),quarter:_A({values:Kxt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:_A({values:Zxt,defaultWidth:"wide"}),day:_A({values:Yxt,defaultWidth:"wide"}),dayPeriod:_A({values:Xxt,defaultWidth:"wide",formattingValues:Qxt,defaultFormattingWidth:"wide"})};function bA(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)?syt(i,g=>g.test(l)):tyt(i,g=>g.test(l));let h;h=t.valueCallback?t.valueCallback(d):d,h=r.valueCallback?r.valueCallback(h):h;const f=s.slice(l.length);return{value:h,rest:f}}}function tyt(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function syt(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 nyt=/^(\d+)(th|st|nd|rd)?/i,ayt=/\d+/i,iyt={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},oyt={any:[/^b/i,/^(a|c)/i]},lyt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},cyt={any:[/1/i,/2/i,/3/i,/4/i]},dyt={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},uyt={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]},hyt={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},myt={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]},pyt={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},fyt={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}},gyt={ordinalNumber:ryt({matchPattern:nyt,parsePattern:ayt,valueCallback:t=>parseInt(t,10)}),era:bA({matchPatterns:iyt,defaultMatchWidth:"wide",parsePatterns:oyt,defaultParseWidth:"any"}),quarter:bA({matchPatterns:lyt,defaultMatchWidth:"wide",parsePatterns:cyt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:bA({matchPatterns:dyt,defaultMatchWidth:"wide",parsePatterns:uyt,defaultParseWidth:"any"}),day:bA({matchPatterns:hyt,defaultMatchWidth:"wide",parsePatterns:myt,defaultParseWidth:"any"}),dayPeriod:bA({matchPatterns:pyt,defaultMatchWidth:"any",parsePatterns:fyt,defaultParseWidth:"any"})},Vie={code:"en-US",formatDistance:Bxt,formatLong:Vxt,formatRelative:Wxt,localize:eyt,match:gyt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function xyt(t){const s=Rn(t);return ig(s,W7e(s))+1}function Qve(t){const s=Rn(t),r=+y0(s)-+Mxt(s);return Math.round(r/Zve)+1}function Jve(t,s){var f,g,v,_;const r=Rn(t),n=r.getFullYear(),a=d_(),o=(s==null?void 0:s.firstWeekContainsDate)??((g=(f=s==null?void 0:s.locale)==null?void 0:f.options)==null?void 0:g.firstWeekContainsDate)??a.firstWeekContainsDate??((_=(v=a.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=qo(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Uu(l,s),d=qo(t,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const h=Uu(d,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=h.getTime()?n:n-1}function yyt(t,s){var i,d,h,f;const r=d_(),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??((f=(h=r.locale)==null?void 0:h.options)==null?void 0:f.firstWeekContainsDate)??1,a=Jve(t,s),o=qo(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Uu(o,s)}function e1e(t,s){const r=Rn(t),n=+Uu(r,s)-+yyt(r,s);return Math.round(n/Zve)+1}function $o(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const _v={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return $o(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):$o(r+1,2)},d(t,s){return $o(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 $o(t.getHours()%12||12,s.length)},H(t,s){return $o(t.getHours(),s.length)},m(t,s){return $o(t.getMinutes(),s.length)},s(t,s){return $o(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return $o(a,s.length)}},NC={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},C4e={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 _v.y(t,s)},Y:function(t,s,r,n){const a=Jve(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return $o(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):$o(o,s.length)},R:function(t,s){const r=q7e(t);return $o(r,s.length)},u:function(t,s){const r=t.getFullYear();return $o(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 $o(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 $o(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 _v.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 $o(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=e1e(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):$o(a,s.length)},I:function(t,s,r){const n=Qve(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):$o(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):_v.d(t,s)},D:function(t,s,r){const n=xyt(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):$o(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 $o(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 $o(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 $o(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=NC.noon:n===0?a=NC.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=NC.evening:n>=12?a=NC.afternoon:n>=4?a=NC.morning:a=NC.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 _v.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):_v.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):$o(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):$o(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):_v.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):_v.s(t,s)},S:function(t,s){return _v.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return T4e(n);case"XXXX":case"XX":return Pj(n);case"XXXXX":case"XXX":default:return Pj(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return T4e(n);case"xxxx":case"xx":return Pj(n);case"xxxxx":case"xxx":default:return Pj(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+M4e(n,":");case"OOOO":default:return"GMT"+Pj(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+M4e(n,":");case"zzzz":default:return"GMT"+Pj(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return $o(n,s.length)},T:function(t,s,r){const n=t.getTime();return $o(n,s.length)}};function M4e(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+$o(o,2)}function T4e(t,s){return t%60===0?(t>0?"-":"+")+$o(Math.abs(t)/60,2):Pj(t,s)}function Pj(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=$o(Math.trunc(n/60),2),o=$o(n%60,2);return r+a+s+o}const A4e=(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"})}},K7e=(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"})}},vyt=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return A4e(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}}",A4e(n,s)).replace("{{time}}",K7e(a,s))},Ffe={p:K7e,P:vyt},_yt=/^D+$/,byt=/^Y+$/,wyt=["D","DD","YY","YYYY"];function Z7e(t){return _yt.test(t)}function Y7e(t){return byt.test(t)}function zfe(t,s,r){const n=jyt(t,s,r);if(console.warn(n),wyt.includes(t))throw new RangeError(n)}function jyt(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 kyt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Nyt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Syt=/^'([^]*?)'?$/,Cyt=/''/g,Myt=/[a-zA-Z]/;function Bs(t,s,r){var f,g,v,_,j,w,k,M;const n=d_(),a=(r==null?void 0:r.locale)??n.locale??Vie,o=(r==null?void 0:r.firstWeekContainsDate)??((g=(f=r==null?void 0:r.locale)==null?void 0:f.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)??((w=(j=r==null?void 0:r.locale)==null?void 0:j.options)==null?void 0:w.weekStartsOn)??n.weekStartsOn??((M=(k=n.locale)==null?void 0:k.options)==null?void 0:M.weekStartsOn)??0,i=Rn(t);if(!Rfe(i))throw new RangeError("Invalid time value");let d=s.match(Nyt).map(S=>{const E=S[0];if(E==="p"||E==="P"){const D=Ffe[E];return D(S,a.formatLong)}return S}).join("").match(kyt).map(S=>{if(S==="''")return{isToken:!1,value:"'"};const E=S[0];if(E==="'")return{isToken:!1,value:Tyt(S)};if(C4e[E])return{isToken:!0,value:S};if(E.match(Myt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+E+"`");return{isToken:!1,value:S}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const h={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return d.map(S=>{if(!S.isToken)return S.value;const E=S.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&Y7e(E)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&Z7e(E))&&zfe(E,s,String(t));const D=C4e[E[0]];return D(i,E,a.localize,h)}).join("")}function Tyt(t){const s=t.match(Syt);return s?s[1].replace(Cyt,"'"):t}function Ayt(t,s,r){const n=d_(),a=(r==null?void 0:r.locale)??n.locale??Vie,o=2520,l=wse(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,h;l>0?(d=Rn(s),h=Rn(t)):(d=Rn(t),h=Rn(s));const f=Rxt(h,d),g=(Z1(h)-Z1(d))/1e3,v=Math.round((f-g)/60);let _;if(v<2)return r!=null&&r.includeSeconds?f<5?a.formatDistance("lessThanXSeconds",5,i):f<10?a.formatDistance("lessThanXSeconds",10,i):f<20?a.formatDistance("lessThanXSeconds",20,i):f<40?a.formatDistance("halfAMinute",0,i):f<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 Hie(t,s){const r=Rn(t),n=Rn(s);return+r<+n}function Ryt(t){return+Rn(t)>Date.now()}function Fyt(t,s){const r=s instanceof Date?qo(s,0):new s(0);return r.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),r.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),r}const zyt=10;class X7e{constructor(){hn(this,"subPriority",0)}validate(s,r){return!0}}class Byt extends X7e{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 $yt extends X7e{constructor(){super(...arguments);hn(this,"priority",zyt);hn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:qo(r,Fyt(r,Date))}}class Io{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new Byt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class Uyt extends Io{constructor(){super(...arguments);hn(this,"priority",140);hn(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 Hc={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}/},px={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 Wc(t,s){return t&&{value:s(t.value),rest:t.rest}}function sc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function fx(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*R6+o*Uie+l*Sxt),rest:s.slice(r[0].length)}}function Q7e(t){return sc(Hc.anyDigitsSigned,t)}function Lc(t,s){switch(t){case 1:return sc(Hc.singleDigit,s);case 2:return sc(Hc.twoDigits,s);case 3:return sc(Hc.threeDigits,s);case 4:return sc(Hc.fourDigits,s);default:return sc(new RegExp("^\\d{1,"+t+"}"),s)}}function Ere(t,s){switch(t){case 1:return sc(Hc.singleDigitSigned,s);case 2:return sc(Hc.twoDigitsSigned,s);case 3:return sc(Hc.threeDigitsSigned,s);case 4:return sc(Hc.fourDigitsSigned,s);default:return sc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function t1e(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 J7e(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 eBe(t){return t%400===0||t%4===0&&t%100!==0}class qyt extends Io{constructor(){super(...arguments);hn(this,"priority",130);hn(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 Wc(Lc(4,r),o);case"yo":return Wc(a.ordinalNumber(r,{unit:"year"}),o);default:return Wc(Lc(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=J7e(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 Vyt extends Io{constructor(){super(...arguments);hn(this,"priority",130);hn(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 Wc(Lc(4,r),o);case"Yo":return Wc(a.ordinalNumber(r,{unit:"year"}),o);default:return Wc(Lc(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=Jve(r,o);if(a.isTwoDigitYear){const d=J7e(a.year,l);return r.setFullYear(d,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Uu(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),Uu(r,o)}}class Hyt extends Io{constructor(){super(...arguments);hn(this,"priority",130);hn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return Ere(n==="R"?4:n.length,r)}set(r,n,a){const o=qo(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),y0(o)}}class Wyt extends Io{constructor(){super(...arguments);hn(this,"priority",130);hn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return Ere(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class Gyt extends Io{constructor(){super(...arguments);hn(this,"priority",120);hn(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 Lc(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 Kyt extends Io{constructor(){super(...arguments);hn(this,"priority",120);hn(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 Lc(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 Zyt extends Io{constructor(){super(...arguments);hn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);hn(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return Wc(sc(Hc.month,r),o);case"MM":return Wc(Lc(2,r),o);case"Mo":return Wc(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 Yyt extends Io{constructor(){super(...arguments);hn(this,"priority",110);hn(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 Wc(sc(Hc.month,r),o);case"LL":return Wc(Lc(2,r),o);case"Lo":return Wc(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 Xyt(t,s,r){const n=Rn(t),a=e1e(n,r)-s;return n.setDate(n.getDate()-a*7),n}class Qyt extends Io{constructor(){super(...arguments);hn(this,"priority",100);hn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return sc(Hc.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Lc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return Uu(Xyt(r,a,o),o)}}function Jyt(t,s){const r=Rn(t),n=Qve(r)-s;return r.setDate(r.getDate()-n*7),r}class e0t extends Io{constructor(){super(...arguments);hn(this,"priority",100);hn(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(r,n,a){switch(n){case"I":return sc(Hc.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Lc(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return y0(Jyt(r,a))}}const t0t=[31,28,31,30,31,30,31,31,30,31,30,31],s0t=[31,29,31,30,31,30,31,31,30,31,30,31];class r0t extends Io{constructor(){super(...arguments);hn(this,"priority",90);hn(this,"subPriority",1);hn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return sc(Hc.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Lc(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=eBe(a),l=r.getMonth();return o?n>=1&&n<=s0t[l]:n>=1&&n<=t0t[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class n0t extends Io{constructor(){super(...arguments);hn(this,"priority",90);hn(this,"subpriority",1);hn(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(r,n,a){switch(n){case"D":case"DD":return sc(Hc.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Lc(n.length,r)}}validate(r,n){const a=r.getFullYear();return eBe(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 s1e(t,s,r){var g,v,_,j;const n=d_(),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??((j=(_=n.locale)==null?void 0:_.options)==null?void 0:j.weekStartsOn)??0,o=Rn(t),l=o.getDay(),d=(s%7+7)%7,h=7-a,f=s<0||s>6?s-(l+h)%7:(d+h)%7-(l+h)%7;return Ul(o,f)}class a0t extends Io{constructor(){super(...arguments);hn(this,"priority",90);hn(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=s1e(r,a,o),r.setHours(0,0,0,0),r}}class i0t extends Io{constructor(){super(...arguments);hn(this,"priority",90);hn(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 Wc(Lc(n.length,r),l);case"eo":return Wc(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=s1e(r,a,o),r.setHours(0,0,0,0),r}}class o0t extends Io{constructor(){super(...arguments);hn(this,"priority",90);hn(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 Wc(Lc(n.length,r),l);case"co":return Wc(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=s1e(r,a,o),r.setHours(0,0,0,0),r}}function l0t(t,s){const r=Rn(t),n=Pyt(r),a=s-n;return Ul(r,a)}class c0t extends Io{constructor(){super(...arguments);hn(this,"priority",90);hn(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 Lc(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return Wc(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 Wc(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Wc(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Wc(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=l0t(r,a),r.setHours(0,0,0,0),r}}class d0t extends Io{constructor(){super(...arguments);hn(this,"priority",80);hn(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(t1e(a),0,0,0),r}}class u0t extends Io{constructor(){super(...arguments);hn(this,"priority",80);hn(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(t1e(a),0,0,0),r}}class h0t extends Io{constructor(){super(...arguments);hn(this,"priority",80);hn(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(t1e(a),0,0,0),r}}class m0t extends Io{constructor(){super(...arguments);hn(this,"priority",70);hn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return sc(Hc.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Lc(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 p0t extends Io{constructor(){super(...arguments);hn(this,"priority",70);hn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return sc(Hc.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Lc(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class f0t extends Io{constructor(){super(...arguments);hn(this,"priority",70);hn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return sc(Hc.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Lc(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 g0t extends Io{constructor(){super(...arguments);hn(this,"priority",70);hn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return sc(Hc.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Lc(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 x0t extends Io{constructor(){super(...arguments);hn(this,"priority",60);hn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return sc(Hc.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Lc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class y0t extends Io{constructor(){super(...arguments);hn(this,"priority",50);hn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return sc(Hc.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Lc(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class v0t extends Io{constructor(){super(...arguments);hn(this,"priority",30);hn(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Wc(Lc(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class _0t extends Io{constructor(){super(...arguments);hn(this,"priority",10);hn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return fx(px.basicOptionalMinutes,r);case"XX":return fx(px.basic,r);case"XXXX":return fx(px.basicOptionalSeconds,r);case"XXXXX":return fx(px.extendedOptionalSeconds,r);case"XXX":default:return fx(px.extended,r)}}set(r,n,a){return n.timestampIsSet?r:qo(r,r.getTime()-Z1(r)-a)}}class b0t extends Io{constructor(){super(...arguments);hn(this,"priority",10);hn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return fx(px.basicOptionalMinutes,r);case"xx":return fx(px.basic,r);case"xxxx":return fx(px.basicOptionalSeconds,r);case"xxxxx":return fx(px.extendedOptionalSeconds,r);case"xxx":default:return fx(px.extended,r)}}set(r,n,a){return n.timestampIsSet?r:qo(r,r.getTime()-Z1(r)-a)}}class w0t extends Io{constructor(){super(...arguments);hn(this,"priority",40);hn(this,"incompatibleTokens","*")}parse(r){return Q7e(r)}set(r,n,a){return[qo(r,a*1e3),{timestampIsSet:!0}]}}class j0t extends Io{constructor(){super(...arguments);hn(this,"priority",20);hn(this,"incompatibleTokens","*")}parse(r){return Q7e(r)}set(r,n,a){return[qo(r,a),{timestampIsSet:!0}]}}const k0t={G:new Uyt,y:new qyt,Y:new Vyt,R:new Hyt,u:new Wyt,Q:new Gyt,q:new Kyt,M:new Zyt,L:new Yyt,w:new Qyt,I:new e0t,d:new r0t,D:new n0t,E:new a0t,e:new i0t,c:new o0t,i:new c0t,a:new d0t,b:new u0t,B:new h0t,h:new m0t,H:new p0t,K:new f0t,k:new g0t,m:new x0t,s:new y0t,S:new v0t,X:new _0t,x:new b0t,t:new w0t,T:new j0t},N0t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,S0t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,C0t=/^'([^]*?)'?$/,M0t=/''/g,T0t=/\S/,A0t=/[a-zA-Z]/;function r1e(t,s,r,n){var w,k,M,S;const a=Iyt(),o=a.locale??Vie,l=a.firstWeekContainsDate??((k=(w=a.locale)==null?void 0:w.options)==null?void 0:k.firstWeekContainsDate)??1,i=a.weekStartsOn??((S=(M=a.locale)==null?void 0:M.options)==null?void 0:S.weekStartsOn)??0;if(s==="")return t===""?Rn(r):qo(r,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},h=[new $yt],f=s.match(S0t).map(E=>{const D=E[0];if(D in Ffe){const L=Ffe[D];return L(E,o.formatLong)}return E}).join("").match(N0t),g=[];for(let E of f){Y7e(E)&&zfe(E,s,t),Z7e(E)&&zfe(E,s,t);const D=E[0],L=k0t[D];if(L){const{incompatibleTokens:B}=L;if(Array.isArray(B)){const V=g.find(W=>B.includes(W.token)||W.token===D);if(V)throw new RangeError(`The format string mustn't contain \`${V.fullToken}\` and \`${E}\` at the same time`)}else if(L.incompatibleTokens==="*"&&g.length>0)throw new RangeError(`The format string mustn't contain \`${E}\` and any other token at the same time`);g.push({token:D,fullToken:E});const $=L.run(t,E,o.match,d);if(!$)return qo(r,NaN);h.push($.setter),t=$.rest}else{if(D.match(A0t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+D+"`");if(E==="''"?E="'":D==="'"&&(E=E0t(E)),t.indexOf(E)===0)t=t.slice(E.length);else return qo(r,NaN)}}if(t.length>0&&T0t.test(t))return qo(r,NaN);const v=h.map(E=>E.priority).sort((E,D)=>D-E).filter((E,D,L)=>L.indexOf(E)===D).map(E=>h.filter(D=>D.priority===E).sort((D,L)=>L.subPriority-D.subPriority)).map(E=>E[0]);let _=Rn(r);if(isNaN(_.getTime()))return qo(r,NaN);const j={};for(const E of v){if(!E.validate(_,d))return qo(r,NaN);const D=E.set(_,j,d);Array.isArray(D)?(_=D[0],Object.assign(j,D[1])):_=D}return qo(r,_)}function E0t(t){return t.match(C0t)[1].replace(M0t,"'")}function Ix(t){return+Rn(t)o-l);return r>=n&&r<=a}function jse(t,s){return Ul(t,-s)}function ph(t,s){const n=F0t(t);let a;if(n.date){const d=z0t(n.date,2);a=B0t(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=$0t(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=U0t(n.timezone),isNaN(i))return new Date(NaN)}else{const d=new Date(o+l),h=new Date(0);return h.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),h.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),h}return new Date(o+l+i)}const WO={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},D0t=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,O0t=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,R0t=/^([+-])(\d{2})(?::?(\d{2}))?$/;function F0t(t){const s={},r=t.split(WO.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],WO.timeZoneDelimiter.test(s.date)&&(s.date=t.split(WO.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=WO.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function z0t(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 B0t(t,s){if(s===null)return new Date(NaN);const r=t.match(D0t);if(!r)return new Date(NaN);const n=!!r[4],a=wA(r[1]),o=wA(r[2])-1,l=wA(r[3]),i=wA(r[4]),d=wA(r[5])-1;if(n)return G0t(s,i,d)?q0t(s,i,d):new Date(NaN);{const h=new Date(0);return!H0t(s,o,l)||!W0t(s,a)?new Date(NaN):(h.setUTCFullYear(s,o,Math.max(a,l)),h)}}function wA(t){return t?parseInt(t):1}function $0t(t){const s=t.match(O0t);if(!s)return NaN;const r=Kue(s[1]),n=Kue(s[2]),a=Kue(s[3]);return K0t(r,n,a)?r*R6+n*Uie+a*1e3:NaN}function Kue(t){return t&&parseFloat(t.replace(",","."))||0}function U0t(t){if(t==="Z")return 0;const s=t.match(R0t);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return Z0t(n,a)?r*(n*R6+a*Uie):NaN}function q0t(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 V0t=[31,null,31,30,31,30,31,31,30,31,30,31];function tBe(t){return t%400===0||t%4===0&&t%100!==0}function H0t(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(V0t[s]||(tBe(t)?29:28))}function W0t(t,s){return s>=1&&s<=(tBe(t)?366:365)}function G0t(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function K0t(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function Z0t(t,s){return s>=0&&s<=59}function Zue(t,s){const r=Rn(t),n=r.getFullYear(),a=r.getDate(),o=qo(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=Eyt(o);return r.setMonth(s,Math.min(a,l)),r}function sBe(t,s){const r=Rn(t);return r.setHours(s),r}function rBe(t,s){const r=Rn(t);return r.setMinutes(s),r}function I4e(t,s){const r=Rn(t);return isNaN(+r)?qo(t,NaN):(r.setFullYear(s),r)}function nBe(t,s){return Ch(t,-s)}var No;(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})(No||(No={}));var P4e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(P4e||(P4e={}));const Jn=No.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pv=t=>{switch(typeof t){case"undefined":return Jn.undefined;case"string":return Jn.string;case"number":return Number.isNaN(t)?Jn.nan:Jn.number;case"boolean":return Jn.boolean;case"function":return Jn.function;case"bigint":return Jn.bigint;case"symbol":return Jn.symbol;case"object":return Array.isArray(t)?Jn.array:t===null?Jn.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Jn.promise:typeof Map<"u"&&t instanceof Map?Jn.map:typeof Set<"u"&&t instanceof Set?Jn.set:typeof Date<"u"&&t instanceof Date?Jn.date:Jn.object;default:return Jn.unknown}},Kr=No.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 Fx 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()}}Fx.create=t=>new Fx(t);const Bfe=(t,s)=>{let r;switch(t.code){case Kr.invalid_type:t.received===Jn.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Kr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,No.jsonStringifyReplacer)}`;break;case Kr.unrecognized_keys:r=`Unrecognized key(s) in object: ${No.joinValues(t.keys,", ")}`;break;case Kr.invalid_union:r="Invalid input";break;case Kr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${No.joinValues(t.options)}`;break;case Kr.invalid_enum_value:r=`Invalid enum value. Expected ${No.joinValues(t.options)}, received '${t.received}'`;break;case Kr.invalid_arguments:r="Invalid function arguments";break;case Kr.invalid_return_type:r="Invalid function return type";break;case Kr.invalid_date:r="Invalid date";break;case Kr.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}"`:No.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Kr.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 Kr.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 Kr.custom:r="Invalid input";break;case Kr.invalid_intersection_types:r="Intersection results could not be merged";break;case Kr.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Kr.not_finite:r="Number must be finite";break;default:r=s.defaultError,No.assertNever(t)}return{message:r}};let Y0t=Bfe;function X0t(){return Y0t}const Q0t=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(h=>!!h).slice().reverse();for(const h of d)i=h(l,{data:s,defaultError:i}).message;return{...a,path:o,message:i}};function Pn(t,s){const r=X0t(),n=Q0t({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Bfe?void 0:Bfe].filter(a=>!!a)});t.common.issues.push(n)}class op{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 xi;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 op.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 xi;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 xi=Object.freeze({status:"aborted"}),eE=t=>({status:"dirty",value:t}),nf=t=>({status:"valid",value:t}),L4e=t=>t.status==="aborted",D4e=t=>t.status==="dirty",F5=t=>t.status==="valid",Pre=t=>typeof Promise<"u"&&t instanceof Promise;var la;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(la||(la={}));class Y1{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 O4e=(t,s)=>{if(F5(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 Fx(t.common.issues);return this._error=r,this._error}}};function Hi(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 wo{get description(){return this._def.description}_getType(s){return Pv(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:Pv(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new op,ctx:{common:s.parent.common,data:s.data,parsedType:Pv(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(Pre(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:Pv(s)},a=this._parseSync({data:s,path:n.path,parent:n});return O4e(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:Pv(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return F5(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=>F5(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:Pv(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(Pre(a)?a:Promise.resolve(a));return O4e(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:Kr.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 $5({schema:this,typeName:vi.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 O1.create(this,this._def)}nullable(){return U5.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Px.create(this)}promise(){return Rre.create(this,this._def)}or(s){return Dre.create([this,s],this._def)}and(s){return Ore.create(this,s,this._def)}transform(s){return new $5({...Hi(this._def),schema:this,typeName:vi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Vfe({...Hi(this._def),innerType:this,defaultValue:r,typeName:vi.ZodDefault})}brand(){return new bvt({typeName:vi.ZodBranded,type:this,...Hi(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Hfe({...Hi(this._def),innerType:this,catchValue:r,typeName:vi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return n1e.create(this,s)}readonly(){return Wfe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const J0t=/^c[^\s-]{8,}$/i,evt=/^[0-9a-z]+$/,tvt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,svt=/^[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,rvt=/^[a-z0-9_-]{21}$/i,nvt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,avt=/^[-+]?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)?)??$/,ivt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ovt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Yue;const lvt=/^(?:(?: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])$/,cvt=/^(?:(?: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])$/,dvt=/^(([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]))$/,uvt=/^(([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])$/,hvt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mvt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aBe="((\\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])))",pvt=new RegExp(`^${aBe}$`);function iBe(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 fvt(t){return new RegExp(`^${iBe(t)}$`)}function gvt(t){let s=`${aBe}T${iBe(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 xvt(t,s){return!!((s==="v4"||!s)&&lvt.test(t)||(s==="v6"||!s)&&dvt.test(t))}function yvt(t,s){if(!nvt.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 vvt(t,s){return!!((s==="v4"||!s)&&cvt.test(t)||(s==="v6"||!s)&&uvt.test(t))}class c1 extends wo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==Jn.string){const o=this._getOrReturnCtx(s);return Pn(o,{code:Kr.invalid_type,expected:Jn.string,received:o.parsedType}),xi}const n=new op;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Pn(a,{code:Kr.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:Kr.invalid_string,...la.errToObj(n)})}_addCheck(s){return new c1({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...la.errToObj(s)})}url(s){return this._addCheck({kind:"url",...la.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...la.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...la.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...la.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...la.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...la.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...la.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...la.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...la.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...la.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...la.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...la.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,...la.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,...la.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...la.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...la.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...la.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...la.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...la.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...la.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...la.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...la.errToObj(r)})}nonempty(s){return this.min(1,la.errToObj(s))}trim(){return new c1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new c1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new c1({...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 c1({checks:[],typeName:vi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Hi(t)});function _vt(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 z5 extends wo{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)!==Jn.number){const o=this._getOrReturnCtx(s);return Pn(o,{code:Kr.invalid_type,expected:Jn.number,received:o.parsedType}),xi}let n;const a=new op;for(const o of this._def.checks)o.kind==="int"?No.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Pn(n,{code:Kr.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),Pn(n,{code:Kr.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?_vt(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Pn(n,{code:Kr.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Pn(n,{code:Kr.not_finite,message:o.message}),a.dirty()):No.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,la.toString(r))}gt(s,r){return this.setLimit("min",s,!1,la.toString(r))}lte(s,r){return this.setLimit("max",s,!0,la.toString(r))}lt(s,r){return this.setLimit("max",s,!1,la.toString(r))}setLimit(s,r,n,a){return new z5({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:la.toString(a)}]})}_addCheck(s){return new z5({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:la.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:la.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:la.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:la.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:la.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:la.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:la.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:la.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:la.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"&&No.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 z5({checks:[],typeName:vi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Hi(t)});class oP extends wo{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)!==Jn.bigint)return this._getInvalidInput(s);let n;const a=new op;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Pn(n,{code:Kr.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),Pn(n,{code:Kr.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):No.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Pn(r,{code:Kr.invalid_type,expected:Jn.bigint,received:r.parsedType}),xi}gte(s,r){return this.setLimit("min",s,!0,la.toString(r))}gt(s,r){return this.setLimit("min",s,!1,la.toString(r))}lte(s,r){return this.setLimit("max",s,!0,la.toString(r))}lt(s,r){return this.setLimit("max",s,!1,la.toString(r))}setLimit(s,r,n,a){return new oP({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:la.toString(a)}]})}_addCheck(s){return new oP({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:la.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:la.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:la.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:la.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:la.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 oP({checks:[],typeName:vi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Hi(t)});class $fe extends wo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==Jn.boolean){const n=this._getOrReturnCtx(s);return Pn(n,{code:Kr.invalid_type,expected:Jn.boolean,received:n.parsedType}),xi}return nf(s.data)}}$fe.create=t=>new $fe({typeName:vi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Hi(t)});class Lre extends wo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==Jn.date){const o=this._getOrReturnCtx(s);return Pn(o,{code:Kr.invalid_type,expected:Jn.date,received:o.parsedType}),xi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Pn(o,{code:Kr.invalid_date}),xi}const n=new op;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Pn(a,{code:Kr.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):No.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new Lre({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:la.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:la.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 Lre({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:vi.ZodDate,...Hi(t)});class R4e extends wo{_parse(s){if(this._getType(s)!==Jn.symbol){const n=this._getOrReturnCtx(s);return Pn(n,{code:Kr.invalid_type,expected:Jn.symbol,received:n.parsedType}),xi}return nf(s.data)}}R4e.create=t=>new R4e({typeName:vi.ZodSymbol,...Hi(t)});class F4e extends wo{_parse(s){if(this._getType(s)!==Jn.undefined){const n=this._getOrReturnCtx(s);return Pn(n,{code:Kr.invalid_type,expected:Jn.undefined,received:n.parsedType}),xi}return nf(s.data)}}F4e.create=t=>new F4e({typeName:vi.ZodUndefined,...Hi(t)});class z4e extends wo{_parse(s){if(this._getType(s)!==Jn.null){const n=this._getOrReturnCtx(s);return Pn(n,{code:Kr.invalid_type,expected:Jn.null,received:n.parsedType}),xi}return nf(s.data)}}z4e.create=t=>new z4e({typeName:vi.ZodNull,...Hi(t)});class B4e extends wo{constructor(){super(...arguments),this._any=!0}_parse(s){return nf(s.data)}}B4e.create=t=>new B4e({typeName:vi.ZodAny,...Hi(t)});class $4e extends wo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return nf(s.data)}}$4e.create=t=>new $4e({typeName:vi.ZodUnknown,...Hi(t)});class X1 extends wo{_parse(s){const r=this._getOrReturnCtx(s);return Pn(r,{code:Kr.invalid_type,expected:Jn.never,received:r.parsedType}),xi}}X1.create=t=>new X1({typeName:vi.ZodNever,...Hi(t)});class U4e extends wo{_parse(s){if(this._getType(s)!==Jn.undefined){const n=this._getOrReturnCtx(s);return Pn(n,{code:Kr.invalid_type,expected:Jn.void,received:n.parsedType}),xi}return nf(s.data)}}U4e.create=t=>new U4e({typeName:vi.ZodVoid,...Hi(t)});class Px extends wo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==Jn.array)return Pn(r,{code:Kr.invalid_type,expected:Jn.array,received:r.parsedType}),xi;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Pn(r,{code:Kr.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 Y1(r,l,r.path,i)))).then(l=>op.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new Y1(r,l,r.path,i)));return op.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new Px({...this._def,minLength:{value:s,message:la.toString(r)}})}max(s,r){return new Px({...this._def,maxLength:{value:s,message:la.toString(r)}})}length(s,r){return new Px({...this._def,exactLength:{value:s,message:la.toString(r)}})}nonempty(s){return this.min(1,s)}}Px.create=(t,s)=>new Px({type:t,minLength:null,maxLength:null,exactLength:null,typeName:vi.ZodArray,...Hi(s)});function FC(t){if(t instanceof od){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=O1.create(FC(n))}return new od({...t._def,shape:()=>s})}else return t instanceof Px?new Px({...t._def,type:FC(t.element)}):t instanceof O1?O1.create(FC(t.unwrap())):t instanceof U5?U5.create(FC(t.unwrap())):t instanceof nN?nN.create(t.items.map(s=>FC(s))):t}class od extends wo{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=No.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==Jn.object){const h=this._getOrReturnCtx(s);return Pn(h,{code:Kr.invalid_type,expected:Jn.object,received:h.parsedType}),xi}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof X1&&this._def.unknownKeys==="strip"))for(const h in a.data)l.includes(h)||i.push(h);const d=[];for(const h of l){const f=o[h],g=a.data[h];d.push({key:{status:"valid",value:h},value:f._parse(new Y1(a,g,a.path,h)),alwaysSet:h in a.data})}if(this._def.catchall instanceof X1){const h=this._def.unknownKeys;if(h==="passthrough")for(const f of i)d.push({key:{status:"valid",value:f},value:{status:"valid",value:a.data[f]}});else if(h==="strict")i.length>0&&(Pn(a,{code:Kr.unrecognized_keys,keys:i}),n.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const f of i){const g=a.data[f];d.push({key:{status:"valid",value:f},value:h._parse(new Y1(a,g,a.path,f)),alwaysSet:f in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const h=[];for(const f of d){const g=await f.key,v=await f.value;h.push({key:g,value:v,alwaysSet:f.alwaysSet})}return h}).then(h=>op.mergeObjectSync(n,h)):op.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(s){return la.errToObj,new od({...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:la.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new od({...this._def,unknownKeys:"strip"})}passthrough(){return new od({...this._def,unknownKeys:"passthrough"})}extend(s){return new od({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new od({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:vi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new od({...this._def,catchall:s})}pick(s){const r={};for(const n of No.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new od({...this._def,shape:()=>r})}omit(s){const r={};for(const n of No.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new od({...this._def,shape:()=>r})}deepPartial(){return FC(this)}partial(s){const r={};for(const n of No.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new od({...this._def,shape:()=>r})}required(s){const r={};for(const n of No.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof O1;)o=o._def.innerType;r[n]=o}return new od({...this._def,shape:()=>r})}keyof(){return oBe(No.objectKeys(this.shape))}}od.create=(t,s)=>new od({shape:()=>t,unknownKeys:"strip",catchall:X1.create(),typeName:vi.ZodObject,...Hi(s)});od.strictCreate=(t,s)=>new od({shape:()=>t,unknownKeys:"strict",catchall:X1.create(),typeName:vi.ZodObject,...Hi(s)});od.lazycreate=(t,s)=>new od({shape:t,unknownKeys:"strip",catchall:X1.create(),typeName:vi.ZodObject,...Hi(s)});class Dre extends wo{_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 Fx(i.ctx.common.issues));return Pn(r,{code:Kr.invalid_union,unionErrors:l}),xi}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 h={...r,common:{...r.common,issues:[]},parent:null},f=d._parseSync({data:r.data,path:r.path,parent:h});if(f.status==="valid")return f;f.status==="dirty"&&!o&&(o={result:f,ctx:h}),h.common.issues.length&&l.push(h.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(d=>new Fx(d));return Pn(r,{code:Kr.invalid_union,unionErrors:i}),xi}}get options(){return this._def.options}}Dre.create=(t,s)=>new Dre({options:t,typeName:vi.ZodUnion,...Hi(s)});function Ufe(t,s){const r=Pv(t),n=Pv(s);if(t===s)return{valid:!0,data:t};if(r===Jn.object&&n===Jn.object){const a=No.objectKeys(s),o=No.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const d=Ufe(t[i],s[i]);if(!d.valid)return{valid:!1};l[i]=d.data}return{valid:!0,data:l}}else if(r===Jn.array&&n===Jn.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(L4e(o)||L4e(l))return xi;const i=Ufe(o.value,l.value);return i.valid?((D4e(o)||D4e(l))&&r.dirty(),{status:r.value,value:i.data}):(Pn(n,{code:Kr.invalid_intersection_types}),xi)};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}))}}Ore.create=(t,s,r)=>new Ore({left:t,right:s,typeName:vi.ZodIntersection,...Hi(r)});class nN extends wo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==Jn.array)return Pn(n,{code:Kr.invalid_type,expected:Jn.array,received:n.parsedType}),xi;if(n.data.lengththis._def.items.length&&(Pn(n,{code:Kr.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 Y1(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>op.mergeArray(r,l)):op.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new nN({...this._def,rest:s})}}nN.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new nN({items:t,typeName:vi.ZodTuple,rest:null,...Hi(s)})};class q4e extends wo{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!==Jn.map)return Pn(n,{code:Kr.invalid_type,expected:Jn.map,received:n.parsedType}),xi;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],h)=>({key:a._parse(new Y1(n,i,n.path,[h,"key"])),value:o._parse(new Y1(n,d,n.path,[h,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of l){const h=await d.key,f=await d.value;if(h.status==="aborted"||f.status==="aborted")return xi;(h.status==="dirty"||f.status==="dirty")&&r.dirty(),i.set(h.value,f.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const d of l){const h=d.key,f=d.value;if(h.status==="aborted"||f.status==="aborted")return xi;(h.status==="dirty"||f.status==="dirty")&&r.dirty(),i.set(h.value,f.value)}return{status:r.value,value:i}}}}q4e.create=(t,s,r)=>new q4e({valueType:s,keyType:t,typeName:vi.ZodMap,...Hi(r)});class lP extends wo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==Jn.set)return Pn(n,{code:Kr.invalid_type,expected:Jn.set,received:n.parsedType}),xi;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Pn(n,{code:Kr.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 h=new Set;for(const f of d){if(f.status==="aborted")return xi;f.status==="dirty"&&r.dirty(),h.add(f.value)}return{status:r.value,value:h}}const i=[...n.data.values()].map((d,h)=>o._parse(new Y1(n,d,n.path,h)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(s,r){return new lP({...this._def,minSize:{value:s,message:la.toString(r)}})}max(s,r){return new lP({...this._def,maxSize:{value:s,message:la.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}lP.create=(t,s)=>new lP({valueType:t,minSize:null,maxSize:null,typeName:vi.ZodSet,...Hi(s)});class V4e extends wo{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})}}V4e.create=(t,s)=>new V4e({getter:t,typeName:vi.ZodLazy,...Hi(s)});class qfe extends wo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Pn(r,{received:r.data,code:Kr.invalid_literal,expected:this._def.value}),xi}return{status:"valid",value:s.data}}get value(){return this._def.value}}qfe.create=(t,s)=>new qfe({value:t,typeName:vi.ZodLiteral,...Hi(s)});function oBe(t,s){return new B5({values:t,typeName:vi.ZodEnum,...Hi(s)})}class B5 extends wo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Pn(r,{expected:No.joinValues(n),received:r.parsedType,code:Kr.invalid_type}),xi}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 Pn(r,{received:r.data,code:Kr.invalid_enum_value,options:n}),xi}return nf(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 B5.create(s,{...this._def,...r})}exclude(s,r=this._def){return B5.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}B5.create=oBe;class H4e extends wo{_parse(s){const r=No.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==Jn.string&&n.parsedType!==Jn.number){const a=No.objectValues(r);return Pn(n,{expected:No.joinValues(a),received:n.parsedType,code:Kr.invalid_type}),xi}if(this._cache||(this._cache=new Set(No.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=No.objectValues(r);return Pn(n,{received:n.data,code:Kr.invalid_enum_value,options:a}),xi}return nf(s.data)}get enum(){return this._def.values}}H4e.create=(t,s)=>new H4e({values:t,typeName:vi.ZodNativeEnum,...Hi(s)});class Rre extends wo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==Jn.promise&&r.common.async===!1)return Pn(r,{code:Kr.invalid_type,expected:Jn.promise,received:r.parsedType}),xi;const n=r.parsedType===Jn.promise?r.data:Promise.resolve(r.data);return nf(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Rre.create=(t,s)=>new Rre({type:t,typeName:vi.ZodPromise,...Hi(s)});class $5 extends wo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===vi.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=>{Pn(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 xi;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?xi:d.status==="dirty"||r.value==="dirty"?eE(d.value):d});{if(r.value==="aborted")return xi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?xi:i.status==="dirty"||r.value==="dirty"?eE(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"?xi:(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"?xi:(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(!F5(l))return xi;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=>F5(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):xi);No.assertNever(a)}}$5.create=(t,s,r)=>new $5({schema:t,typeName:vi.ZodEffects,effect:s,...Hi(r)});$5.createWithPreprocess=(t,s,r)=>new $5({schema:s,effect:{type:"preprocess",transform:t},typeName:vi.ZodEffects,...Hi(r)});class O1 extends wo{_parse(s){return this._getType(s)===Jn.undefined?nf(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}O1.create=(t,s)=>new O1({innerType:t,typeName:vi.ZodOptional,...Hi(s)});class U5 extends wo{_parse(s){return this._getType(s)===Jn.null?nf(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}U5.create=(t,s)=>new U5({innerType:t,typeName:vi.ZodNullable,...Hi(s)});class Vfe extends wo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===Jn.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Vfe.create=(t,s)=>new Vfe({innerType:t,typeName:vi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Hi(s)});class Hfe extends wo{_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 Pre(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Fx(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Fx(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Hfe.create=(t,s)=>new Hfe({innerType:t,typeName:vi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Hi(s)});class W4e extends wo{_parse(s){if(this._getType(s)!==Jn.nan){const n=this._getOrReturnCtx(s);return Pn(n,{code:Kr.invalid_type,expected:Jn.nan,received:n.parsedType}),xi}return{status:"valid",value:s.data}}}W4e.create=t=>new W4e({typeName:vi.ZodNaN,...Hi(t)});class bvt extends wo{_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 n1e extends wo{_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"?xi:o.status==="dirty"?(r.dirty(),eE(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"?xi: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 n1e({in:s,out:r,typeName:vi.ZodPipeline})}}class Wfe extends wo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(F5(a)&&(a.value=Object.freeze(a.value)),a);return Pre(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Wfe.create=(t,s)=>new Wfe({innerType:t,typeName:vi.ZodReadonly,...Hi(s)});var vi;(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"})(vi||(vi={}));const Uo=c1.create,nI=z5.create,wvt=$fe.create;X1.create;Px.create;const u_=od.create;Dre.create;Ore.create;nN.create;const q5=qfe.create,lBe=B5.create;Rre.create;O1.create;U5.create;function jvt(){const s=pm().pathname.slice(1);return T.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(kvt,{slug:s})}function kvt({slug:t}){return e.jsx(Cvt,{slug:t})}const Nvt=u_({first_name:Uo().trim().min(1,"First name is required").max(50),last_name:Uo().trim().max(50).optional(),email:Uo().trim().email("Please enter a valid email").max(255).optional().or(q5("")),phone:Uo().trim().max(20).optional().or(q5(""))}),Svt=[{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 Cvt({slug:t}){var D;const{data:s,isLoading:r,error:n}=L7e(t),a=D7e(),[o,l]=T.useState("welcome"),[i,d]=T.useState({first_name:"",last_name:"",email:"",phone:""}),[h,f]=T.useState(!1),[g,v]=T.useState(!1),[_,j]=T.useState(""),w=L=>{if(!L)return"";const[B,$]=L.split(":"),V=parseInt(B),W=V>=12?"PM":"AM";return`${V>12?V-12:V||12}:${$} ${W}`},k=()=>{j("");const L=Nvt.safeParse(i);if(!L.success){j(L.error.issues[0].message);return}if(!i.email&&!i.phone){j("Please provide either an email or phone number");return}l("intent")},M=async L=>{try{await a.mutateAsync({open_house_id:s.id,first_name:i.first_name.trim(),last_name:i.last_name.trim()||void 0,email:i.email.trim()||void 0,phone:i.phone.trim()||void 0,visitor_intent:L,wants_market_updates:h,has_agent:g}),l("done")}catch{j("Something went wrong. Please try again.")}};if(r)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(n||!s)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(Zn,{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 S=s.profiles,E=((D=S==null?void 0:S.name)==null?void 0:D.split(" ").map(L=>L[0]).join("").slice(0,2))||"?";return e.jsxs(e.Fragment,{children:[e.jsxs(Ih,{children:[e.jsxs("title",{children:["Open House | ",s.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(_a,{src:(S==null?void 0:S.avatar_url)||"",alt:(S==null?void 0:S.name)||""}),e.jsx(gn,{className:"bg-white/10 text-white text-lg",children:E})]}),e.jsx("p",{className:"text-white/60 text-sm",children:S==null?void 0:S.name}),(S==null?void 0:S.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:S.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[s.photo_url&&e.jsxs("div",{className:"relative w-full h-48 overflow-hidden",children:[e.jsx("img",{src:s.photo_url,alt:s.property_address,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/60 to-transparent"})]}),e.jsx("div",{className:`${s.photo_url?"px-6 py-4":"px-6 py-5"} bg-gradient-to-r from-slate-800 to-slate-700`,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:e.jsx(Zn,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:s.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[s.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gi,{className:"h-3 w-3"}),s.city,s.state?`, ${s.state}`:""," ",s.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),Bs(new Date(s.event_date+"T00:00:00"),"MMM d, yyyy")]}),s.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ca,{className:"h-3 w-3"}),w(s.start_time),s.end_time?` – ${w(s.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[o==="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:s.agent_greeting||"Please sign in below."})]}),e.jsxs(Y,{onClick:()=>l("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(qi,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),o==="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:()=>l("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(bi,{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(je,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Be,{value:i.first_name,onChange:L=>d(B=>({...B,first_name:L.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Be,{value:i.last_name,onChange:L=>d(B=>({...B,last_name:L.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Be,{type:"email",value:i.email,onChange:L=>d(B=>({...B,email:L.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Be,{type:"tel",value:i.phone,onChange:L=>d(B=>({...B,phone:L.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:h,onChange:L=>f(L.target.checked),className:"rounded border-slate-300"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-1",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:g?"Yes":"No"}),e.jsx(ln,{checked:g,onCheckedChange:v})]})]}),_&&e.jsx("p",{className:"text-red-500 text-sm",children:_}),e.jsxs(Y,{onClick:k,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(qi,{className:"h-5 w-5 ml-2"})]})]}),o==="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:()=>l("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(bi,{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:Svt.map(L=>e.jsxs("button",{onClick:()=>M(L.value),disabled:a.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:L.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:L.label})]},L.value))}),_&&e.jsx("p",{className:"text-red-500 text-sm text-center",children:_})]}),o==="done"&&e.jsx(Mvt,{firstName:i.first_name,agentName:S==null?void 0:S.name,agentCardSlug:s.auto_forward_to_card?s.agent_card_slug:null,disclosurePdfUrl:s.auto_forward_to_card?null:s.disclosure_pdf_url})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function Mvt({firstName:t,agentName:s,agentCardSlug:r,disclosurePdfUrl:n}){const[a,o]=T.useState(5),[l,i]=T.useState(!1);return T.useEffect(()=>{if(!r||l)return;const d=setInterval(()=>{o(h=>h<=1?(clearInterval(d),window.location.href=`https://cards.relevelup.com/${r}`,0):h-1)},1e3);return()=>clearInterval(d)},[r,l]),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(oi,{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, ",t,". Enjoy the open house!"]})]}),s&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:s})]}),r&&!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-400 animate-pulse",children:["Redirecting to ",s?`${s}'s`:"your agent's"," card in ",a,"s…"]}),e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-slate-500 underline hover:text-slate-700",children:"Stay on this page"})]}),n&&e.jsxs("div",{className:"pt-2 space-y-2",children:[e.jsx("p",{className:"text-sm text-slate-600 font-medium",children:"Seller's Disclosures"}),e.jsxs("div",{className:"flex gap-2 justify-center",children:[e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-700 text-sm font-medium transition-colors",children:[e.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),"View"]}),e.jsxs("a",{href:n,download:!0,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-xl bg-slate-900 hover:bg-slate-800 text-white text-sm font-medium transition-colors",children:[e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Download"]})]})]})]})}function Tvt({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(Zn,{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(Gi,{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(Ha,{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(zr,{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(Gl,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function Avt({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(qi,{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 G4e(t){const s=t.split(/[-/T]/);return new Date(Number(s[0]),Number(s[1])-1,Number(s[2]))}function Pvt(t,s){const r=Bs(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 Lvt(t,s){const r=Bs(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 Dvt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:M4,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:On,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Zn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:xn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,d,h)=>{const f=G4e(d);if(h==="google")window.open(Pvt(i,f),"_blank");else{const g=Lvt(i,f),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:h,color:f})=>{const g=G4e(d),v=Ix(g)&&!Sd(g),_=Sd(g),j=!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 ${f}`,children:e.jsx(h,{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:[Bs(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:"✓"}),j&&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(N1,{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 Ovt({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 Z.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(Yn,{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(Vi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function Rvt({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(Hp,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(dg,{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:Bs(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 Fvt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var j,w;const[l,i]=T.useState({first_name:((j=t.client_name)==null?void 0:j.split(" ")[0])||"",last_name:((w=t.client_name)==null?void 0:w.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[d,h]=T.useState({}),[f,g]=T.useState(!1),v=Wt({mutationFn:async()=>{const{error:k}=await Z.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:f&&l.spouse_first_name||null,spouse_last_name:f&&l.spouse_last_name||null,spouse_email:f&&l.spouse_email||null,spouse_phone:f&&l.spouse_phone||null});if(k)throw k},onSuccess:o}),_=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(Gi,{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:k=>{k.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(je,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(Be,{required:!0,value:l.first_name,onChange:k=>i(M=>({...M,first_name:k.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Be,{value:l.last_name,onChange:k=>i(M=>({...M,last_name:k.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Be,{type:"email",value:l.email,onChange:k=>i(M=>({...M,email:k.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Be,{type:"tel",value:l.phone,onChange:k=>i(M=>({...M,phone:k.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["email","phone","text"].map(k=>e.jsx("button",{type:"button",onClick:()=>i(M=>({...M,preferred_contact_method:k})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===k?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:k.charAt(0).toUpperCase()+k.slice(1)},k))})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(k=>e.jsx("button",{type:"button",onClick:()=>i(M=>({...M,client_role:k})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===k?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:k.charAt(0).toUpperCase()+k.slice(1)},k))})]}),n.map(k=>e.jsxs("div",{children:[e.jsxs(je,{className:"text-xs text-slate-600",children:[k.question_text," ",k.is_required&&"*"]}),k.field_type==="text"&&e.jsx(Be,{required:k.is_required,value:d[k.id]||"",onChange:M=>h(S=>({...S,[k.id]:M.target.value})),className:"mt-1 rounded-xl"}),k.field_type==="textarea"&&e.jsx("textarea",{required:k.is_required,value:d[k.id]||"",onChange:M=>h(S=>({...S,[k.id]:M.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"}),k.field_type==="dropdown"&&e.jsxs("select",{required:k.is_required,value:d[k.id]||"",onChange:M=>h(S=>({...S,[k.id]:M.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..."}),(k.options||[]).map(M=>e.jsx("option",{value:M,children:M},M))]}),k.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(M=>e.jsx("button",{type:"button",onClick:()=>h(S=>({...S,[k.id]:M})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[k.id]===M?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:M},M))})]},k.id)),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:k=>i(M=>({...M,notes:k.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(!f),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:f?"− Remove spouse/partner":"+ Add spouse/partner"}),f&&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(je,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(Be,{value:l.spouse_first_name,onChange:k=>i(M=>({...M,spouse_first_name:k.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Be,{value:l.spouse_last_name,onChange:k=>i(M=>({...M,spouse_last_name:k.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Be,{type:"email",value:l.spouse_email,onChange:k=>i(M=>({...M,spouse_email:k.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Be,{type:"tel",value:l.spouse_phone,onChange:k=>i(M=>({...M,spouse_phone:k.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(Y,{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 zvt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function Bvt(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 $vt={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. 🎉"}},cBe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function dBe(t){return cBe.map(s=>{if(s==="Active")return{key:"Active",label:zvt(t),description:Bvt(t)};const r=$vt[s];return{key:s,label:r.label,description:r.description}})}function Uvt(t){if(!t)return 0;const s=cBe.indexOf(t);return s>=0?s:0}function uBe({slug:t}){var G,J;const[s,r]=T.useState(!1),[n]=T.useState(()=>{const ne=`portal_fp_${t}`;let ie=localStorage.getItem(ne);return ie||(ie=localStorage.getItem("portal_fp"),ie?localStorage.setItem(ne,ie):(ie=crypto.randomUUID(),localStorage.setItem(ne,ie),localStorage.setItem("portal_fp",ie))),ie});T.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:a,isLoading:o,error:l}=zt({queryKey:["client-portal-public",t],queryFn:async()=>{const{data:ne,error:ie}=await Z.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(ie)throw ie;return ne}}),i=(G=a==null?void 0:a.deal_pipeline)==null?void 0:G.owner_user_id,{data:d}=zt({queryKey:["portal-stages",i],queryFn:async()=>{const{data:ne,error:ie}=await Z.from("deal_pipeline_stages").select("*").eq("owner_user_id",i).order("sort_order",{ascending:!0});if(ie)throw ie;return ne},enabled:!!i}),{data:h}=zt({queryKey:["portal-agent",i],queryFn:async()=>{const{data:ne,error:ie}=await Z.from("profiles").select("id, name, avatar_url, phone, email").eq("id",i).single();if(ie)throw ie;return ne},enabled:!!i}),f=a==null?void 0:a.id,{data:g}=zt({queryKey:["portal-updates-public",f],queryFn:async()=>{const{data:ne,error:ie}=await Z.from("portal_updates").select("*").eq("portal_id",f).order("created_at",{ascending:!1});if(ie)throw ie;return ne},enabled:!!f}),v=(J=a==null?void 0:a.deal_pipeline)==null?void 0:J.id,{data:_}=zt({queryKey:["portal-documents",v],queryFn:async()=>{const{data:ne,error:ie}=await Z.from("deal_files").select("*").eq("deal_id",v).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(ie)throw ie;return ne},enabled:!!v}),{data:j,isLoading:w}=zt({queryKey:["portal-onboarding-check",f,n],queryFn:async()=>{const{data:ne,error:ie}=await Z.from("portal_onboarding_submissions").select("id").eq("portal_id",f).eq("device_fingerprint",n).maybeSingle();if(ie)throw ie;return ne},enabled:!!f&&!!(a!=null&&a.require_onboarding)}),{data:k}=zt({queryKey:["portal-custom-questions-public",i],queryFn:async()=>{const{data:ne,error:ie}=await Z.from("portal_custom_questions").select("*").eq("owner_user_id",i).eq("is_active",!0).order("sort_order",{ascending:!0});if(ie)throw ie;return ne},enabled:!!i&&!!(a!=null&&a.require_onboarding)}),M=!!j||s||!(a!=null&&a.require_onboarding);if(o||a!=null&&a.require_onboarding&&w)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(ys,{className:"h-48 w-full rounded-2xl"}),e.jsx(ys,{className:"h-10 w-48 mx-auto"}),e.jsx(ys,{className:"h-32 w-full rounded-2xl"}),e.jsx(ys,{className:"h-24 w-full rounded-2xl"})]})});if(l||!a)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."})]})});const S=a,E=S==null?void 0:S.deal_pipeline,D=E==null?void 0:E.deal_pipeline_stages,L=D==null?void 0:D.is_won_stage,B=E==null?void 0:E.deal_type,$=dBe(B),V=Uvt(D==null?void 0:D.name),W=$[V];return g==null||g.find(ne=>!ne.is_stage_change),M?e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white pb-12",children:[e.jsx(Tvt,{dealData:E,agentProfile:h,welcomeMessage:a.welcome_message,isWon:L}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[e.jsx(Evt,{targetCloseDate:E==null?void 0:E.target_close_date,actualCloseDate:E==null?void 0:E.actual_close_date,clientName:a.client_name}),e.jsx(Avt,{journeyStages:$,currentIndex:V}),W&&e.jsx(Ivt,{currentStage:W,nextStepText:a.next_step_text,nextStepVideoUrl:a.next_step_video_url}),e.jsx(Dvt,{targetCloseDate:E==null?void 0:E.target_close_date,contractDate:E==null?void 0:E.contract_date,inspectionDate:a.inspection_date,appraisalDate:a.appraisal_date,actualCloseDate:E==null?void 0:E.actual_close_date}),_&&_.length>0&&e.jsx(Ovt,{documents:_}),g&&g.length>0&&e.jsx(Rvt,{updates:g}),L&&a.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!"}),a.review_url&&e.jsx("a",{href:a.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 ⭐"})]}),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(Bu,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),h&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:h.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]}):e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:e.jsx(Fvt,{portal:a,dealData:E,agentProfile:h,customQuestions:k||[],deviceFingerprint:n,onComplete:()=>r(!0)})})}function qvt(){const s=pm().pathname.slice(1);return T.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(uBe,{slug:s})}const Gfe="levelup_affiliate_ref",Vvt=30,Hvt=()=>{const[t]=Oc();T.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(Gfe,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},Wvt=()=>{try{const t=localStorage.getItem(Gfe);if(!t)return null;const s=JSON.parse(t),r=Vvt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(Gfe),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},Fre="/assets/levelup-logo-header-_ZX7DvlA.png",Gvt="/assets/scale-your-team-ku4MPatU.png";function Kvt({open:t,onOpenChange:s}){return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ls,{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(Ya,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ps,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(en,{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 qd={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"]}},Zvt=[{icon:Om,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:hd,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:xn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Gl,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Yn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:oo,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],Yvt=[{icon:br,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:Sn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Ha,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Gm,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Gi,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Sc,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ti,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Ax,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],Xvt=[{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."}],Qvt=()=>{const{user:t,loading:s}=Ys(),r=Yr(),[n]=Oc();T.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",V=window.location.pathname==="/";if($&&V){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=T.useState(null),[l,i]=T.useState(null),[d,h]=T.useState(!1),[f,g]=T.useState(""),[v,_]=T.useState(""),[j,w]=T.useState(""),[k,M]=T.useState(!1),[S,E]=T.useState(!1),D=($,V=!1)=>{i({tier:$,skipTrial:V}),h(!0)};Hvt(),T.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",V=location.pathname.startsWith("/public/");!s&&t&&!$&&!V&&r("/dashboard")},[t,s,r,location.pathname]),T.useEffect(()=>{n.get("canceled")==="true"&&be.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const L=async($,V=!1)=>{if(!f){be.error("Please enter your email address");return}if(!v.trim()){be.error("Please enter your full name");return}M(!0),o($+(V?"_direct":""));const W=Wvt();try{const{data:G,error:J}=await Z.functions.invoke("create-checkout",{body:{tier:$,email:f,name:v.trim(),couponCode:j.trim()||void 0,skipTrial:V,referralCode:W}});if(J)throw J;if(G!=null&&G.url)window.open(G.url,"_blank","noopener,noreferrer"),be.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(G){console.error("Checkout error:",G),be.error(G.message||"Failed to start checkout. Please try again.")}finally{M(!1),o(null),h(!1),i(null)}},B=()=>{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:Fre,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(Y,{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(Y,{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(Y,{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(Y,{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(qi,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(Y,{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(Y,{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(Ya,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(Y,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(Wo,{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:Zvt.map(($,V)=>e.jsxs(Oe,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Ht,{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(Gt,{className:"text-xl font-sans",children:$.title})]}),e.jsx($e,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:$.description})})]},V))})]})}),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(Sn,{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:Yvt.map(($,V)=>e.jsxs(Oe,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Ht,{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(Gt,{className:"text-lg font-semibold text-white",children:$.title})]}),e.jsx($e,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:$.description})})]},V))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(Y,{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(qi,{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(Ya,{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(($,V)=>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(ma,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:$})]},V))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(Y,{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(Ri,{className:"ml-2 w-5 h-5"})]}),e.jsxs(Y,{size:"lg",variant:"outline",onClick:()=>E(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(xn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:Gvt,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:Xvt.map(($,V)=>e.jsx(Oe,{className:"bg-muted/30 border-0",children:e.jsxs($e,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(W=>e.jsx(qn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},W))}),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})]})]})},V))})]})}),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(Y,{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:()=>D("individual_agent"),children:["Start Free Trial",e.jsx(qi,{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(Oe,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Ht,{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(Wo,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Gt,{className:"text-xl font-sans",children:qd.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:qd.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qd.individual_agent.period})]}),e.jsx(Tr,{className:"text-base mt-2",children:qd.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(ca,{className:"w-4 h-4"}),qd.individual_agent.trial]})]}),e.jsx($e,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qd.individual_agent.features.map(($,V)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},V))})}),e.jsxs(rI,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(Y,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>D("individual_agent"),children:"Start Free Trial"}),e.jsx(Y,{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:()=>D("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Oe,{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(Ht,{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(Ya,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-xl font-sans",children:qd.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:qd.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:qd.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qd.brokerage_under_25.period})]}),e.jsx(Tr,{className:"text-base mt-2",children:qd.brokerage_under_25.description})]}),e.jsx($e,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qd.brokerage_under_25.features.map(($,V)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},V))})}),e.jsx(rI,{className:"pt-4",children:e.jsx(Y,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>D("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Oe,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Ht,{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(Ya,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-xl font-sans",children:qd.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:qd.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:qd.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:qd.brokerage_over_25.period})]}),e.jsx(Tr,{className:"text-base mt-2",children:qd.brokerage_over_25.description})]}),e.jsx($e,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:qd.brokerage_over_25.features.map(($,V)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},V))})}),e.jsx(rI,{className:"pt-4",children:e.jsx(Y,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>D("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(Y,{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(qi,{className:"ml-2 w-5 h-5"})]}),e.jsx(Y,{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:Fre,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(Kvt,{open:S,onOpenChange:E}),e.jsx(js,{open:d,onOpenChange:h,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(en,{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(je,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Be,{id:"dialog-name",type:"text",placeholder:"John Smith",value:v,onChange:$=>_($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(je,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Be,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:f,onChange:$=>g($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(je,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(Be,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:j,onChange:$=>w($.target.value),className:"mt-1"})]})]}),e.jsx(Y,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:B,disabled:k,children:k?"Loading...":"Continue to Checkout"})]})})]})},Jvt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Ih,{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"})]})]})]})]})})]}),e1t=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Ih,{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"})]})]})]})]})})]}),t1t=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Ih,{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"})]})]})]})]})})]}),s1t=u_({email:Uo().email("Invalid email address"),password:Uo().min(6,"Password must be at least 6 characters")}),r1t=()=>{const{signIn:t,user:s}=Ys(),r=Yr(),[n,a]=T.useState(!1),[o,l]=T.useState({}),[i,d]=T.useState(""),[h,f]=T.useState(!1),[g,v]=T.useState(!1);T.useEffect(()=>{s&&r("/dashboard")},[s,r]);const _=async w=>{w.preventDefault(),l({}),a(!0);const k=new FormData(w.currentTarget),M=k.get("email"),S=k.get("password");try{s1t.parse({email:M,password:S}),await t(M,S)}catch(E){if(E instanceof Fx){const D={};E.errors.forEach(L=>{L.path[0]&&(D[L.path[0]]=L.message)}),l(D)}}finally{a(!1)}},j=async()=>{if(!i){be.error("Please enter your email address");return}f(!0);try{const{error:w}=await Z.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(w)throw w;be.success("Password reset email sent! Check your inbox."),v(!1),d("")}catch(w){be.error(w.message||"Failed to send reset email")}finally{f(!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(bo,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(bi,{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:Rze,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Oe,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Ht,{className:"space-y-1 text-center pb-4",children:[e.jsx(Gt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(Tr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx($e,{children:e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(Be,{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(je,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(Be,{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(Y,{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(js,{open:g,onOpenChange:v,children:[e.jsx(Fi,{asChild:!0,children:e.jsx(Y,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(_s,{className:"bg-white",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(en,{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(je,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(Be,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:w=>d(w.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(Y,{onClick:j,className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white",disabled:h,children:h?"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(bo,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},n1t=()=>{const[t]=Oc(),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(Oe,{className:"max-w-lg w-full",children:[e.jsxs(Ht,{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(yi,{className:"w-10 h-10 text-green-500"})}),e.jsx(Gt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(Tr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs($e,{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(zr,{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."})})]})]})})},hBe=t=>{const[s,r]=T.useState(null),[n,a]=T.useState(!0);return T.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await Z.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:d}=Z.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 Z.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=Z.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},mBe=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await Z.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=Z.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},a1t=t=>{const[s,r]=T.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return T.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await Z.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(),h=new Date(a.subscription_end_date).getTime(),f=Math.ceil((h-d)/(1e3*60*60*24)),g=f<=0;r({isTrial:!0,isExpired:g,expiresAt:a.subscription_end_date,daysLeft:g?0:f,loading:!1})}else if(i){const d=new Date().getTime(),h=new Date(a.trial_expires_at).getTime(),f=Math.ceil((h-d)/(1e3*60*60*24)),g=f<=0;r({isTrial:!0,isExpired:g,expiresAt:a.trial_expires_at,daysLeft:g?0:f,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},pBe=()=>{const{data:t,isLoading:s}=zt({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await Z.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")}},K4e="community_last_seen_post_at";function i1t(){const{user:t}=Ys(),s=pm(),[r,n]=T.useState(0),[a,o]=T.useState(null);T.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${K4e}_${t.id}`);o(i)},[t]),T.useEffect(()=>{if(!t)return;(async()=>{let d=Z.from("community_posts").select("id",{count:"exact",head:!0});a&&(d=d.gt("created_at",a));const{data:h}=await Z.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:f,error:g}=await d;!g&&f!==null&&n(f)})()},[t,a]),T.useEffect(()=>{if(!t)return;const i=Z.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async d=>{const h=d.new;if(h.user_id===t.id)return;const f=s.pathname==="/community";f||n(j=>j+1);const{data:g}=await Z.from("profiles").select("name").eq("id",h.user_id).single(),v=(g==null?void 0:g.name)||"Someone",_=h.content.length>50?h.content.substring(0,50)+"...":h.content;f||be("New Community Post",{description:`${v}: ${_}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{Z.removeChannel(i)}},[t,s.pathname]);const l=T.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${K4e}_${t.id}`,i),o(i),n(0)},[t]);return T.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function o1t(){const{isAdmin:t}=Ys(),{data:s=0}=zt({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await Z.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 h_=()=>{const{user:t}=Ys();return zt({queryKey:["user-team",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.from("team_members").select("id, team_id, role").eq("user_id",t.id).maybeSingle();if(console.log("[useUserTeam] membership query:",{userId:t.id,membership:s,error:r}),r)throw r;if(!s)return null;const{data:n,error:a}=await Z.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})},z6=Eie,a1e=Hve,l1t=Iie,fBe=T.forwardRef(({className:t,...s},r)=>e.jsx(B3,{className:$t("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}));fBe.displayName=B3.displayName;const c1t=M3("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"}}),q3=T.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(l1t,{children:[e.jsx(fBe,{}),e.jsxs($3,{ref:a,className:$t(c1t({side:t}),s),...n,children:[r,e.jsxs(Pie,{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(Xr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));q3.displayName=$3.displayName;const B6=({className:t,...s})=>e.jsx("div",{className:$t("flex flex-col space-y-2 text-center sm:text-left",t),...s});B6.displayName="SheetHeader";const $6=T.forwardRef(({className:t,...s},r)=>e.jsx(L6,{ref:r,className:$t("text-lg font-semibold text-foreground",t),...s}));$6.displayName=L6.displayName;const d1t=T.forwardRef(({className:t,...s},r)=>e.jsx(D6,{ref:r,className:$t("text-sm text-muted-foreground",t),...s}));d1t.displayName=D6.displayName;function u1t(t,s){return T.useReducer((r,n)=>s[r][n]??r,t)}var i1e="ScrollArea",[gBe]=Dc(i1e),[h1t,af]=gBe(i1e),xBe=T.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=T.useState(null),[h,f]=T.useState(null),[g,v]=T.useState(null),[_,j]=T.useState(null),[w,k]=T.useState(null),[M,S]=T.useState(0),[E,D]=T.useState(0),[L,B]=T.useState(!1),[$,V]=T.useState(!1),W=ba(s,J=>d(J)),G=jN(a);return e.jsx(h1t,{scope:r,type:n,dir:G,scrollHideDelay:o,scrollArea:i,viewport:h,onViewportChange:f,content:g,onContentChange:v,scrollbarX:_,onScrollbarXChange:j,scrollbarXEnabled:L,onScrollbarXEnabledChange:B,scrollbarY:w,onScrollbarYChange:k,scrollbarYEnabled:$,onScrollbarYEnabledChange:V,onCornerWidthChange:S,onCornerHeightChange:D,children:e.jsx(Qr.div,{dir:G,...l,ref:W,style:{position:"relative","--radix-scroll-area-corner-width":M+"px","--radix-scroll-area-corner-height":E+"px",...t.style}})})});xBe.displayName=i1e;var yBe="ScrollAreaViewport",vBe=T.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=af(yBe,r),i=T.useRef(null),d=ba(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})})]})});vBe.displayName=yBe;var Kx="ScrollAreaScrollbar",o1e=T.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=af(Kx,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return T.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(m1t,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(p1t,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(_Be,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(l1e,{...n,ref:s}):null});o1e.displayName=Kx;var m1t=T.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=af(Kx,t.__scopeScrollArea),[o,l]=T.useState(!1);return T.useEffect(()=>{const i=a.scrollArea;let d=0;if(i){const h=()=>{window.clearTimeout(d),l(!0)},f=()=>{d=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",h),i.addEventListener("pointerleave",f),()=>{window.clearTimeout(d),i.removeEventListener("pointerenter",h),i.removeEventListener("pointerleave",f)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(Qc,{present:r||o,children:e.jsx(_Be,{"data-state":o?"visible":"hidden",...n,ref:s})})}),p1t=T.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=af(Kx,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Kie(()=>d("SCROLL_END"),100),[i,d]=u1t("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 T.useEffect(()=>{if(i==="idle"){const h=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(h)}},[i,a.scrollHideDelay,d]),T.useEffect(()=>{const h=a.viewport,f=o?"scrollLeft":"scrollTop";if(h){let g=h[f];const v=()=>{const _=h[f];g!==_&&(d("SCROLL"),l()),g=_};return h.addEventListener("scroll",v),()=>h.removeEventListener("scroll",v)}},[a.viewport,o,d,l]),e.jsx(Qc,{present:r||i!=="hidden",children:e.jsx(l1e,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:kr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:kr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),_Be=T.forwardRef((t,s)=>{const r=af(Kx,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=T.useState(!1),i=t.orientation==="horizontal",d=Kie(()=>{if(r.viewport){const h=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=af(Kx,t.__scopeScrollArea),o=T.useRef(null),l=T.useRef(0),[i,d]=T.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),h=NBe(i.viewport,i.content),f={...n,sizes:i,onSizesChange:d,hasThumb:h>0&&h<1,onThumbChange:v=>o.current=v,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:v=>l.current=v};function g(v,_){return _1t(v,l.current,i,_)}return r==="horizontal"?e.jsx(f1t,{...f,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollLeft,_=Z4e(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(g1t,{...f,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollTop,_=Z4e(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}),f1t=T.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=af(Kx,t.__scopeScrollArea),[l,i]=T.useState(),d=T.useRef(null),h=ba(s,d,o.onScrollbarXChange);return T.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(wBe,{"data-orientation":"horizontal",...a,ref:h,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":Gie(r)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.x),onDragScroll:f=>t.onDragScroll(f.x),onWheelScroll:(f,g)=>{if(o.viewport){const v=o.viewport.scrollLeft+f.deltaX;t.onWheelScroll(v),CBe(v,g)&&f.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Bre(l.paddingLeft),paddingEnd:Bre(l.paddingRight)}})}})}),g1t=T.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=af(Kx,t.__scopeScrollArea),[l,i]=T.useState(),d=T.useRef(null),h=ba(s,d,o.onScrollbarYChange);return T.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(wBe,{"data-orientation":"vertical",...a,ref:h,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":Gie(r)+"px",...t.style},onThumbPointerDown:f=>t.onThumbPointerDown(f.y),onDragScroll:f=>t.onDragScroll(f.y),onWheelScroll:(f,g)=>{if(o.viewport){const v=o.viewport.scrollTop+f.deltaY;t.onWheelScroll(v),CBe(v,g)&&f.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Bre(l.paddingTop),paddingEnd:Bre(l.paddingBottom)}})}})}),[x1t,bBe]=gBe(Kx),wBe=T.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:h,onWheelScroll:f,onResize:g,...v}=t,_=af(Kx,r),[j,w]=T.useState(null),k=ba(s,W=>w(W)),M=T.useRef(null),S=T.useRef(""),E=_.viewport,D=n.content-n.viewport,L=Ac(f),B=Ac(d),$=Kie(g,10);function V(W){if(M.current){const G=W.clientX-M.current.left,J=W.clientY-M.current.top;h({x:G,y:J})}}return T.useEffect(()=>{const W=G=>{const J=G.target;(j==null?void 0:j.contains(J))&&L(G,D)};return document.addEventListener("wheel",W,{passive:!1}),()=>document.removeEventListener("wheel",W,{passive:!1})},[E,j,D,L]),T.useEffect(B,[n,B]),V5(j,$),V5(_.content,$),e.jsx(x1t,{scope:r,scrollbar:j,hasThumb:a,onThumbChange:Ac(o),onThumbPointerUp:Ac(l),onThumbPositionChange:B,onThumbPointerDown:Ac(i),children:e.jsx(Qr.div,{...v,ref:k,style:{position:"absolute",...v.style},onPointerDown:kr(t.onPointerDown,W=>{W.button===0&&(W.target.setPointerCapture(W.pointerId),M.current=j.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),V(W))}),onPointerMove:kr(t.onPointerMove,V),onPointerUp:kr(t.onPointerUp,W=>{const G=W.target;G.hasPointerCapture(W.pointerId)&&G.releasePointerCapture(W.pointerId),document.body.style.webkitUserSelect=S.current,_.viewport&&(_.viewport.style.scrollBehavior=""),M.current=null})})})}),zre="ScrollAreaThumb",jBe=T.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=bBe(zre,t.__scopeScrollArea);return e.jsx(Qc,{present:r||a.hasThumb,children:e.jsx(y1t,{ref:s,...n})})}),y1t=T.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=af(zre,r),l=bBe(zre,r),{onThumbPositionChange:i}=l,d=ba(s,g=>l.onThumbChange(g)),h=T.useRef(void 0),f=Kie(()=>{h.current&&(h.current(),h.current=void 0)},100);return T.useEffect(()=>{const g=o.viewport;if(g){const v=()=>{if(f(),!h.current){const _=b1t(g,i);h.current=_,i()}};return i(),g.addEventListener("scroll",v),()=>g.removeEventListener("scroll",v)}},[o.viewport,f,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:kr(t.onPointerDownCapture,g=>{const _=g.target.getBoundingClientRect(),j=g.clientX-_.left,w=g.clientY-_.top;l.onThumbPointerDown({x:j,y:w})}),onPointerUp:kr(t.onPointerUp,l.onThumbPointerUp)})});jBe.displayName=zre;var c1e="ScrollAreaCorner",kBe=T.forwardRef((t,s)=>{const r=af(c1e,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(v1t,{...t,ref:s}):null});kBe.displayName=c1e;var v1t=T.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=af(c1e,r),[o,l]=T.useState(0),[i,d]=T.useState(0),h=!!(o&&i);return V5(a.scrollbarX,()=>{var g;const f=((g=a.scrollbarX)==null?void 0:g.offsetHeight)||0;a.onCornerHeightChange(f),d(f)}),V5(a.scrollbarY,()=>{var g;const f=((g=a.scrollbarY)==null?void 0:g.offsetWidth)||0;a.onCornerWidthChange(f),l(f)}),h?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 Bre(t){return t?parseInt(t,10):0}function NBe(t,s){const r=t/s;return isNaN(r)?0:r}function Gie(t){const s=NBe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function _1t(t,s,r,n="ltr"){const a=Gie(r),o=a/2,l=s||o,i=a-l,d=r.scrollbar.paddingStart+l,h=r.scrollbar.size-r.scrollbar.paddingEnd-i,f=r.content-r.viewport,g=n==="ltr"?[0,f]:[f*-1,0];return SBe([d,h],g)(t)}function Z4e(t,s,r="ltr"){const n=Gie(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],h=iP(t,d);return SBe([0,l],[0,i])(h)}function SBe(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 CBe(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 Kie(t,s){const r=Ac(t),n=T.useRef(0);return T.useEffect(()=>()=>window.clearTimeout(n.current),[]),T.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function V5(t,s){const r=Ac(s);Pc(()=>{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 MBe=xBe,w1t=vBe,j1t=kBe;const po=T.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(MBe,{ref:n,className:$t("relative overflow-hidden",t),...r,children:[e.jsx(w1t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Zie,{}),e.jsx(j1t,{})]}));po.displayName=MBe.displayName;const Zie=T.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(o1e,{ref:n,orientation:s,className:$t("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(jBe,{className:"relative flex-1 rounded-full bg-border"})}));Zie.displayName=o1e.displayName;var Yie="Collapsible",[k1t]=Dc(Yie),[N1t,d1e]=k1t(Yie),TBe=T.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[d,h]=Sh({prop:n,defaultProp:a??!1,onChange:l,caller:Yie});return e.jsx(N1t,{scope:r,disabled:o,contentId:Id(),open:d,onOpenToggle:T.useCallback(()=>h(f=>!f),[h]),children:e.jsx(Qr.div,{"data-state":h1e(d),"data-disabled":o?"":void 0,...i,ref:s})})});TBe.displayName=Yie;var ABe="CollapsibleTrigger",EBe=T.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=d1e(ABe,r);return e.jsx(Qr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":h1e(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:kr(t.onClick,a.onOpenToggle)})});EBe.displayName=ABe;var u1e="CollapsibleContent",IBe=T.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=d1e(u1e,t.__scopeCollapsible);return e.jsx(Qc,{present:r||a.open,children:({present:o})=>e.jsx(S1t,{...n,ref:s,present:o})})});IBe.displayName=u1e;var S1t=T.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=d1e(u1e,r),[i,d]=T.useState(n),h=T.useRef(null),f=ba(s,h),g=T.useRef(0),v=g.current,_=T.useRef(0),j=_.current,w=l.open||i,k=T.useRef(w),M=T.useRef(void 0);return T.useEffect(()=>{const S=requestAnimationFrame(()=>k.current=!1);return()=>cancelAnimationFrame(S)},[]),Pc(()=>{const S=h.current;if(S){M.current=M.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const E=S.getBoundingClientRect();g.current=E.height,_.current=E.width,k.current||(S.style.transitionDuration=M.current.transitionDuration,S.style.animationName=M.current.animationName),d(n)}},[l.open,n]),e.jsx(Qr.div,{"data-state":h1e(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!w,...o,ref:f,style:{"--radix-collapsible-content-height":v?`${v}px`:void 0,"--radix-collapsible-content-width":j?`${j}px`:void 0,...t.style},children:w&&a})});function h1e(t){return t?"open":"closed"}var C1t=TBe;const Dk=C1t,Ok=EBe,Rk=IBe,M1t="/assets/levelup-logo-Eif24dqY.png",T1t="/assets/levelup-logo-icon-C-7iromj.png",A1t="/assets/levelup-logo-mobile-B9skSjUG.png";var U6=t=>t.type==="checkbox",Kj=t=>t instanceof Date,mh=t=>t==null;const PBe=t=>typeof t=="object";var Xc=t=>!mh(t)&&!Array.isArray(t)&&PBe(t)&&!Kj(t),LBe=t=>Xc(t)&&t.target?U6(t.target)?t.target.checked:t.target.value:t,E1t=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,DBe=(t,s)=>t.has(E1t(s)),I1t=t=>{const s=t.constructor&&t.constructor.prototype;return Xc(s)&&s.hasOwnProperty("isPrototypeOf")},m1e=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function bd(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(!(m1e&&(t instanceof Blob||n))&&(r||Xc(t)))if(s=r?[]:{},!r&&!I1t(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=bd(t[a]));else return t;return s}var Xie=t=>/^\w*$/.test(t),qc=t=>t===void 0,p1e=t=>Array.isArray(t)?t.filter(Boolean):[],f1e=t=>p1e(t.replace(/["|']|\]/g,"").split(/\.|\[/)),mn=(t,s,r)=>{if(!s||!Xc(t))return r;const n=(Xie(s)?[s]:f1e(s)).reduce((a,o)=>mh(a)?a:a[o],t);return qc(n)||n===t?qc(t[s])?r:t[s]:n},Dm=t=>typeof t=="boolean",Bo=(t,s,r)=>{let n=-1;const a=Xie(s)?[s]:f1e(s),o=a.length,l=o-1;for(;++nlt.useContext(g1e),P1t=t=>{const{children:s,...r}=t;return lt.createElement(g1e.Provider,{value:r},s)};var OBe=(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]!==eg.all&&(s._proxyFormState[l]=!n||eg.all),r&&(r[l]=!0),t[l]}});return a};const x1e=typeof window<"u"?lt.useLayoutEffect:lt.useEffect;function L1t(t){const s=Qie(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=lt.useState(r._formState),d=lt.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return x1e(()=>r._subscribe({name:a,formState:d.current,exact:o,callback:h=>{!n&&i({...r._formState,...h})}}),[a,n,o]),lt.useEffect(()=>{d.current.isValid&&r._setValid(!0)},[r]),lt.useMemo(()=>OBe(l,r,d.current,!1),[l,r])}var xx=t=>typeof t=="string",RBe=(t,s,r,n,a)=>xx(t)?(n&&s.watch.add(t),mn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),mn(r,o))):(n&&(s.watchAll=!0),r),Kfe=t=>mh(t)||!PBe(t);function zy(t,s,r=new WeakSet){if(Kfe(t)||Kfe(s))return t===s;if(Kj(t)&&Kj(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(Kj(l)&&Kj(i)||Xc(l)&&Xc(i)||Array.isArray(l)&&Array.isArray(i)?!zy(l,i,r):l!==i)return!1}}return!0}function D1t(t){const s=Qie(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},d=lt.useRef(a),h=lt.useRef(i),f=lt.useRef(void 0);h.current=i;const g=lt.useMemo(()=>r._getWatch(n,d.current),[r,n]),[v,_]=lt.useState(h.current?h.current(g):g);return x1e(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:j=>{if(!o){const w=RBe(n,r._names,j.values||r._formValues,!1,d.current);if(h.current){const k=h.current(w);zy(k,f.current)||(_(k),f.current=k)}else _(w)}}}),[r,o,n,l]),lt.useEffect(()=>r._removeUnmounted()),v}function O1t(t){const s=Qie(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=DBe(a._names.array,r),d=lt.useMemo(()=>mn(a._formValues,r,mn(a._defaultValues,r,l)),[a,r,l]),h=D1t({control:a,name:r,defaultValue:d,exact:!0}),f=L1t({control:a,name:r,exact:!0}),g=lt.useRef(t),v=lt.useRef(a.register(r,{...t.rules,value:h,...Dm(t.disabled)?{disabled:t.disabled}:{}}));g.current=t;const _=lt.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!mn(f.errors,r)},isDirty:{enumerable:!0,get:()=>!!mn(f.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!mn(f.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!mn(f.validatingFields,r)},error:{enumerable:!0,get:()=>mn(f.errors,r)}}),[f,r]),j=lt.useCallback(S=>v.current.onChange({target:{value:LBe(S),name:r},type:$re.CHANGE}),[r]),w=lt.useCallback(()=>v.current.onBlur({target:{value:mn(a._formValues,r),name:r},type:$re.BLUR}),[r,a._formValues]),k=lt.useCallback(S=>{const E=mn(a._fields,r);E&&S&&(E._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:D=>S.setCustomValidity(D),reportValidity:()=>S.reportValidity()})},[a._fields,r]),M=lt.useMemo(()=>({name:r,value:h,...Dm(n)||f.disabled?{disabled:f.disabled||n}:{},onChange:j,onBlur:w,ref:k}),[r,n,f.disabled,j,w,k,h]);return lt.useEffect(()=>{const S=a._options.shouldUnregister||o;a.register(r,{...g.current.rules,...Dm(g.current.disabled)?{disabled:g.current.disabled}:{}});const E=(D,L)=>{const B=mn(a._fields,D);B&&B._f&&(B._f.mount=L)};if(E(r,!0),S){const D=bd(mn(a._options.defaultValues,r));Bo(a._defaultValues,r,D),qc(mn(a._formValues,r))&&Bo(a._formValues,r,D)}return!i&&a.register(r),()=>{(i?S&&!a._state.action:S)?a.unregister(r):E(r,!1)}},[r,a,i,o]),lt.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),lt.useMemo(()=>({field:M,formState:f,fieldState:_}),[M,f,_])}const R1t=t=>t.render(O1t(t));var FBe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},aI=t=>Array.isArray(t)?t:[t],Y4e=()=>{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=[]}}},Wh=t=>Xc(t)&&!Object.keys(t).length,y1e=t=>t.type==="file",tg=t=>typeof t=="function",Ure=t=>{if(!m1e)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},zBe=t=>t.type==="select-multiple",v1e=t=>t.type==="radio",F1t=t=>v1e(t)||U6(t),Xue=t=>Ure(t)&&t.isConnected;function z1t(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(tg(t[s]))return!0;return!1};function qre(t,s={}){const r=Array.isArray(t);if(Xc(t)||r)for(const n in t)Array.isArray(t[n])||Xc(t[n])&&!BBe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},qre(t[n],s[n])):mh(t[n])||(s[n]=!0);return s}function $Be(t,s,r){const n=Array.isArray(t);if(Xc(t)||n)for(const a in t)Array.isArray(t[a])||Xc(t[a])&&!BBe(t[a])?qc(s)||Kfe(r[a])?r[a]=Array.isArray(t[a])?qre(t[a],[]):{...qre(t[a])}:$Be(t[a],mh(s)?{}:s[a],r[a]):r[a]=!zy(t[a],s[a]);return r}var jA=(t,s)=>$Be(t,s,qre(s));const X4e={value:!1,isValid:!1},Q4e={value:!0,isValid:!0};var UBe=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&&!qc(t[0].attributes.value)?qc(t[0].value)||t[0].value===""?Q4e:{value:t[0].value,isValid:!0}:Q4e:X4e}return X4e},qBe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>qc(t)?t:s?t===""?NaN:t&&+t:r&&xx(t)?new Date(t):n?n(t):t;const J4e={isValid:!1,value:null};var VBe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,J4e):J4e;function e5e(t){const s=t.ref;return y1e(s)?s.files:v1e(s)?VBe(t.refs).value:zBe(s)?[...s.selectedOptions].map(({value:r})=>r):U6(s)?UBe(t.refs).value:qBe(qc(s.value)?t.ref.value:s.value,t)}var $1t=(t,s,r,n)=>{const a={};for(const o of t){const l=mn(s,o);l&&Bo(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},Vre=t=>t instanceof RegExp,kA=t=>qc(t)?t:Vre(t)?t.source:Xc(t)?Vre(t.value)?t.value.source:t.value:t,t5e=t=>({isOnSubmit:!t||t===eg.onSubmit,isOnBlur:t===eg.onBlur,isOnChange:t===eg.onChange,isOnAll:t===eg.all,isOnTouch:t===eg.onTouched});const s5e="AsyncFunction";var U1t=t=>!!t&&!!t.validate&&!!(tg(t.validate)&&t.validate.constructor.name===s5e||Xc(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===s5e)),q1t=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),r5e=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const iI=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=mn(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(iI(i,s))break}else if(Xc(i)&&iI(i,s))break}}};function n5e(t,s,r){const n=mn(t,r);if(n||Xie(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=mn(s,o),i=mn(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 V1t=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return Wh(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||eg.all))},H1t=(t,s,r)=>!t||!s||t===s||aI(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),W1t=(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,G1t=(t,s)=>!p1e(mn(t,s)).length&&nd(t,s),K1t=(t,s,r)=>{const n=aI(mn(t,r));return Bo(n,"root",s[r]),Bo(t,r,n),t},kse=t=>xx(t);function a5e(t,s,r="validate"){if(kse(t)||Array.isArray(t)&&t.every(kse)||Dm(t)&&!t)return{type:r,message:kse(t)?t:"",ref:s}}var SC=t=>Xc(t)&&!Vre(t)?t:{value:t,message:""},i5e=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:h,minLength:f,min:g,max:v,pattern:_,validate:j,name:w,valueAsNumber:k,mount:M}=t._f,S=mn(r,w);if(!M||s.has(w))return{};const E=i?i[0]:l,D=ne=>{a&&E.reportValidity&&(E.setCustomValidity(Dm(ne)?"":ne||""),E.reportValidity())},L={},B=v1e(l),$=U6(l),V=B||$,W=(k||y1e(l))&&qc(l.value)&&qc(S)||Ure(l)&&l.value===""||S===""||Array.isArray(S)&&!S.length,G=FBe.bind(null,w,n,L),J=(ne,ie,ee,de=by.maxLength,oe=by.minLength)=>{const ue=ne?ie:ee;L[w]={type:ne?de:oe,message:ue,ref:l,...G(ne?de:oe,ue)}};if(o?!Array.isArray(S)||!S.length:d&&(!V&&(W||mh(S))||Dm(S)&&!S||$&&!UBe(i).isValid||B&&!VBe(i).isValid)){const{value:ne,message:ie}=kse(d)?{value:!!d,message:d}:SC(d);if(ne&&(L[w]={type:by.required,message:ie,ref:E,...G(by.required,ie)},!n))return D(ie),L}if(!W&&(!mh(g)||!mh(v))){let ne,ie;const ee=SC(v),de=SC(g);if(!mh(S)&&!isNaN(S)){const oe=l.valueAsNumber||S&&+S;mh(ee.value)||(ne=oe>ee.value),mh(de.value)||(ie=oenew Date(new Date().toDateString()+" "+Te),ce=l.type=="time",ge=l.type=="week";xx(ee.value)&&S&&(ne=ce?ue(S)>ue(ee.value):ge?S>ee.value:oe>new Date(ee.value)),xx(de.value)&&S&&(ie=ce?ue(S)+ne.value,de=!mh(ie.value)&&S.length<+ie.value;if((ee||de)&&(J(ee,ne.message,ie.message),!n))return D(L[w].message),L}if(_&&!W&&xx(S)){const{value:ne,message:ie}=SC(_);if(Vre(ne)&&!S.match(ne)&&(L[w]={type:by.pattern,message:ie,ref:l,...G(by.pattern,ie)},!n))return D(ie),L}if(j){if(tg(j)){const ne=await j(S,r),ie=a5e(ne,E);if(ie&&(L[w]={...ie,...G(by.validate,ie.message)},!n))return D(ie.message),L}else if(Xc(j)){let ne={};for(const ie in j){if(!Wh(ne)&&!n)break;const ee=a5e(await j[ie](S,r),E,ie);ee&&(ne={...ee,...G(ie,ee.message)},D(ee.message),n&&(L[w]=ne))}if(!Wh(ne)&&(L[w]={ref:E,...ne},!n))return L}}return D(!0),L};const Z1t={mode:eg.onSubmit,reValidateMode:eg.onChange,shouldFocusError:!0};function Y1t(t={}){let s={...Z1t,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:tg(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=Xc(s.defaultValues)||Xc(s.values)?bd(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:bd(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,h=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let g={...f};const v={array:Y4e(),state:Y4e()},_=s.criteriaMode===eg.all,j=Fe=>it=>{clearTimeout(h),h=setTimeout(Fe,it)},w=async Fe=>{if(!s.disabled&&(f.isValid||g.isValid||Fe)){const it=s.resolver?Wh((await $()).errors):await W(n,!0);it!==r.isValid&&v.state.next({isValid:it})}},k=(Fe,it)=>{!s.disabled&&(f.isValidating||f.validatingFields||g.isValidating||g.validatingFields)&&((Fe||Array.from(i.mount)).forEach(dt=>{dt&&(it?Bo(r.validatingFields,dt,it):nd(r.validatingFields,dt))}),v.state.next({validatingFields:r.validatingFields,isValidating:!Wh(r.validatingFields)}))},M=(Fe,it=[],dt,tt,ut=!0,xt=!0)=>{if(tt&&dt&&!s.disabled){if(l.action=!0,xt&&Array.isArray(mn(n,Fe))){const _t=dt(mn(n,Fe),tt.argA,tt.argB);ut&&Bo(n,Fe,_t)}if(xt&&Array.isArray(mn(r.errors,Fe))){const _t=dt(mn(r.errors,Fe),tt.argA,tt.argB);ut&&Bo(r.errors,Fe,_t),G1t(r.errors,Fe)}if((f.touchedFields||g.touchedFields)&&xt&&Array.isArray(mn(r.touchedFields,Fe))){const _t=dt(mn(r.touchedFields,Fe),tt.argA,tt.argB);ut&&Bo(r.touchedFields,Fe,_t)}(f.dirtyFields||g.dirtyFields)&&(r.dirtyFields=jA(a,o)),v.state.next({name:Fe,isDirty:J(Fe,it),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Bo(o,Fe,it)},S=(Fe,it)=>{Bo(r.errors,Fe,it),v.state.next({errors:r.errors})},E=Fe=>{r.errors=Fe,v.state.next({errors:r.errors,isValid:!1})},D=(Fe,it,dt,tt)=>{const ut=mn(n,Fe);if(ut){const xt=mn(o,Fe,qc(dt)?mn(a,Fe):dt);qc(xt)||tt&&tt.defaultChecked||it?Bo(o,Fe,it?xt:e5e(ut._f)):ee(Fe,xt),l.mount&&w()}},L=(Fe,it,dt,tt,ut)=>{let xt=!1,_t=!1;const qe={name:Fe};if(!s.disabled){if(!dt||tt){(f.isDirty||g.isDirty)&&(_t=r.isDirty,r.isDirty=qe.isDirty=J(),xt=_t!==qe.isDirty);const Lt=zy(mn(a,Fe),it);_t=!!mn(r.dirtyFields,Fe),Lt?nd(r.dirtyFields,Fe):Bo(r.dirtyFields,Fe,!0),qe.dirtyFields=r.dirtyFields,xt=xt||(f.dirtyFields||g.dirtyFields)&&_t!==!Lt}if(dt){const Lt=mn(r.touchedFields,Fe);Lt||(Bo(r.touchedFields,Fe,dt),qe.touchedFields=r.touchedFields,xt=xt||(f.touchedFields||g.touchedFields)&&Lt!==dt)}xt&&ut&&v.state.next(qe)}return xt?qe:{}},B=(Fe,it,dt,tt)=>{const ut=mn(r.errors,Fe),xt=(f.isValid||g.isValid)&&Dm(it)&&r.isValid!==it;if(s.delayError&&dt?(d=j(()=>S(Fe,dt)),d(s.delayError)):(clearTimeout(h),d=null,dt?Bo(r.errors,Fe,dt):nd(r.errors,Fe)),(dt?!zy(ut,dt):ut)||!Wh(tt)||xt){const _t={...tt,...xt&&Dm(it)?{isValid:it}:{},errors:r.errors,name:Fe};r={...r,..._t},v.state.next(_t)}},$=async Fe=>{k(Fe,!0);const it=await s.resolver(o,s.context,$1t(Fe||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return k(Fe),it},V=async Fe=>{const{errors:it}=await $(Fe);if(Fe)for(const dt of Fe){const tt=mn(it,dt);tt?Bo(r.errors,dt,tt):nd(r.errors,dt)}else r.errors=it;return it},W=async(Fe,it,dt={valid:!0})=>{for(const tt in Fe){const ut=Fe[tt];if(ut){const{_f:xt,..._t}=ut;if(xt){const qe=i.array.has(xt.name),Lt=ut._f&&U1t(ut._f);Lt&&f.validatingFields&&k([tt],!0);const Rt=await i5e(ut,i.disabled,o,_,s.shouldUseNativeValidation&&!it,qe);if(Lt&&f.validatingFields&&k([tt]),Rt[xt.name]&&(dt.valid=!1,it))break;!it&&(mn(Rt,xt.name)?qe?K1t(r.errors,Rt,xt.name):Bo(r.errors,xt.name,Rt[xt.name]):nd(r.errors,xt.name))}!Wh(_t)&&await W(_t,it,dt)}}return dt.valid},G=()=>{for(const Fe of i.unMount){const it=mn(n,Fe);it&&(it._f.refs?it._f.refs.every(dt=>!Xue(dt)):!Xue(it._f.ref))&&He(Fe)}i.unMount=new Set},J=(Fe,it)=>!s.disabled&&(Fe&&it&&Bo(o,Fe,it),!zy(Te(),a)),ne=(Fe,it,dt)=>RBe(Fe,i,{...l.mount?o:qc(it)?a:xx(Fe)?{[Fe]:it}:it},dt,it),ie=Fe=>p1e(mn(l.mount?o:a,Fe,s.shouldUnregister?mn(a,Fe,[]):[])),ee=(Fe,it,dt={})=>{const tt=mn(n,Fe);let ut=it;if(tt){const xt=tt._f;xt&&(!xt.disabled&&Bo(o,Fe,qBe(it,xt)),ut=Ure(xt.ref)&&mh(it)?"":it,zBe(xt.ref)?[...xt.ref.options].forEach(_t=>_t.selected=ut.includes(_t.value)):xt.refs?U6(xt.ref)?xt.refs.forEach(_t=>{(!_t.defaultChecked||!_t.disabled)&&(Array.isArray(ut)?_t.checked=!!ut.find(qe=>qe===_t.value):_t.checked=ut===_t.value||!!ut)}):xt.refs.forEach(_t=>_t.checked=_t.value===ut):y1e(xt.ref)?xt.ref.value="":(xt.ref.value=ut,xt.ref.type||v.state.next({name:Fe,values:bd(o)})))}(dt.shouldDirty||dt.shouldTouch)&&L(Fe,ut,dt.shouldTouch,dt.shouldDirty,!0),dt.shouldValidate&&ge(Fe)},de=(Fe,it,dt)=>{for(const tt in it){if(!it.hasOwnProperty(tt))return;const ut=it[tt],xt=Fe+"."+tt,_t=mn(n,xt);(i.array.has(Fe)||Xc(ut)||_t&&!_t._f)&&!Kj(ut)?de(xt,ut,dt):ee(xt,ut,dt)}},oe=(Fe,it,dt={})=>{const tt=mn(n,Fe),ut=i.array.has(Fe),xt=bd(it);Bo(o,Fe,xt),ut?(v.array.next({name:Fe,values:bd(o)}),(f.isDirty||f.dirtyFields||g.isDirty||g.dirtyFields)&&dt.shouldDirty&&v.state.next({name:Fe,dirtyFields:jA(a,o),isDirty:J(Fe,xt)})):tt&&!tt._f&&!mh(xt)?de(Fe,xt,dt):ee(Fe,xt,dt),r5e(Fe,i)&&v.state.next({...r,name:Fe}),v.state.next({name:l.mount?Fe:void 0,values:bd(o)})},ue=async Fe=>{l.mount=!0;const it=Fe.target;let dt=it.name,tt=!0;const ut=mn(n,dt),xt=Lt=>{tt=Number.isNaN(Lt)||Kj(Lt)&&isNaN(Lt.getTime())||zy(Lt,mn(o,dt,Lt))},_t=t5e(s.mode),qe=t5e(s.reValidateMode);if(ut){let Lt,Rt;const Kt=it.type?e5e(ut._f):LBe(Fe),Xt=Fe.type===$re.BLUR||Fe.type===$re.FOCUS_OUT,ss=!q1t(ut._f)&&!s.resolver&&!mn(r.errors,dt)&&!ut._f.deps||W1t(Xt,mn(r.touchedFields,dt),r.isSubmitted,qe,_t),fs=r5e(dt,i,Xt);Bo(o,dt,Kt),Xt?(ut._f.onBlur&&ut._f.onBlur(Fe),d&&d(0)):ut._f.onChange&&ut._f.onChange(Fe);const fr=L(dt,Kt,Xt),yt=!Wh(fr)||fs;if(!Xt&&v.state.next({name:dt,type:Fe.type,values:bd(o)}),ss)return(f.isValid||g.isValid)&&(s.mode==="onBlur"?Xt&&w():Xt||w()),yt&&v.state.next({name:dt,...fs?{}:fr});if(!Xt&&fs&&v.state.next({...r}),s.resolver){const{errors:bs}=await $([dt]);if(xt(Kt),tt){const gr=n5e(r.errors,n,dt),Br=n5e(bs,n,gr.name||dt);Lt=Br.error,dt=Br.name,Rt=Wh(bs)}}else k([dt],!0),Lt=(await i5e(ut,i.disabled,o,_,s.shouldUseNativeValidation))[dt],k([dt]),xt(Kt),tt&&(Lt?Rt=!1:(f.isValid||g.isValid)&&(Rt=await W(n,!0)));tt&&(ut._f.deps&&ge(ut._f.deps),B(dt,Rt,Lt,fr))}},ce=(Fe,it)=>{if(mn(r.errors,it)&&Fe.focus)return Fe.focus(),1},ge=async(Fe,it={})=>{let dt,tt;const ut=aI(Fe);if(s.resolver){const xt=await V(qc(Fe)?Fe:ut);dt=Wh(xt),tt=Fe?!ut.some(_t=>mn(xt,_t)):dt}else Fe?(tt=(await Promise.all(ut.map(async xt=>{const _t=mn(n,xt);return await W(_t&&_t._f?{[xt]:_t}:_t)}))).every(Boolean),!(!tt&&!r.isValid)&&w()):tt=dt=await W(n);return v.state.next({...!xx(Fe)||(f.isValid||g.isValid)&&dt!==r.isValid?{}:{name:Fe},...s.resolver||!Fe?{isValid:dt}:{},errors:r.errors}),it.shouldFocus&&!tt&&iI(n,ce,Fe?ut:i.mount),tt},Te=Fe=>{const it={...l.mount?o:a};return qc(Fe)?it:xx(Fe)?mn(it,Fe):Fe.map(dt=>mn(it,dt))},ve=(Fe,it)=>({invalid:!!mn((it||r).errors,Fe),isDirty:!!mn((it||r).dirtyFields,Fe),error:mn((it||r).errors,Fe),isValidating:!!mn(r.validatingFields,Fe),isTouched:!!mn((it||r).touchedFields,Fe)}),ye=Fe=>{Fe&&aI(Fe).forEach(it=>nd(r.errors,it)),v.state.next({errors:Fe?r.errors:{}})},Se=(Fe,it,dt)=>{const tt=(mn(n,Fe,{_f:{}})._f||{}).ref,ut=mn(r.errors,Fe)||{},{ref:xt,message:_t,type:qe,...Lt}=ut;Bo(r.errors,Fe,{...Lt,...it,ref:tt}),v.state.next({name:Fe,errors:r.errors,isValid:!1}),dt&&dt.shouldFocus&&tt&&tt.focus&&tt.focus()},Ke=(Fe,it)=>tg(Fe)?v.state.subscribe({next:dt=>"values"in dt&&Fe(ne(void 0,it),dt)}):ne(Fe,it,!0),Ae=Fe=>v.state.subscribe({next:it=>{H1t(Fe.name,it.name,Fe.exact)&&V1t(it,Fe.formState||f,Ye,Fe.reRenderRoot)&&Fe.callback({values:{...o},...r,...it,defaultValues:a})}}).unsubscribe,Ee=Fe=>(l.mount=!0,g={...g,...Fe.formState},Ae({...Fe,formState:g})),He=(Fe,it={})=>{for(const dt of Fe?aI(Fe):i.mount)i.mount.delete(dt),i.array.delete(dt),it.keepValue||(nd(n,dt),nd(o,dt)),!it.keepError&&nd(r.errors,dt),!it.keepDirty&&nd(r.dirtyFields,dt),!it.keepTouched&&nd(r.touchedFields,dt),!it.keepIsValidating&&nd(r.validatingFields,dt),!s.shouldUnregister&&!it.keepDefaultValue&&nd(a,dt);v.state.next({values:bd(o)}),v.state.next({...r,...it.keepDirty?{isDirty:J()}:{}}),!it.keepIsValid&&w()},Ue=({disabled:Fe,name:it})=>{(Dm(Fe)&&l.mount||Fe||i.disabled.has(it))&&(Fe?i.disabled.add(it):i.disabled.delete(it))},De=(Fe,it={})=>{let dt=mn(n,Fe);const tt=Dm(it.disabled)||Dm(s.disabled);return Bo(n,Fe,{...dt||{},_f:{...dt&&dt._f?dt._f:{ref:{name:Fe}},name:Fe,mount:!0,...it}}),i.mount.add(Fe),dt?Ue({disabled:Dm(it.disabled)?it.disabled:s.disabled,name:Fe}):D(Fe,!0,it.value),{...tt?{disabled:it.disabled||s.disabled}:{},...s.progressive?{required:!!it.required,min:kA(it.min),max:kA(it.max),minLength:kA(it.minLength),maxLength:kA(it.maxLength),pattern:kA(it.pattern)}:{},name:Fe,onChange:ue,onBlur:ue,ref:ut=>{if(ut){De(Fe,it),dt=mn(n,Fe);const xt=qc(ut.value)&&ut.querySelectorAll&&ut.querySelectorAll("input,select,textarea")[0]||ut,_t=F1t(xt),qe=dt._f.refs||[];if(_t?qe.find(Lt=>Lt===xt):xt===dt._f.ref)return;Bo(n,Fe,{_f:{...dt._f,..._t?{refs:[...qe.filter(Xue),xt,...Array.isArray(mn(a,Fe))?[{}]:[]],ref:{type:xt.type,name:Fe}}:{ref:xt}}}),D(Fe,!1,void 0,xt)}else dt=mn(n,Fe,{}),dt._f&&(dt._f.mount=!1),(s.shouldUnregister||it.shouldUnregister)&&!(DBe(i.array,Fe)&&l.action)&&i.unMount.add(Fe)}}},Ge=()=>s.shouldFocusError&&iI(n,ce,i.mount),wt=Fe=>{Dm(Fe)&&(v.state.next({disabled:Fe}),iI(n,(it,dt)=>{const tt=mn(n,dt);tt&&(it.disabled=tt._f.disabled||Fe,Array.isArray(tt._f.refs)&&tt._f.refs.forEach(ut=>{ut.disabled=tt._f.disabled||Fe}))},0,!1))},Ie=(Fe,it)=>async dt=>{let tt;dt&&(dt.preventDefault&&dt.preventDefault(),dt.persist&&dt.persist());let ut=bd(o);if(v.state.next({isSubmitting:!0}),s.resolver){const{errors:xt,values:_t}=await $();r.errors=xt,ut=bd(_t)}else await W(n);if(i.disabled.size)for(const xt of i.disabled)nd(ut,xt);if(nd(r.errors,"root"),Wh(r.errors)){v.state.next({errors:{}});try{await Fe(ut,dt)}catch(xt){tt=xt}}else it&&await it({...r.errors},dt),Ge(),setTimeout(Ge);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Wh(r.errors)&&!tt,submitCount:r.submitCount+1,errors:r.errors}),tt)throw tt},st=(Fe,it={})=>{mn(n,Fe)&&(qc(it.defaultValue)?oe(Fe,bd(mn(a,Fe))):(oe(Fe,it.defaultValue),Bo(a,Fe,bd(it.defaultValue))),it.keepTouched||nd(r.touchedFields,Fe),it.keepDirty||(nd(r.dirtyFields,Fe),r.isDirty=it.defaultValue?J(Fe,bd(mn(a,Fe))):J()),it.keepError||(nd(r.errors,Fe),f.isValid&&w()),v.state.next({...r}))},he=(Fe,it={})=>{const dt=Fe?bd(Fe):a,tt=bd(dt),ut=Wh(Fe),xt=ut?a:tt;if(it.keepDefaultValues||(a=dt),!it.keepValues){if(it.keepDirtyValues){const _t=new Set([...i.mount,...Object.keys(jA(a,o))]);for(const qe of Array.from(_t))mn(r.dirtyFields,qe)?Bo(xt,qe,mn(o,qe)):oe(qe,mn(xt,qe))}else{if(m1e&&qc(Fe))for(const _t of i.mount){const qe=mn(n,_t);if(qe&&qe._f){const Lt=Array.isArray(qe._f.refs)?qe._f.refs[0]:qe._f.ref;if(Ure(Lt)){const Rt=Lt.closest("form");if(Rt){Rt.reset();break}}}}if(it.keepFieldsRef)for(const _t of i.mount)oe(_t,mn(xt,_t));else n={}}o=s.shouldUnregister?it.keepDefaultValues?bd(a):{}:bd(xt),v.array.next({values:{...xt}}),v.state.next({values:{...xt}})}i={mount:it.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!f.isValid||!!it.keepIsValid||!!it.keepDirtyValues,l.watch=!!s.shouldUnregister,v.state.next({submitCount:it.keepSubmitCount?r.submitCount:0,isDirty:ut?!1:it.keepDirty?r.isDirty:!!(it.keepDefaultValues&&!zy(Fe,a)),isSubmitted:it.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:ut?{}:it.keepDirtyValues?it.keepDefaultValues&&o?jA(a,o):r.dirtyFields:it.keepDefaultValues&&Fe?jA(a,Fe):it.keepDirty?r.dirtyFields:{},touchedFields:it.keepTouched?r.touchedFields:{},errors:it.keepErrors?r.errors:{},isSubmitSuccessful:it.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},We=(Fe,it)=>he(tg(Fe)?Fe(o):Fe,it),et=(Fe,it={})=>{const dt=mn(n,Fe),tt=dt&&dt._f;if(tt){const ut=tt.refs?tt.refs[0]:tt.ref;ut.focus&&(ut.focus(),it.shouldSelect&&tg(ut.select)&&ut.select())}},Ye=Fe=>{r={...r,...Fe}},at={control:{register:De,unregister:He,getFieldState:ve,handleSubmit:Ie,setError:Se,_subscribe:Ae,_runSchema:$,_focusError:Ge,_getWatch:ne,_getDirty:J,_setValid:w,_setFieldArray:M,_setDisabledField:Ue,_setErrors:E,_getFieldArray:ie,_reset:he,_resetDefaultValues:()=>tg(s.defaultValues)&&s.defaultValues().then(Fe=>{We(Fe,s.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:G,_disableForm:wt,_subjects:v,_proxyFormState:f,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(Fe){l=Fe},get _defaultValues(){return a},get _names(){return i},set _names(Fe){i=Fe},get _formState(){return r},get _options(){return s},set _options(Fe){s={...s,...Fe}}},subscribe:Ee,trigger:ge,register:De,handleSubmit:Ie,watch:Ke,setValue:oe,getValues:Te,reset:We,resetField:st,clearErrors:ye,unregister:He,setError:Se,setFocus:et,getFieldState:ve};return{...at,formControl:at}}function Jie(t={}){const s=lt.useRef(void 0),r=lt.useRef(void 0),[n,a]=lt.useState({isDirty:!1,isValidating:!1,isLoading:tg(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:tg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!tg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=Y1t(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,x1e(()=>{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]),lt.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),lt.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),lt.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),lt.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),lt.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),lt.useEffect(()=>{t.values&&!zy(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]),lt.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=OBe(n,o),s.current}const o5e=(t,s,r)=>{if(t&&"reportValidity"in t){const n=mn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},HBe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?o5e(n.ref,r,t):n.refs&&n.refs.forEach(a=>o5e(a,r,t))}},X1t=(t,s)=>{s.shouldUseNativeValidation&&HBe(t,s);const r={};for(const n in t){const a=mn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(Q1t(s.names||Object.keys(t),n)){const l=Object.assign({},mn(r,n));Bo(l,"root",o),Bo(r,n,l)}else Bo(r,n,o)}return r},Q1t=(t,s)=>t.some(r=>r.startsWith(s+"."));var J1t=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(f){return f.errors.forEach(function(g){return t.push(g)})}),s){var d=r[l].types,h=d&&d[n.code];r[l]=FBe(l,s,r,a,h?[].concat(h,n.message):n.message)}t.shift()}return r},eoe=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(h){return o.shouldUseNativeValidation&&HBe({},o),{errors:{},values:r.raw?n:h}})}catch(h){return i(h)}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:X1t(J1t(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const toe=P1t,WBe=T.createContext({}),Jl=({...t})=>e.jsx(WBe.Provider,{value:{name:t.name},children:e.jsx(R1t,{...t})}),soe=()=>{const t=T.useContext(WBe),s=T.useContext(GBe),{getFieldState:r,formState:n}=Qie(),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}},GBe=T.createContext({}),zl=T.forwardRef(({className:t,...s},r)=>{const n=T.useId();return e.jsx(GBe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:$t("space-y-2",t),...s})})});zl.displayName="FormItem";const Bl=T.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=soe();return e.jsx(je,{ref:r,className:$t(n&&"text-destructive",t),htmlFor:a,...s})});Bl.displayName="FormLabel";const $l=T.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=soe();return e.jsx(K0e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});$l.displayName="FormControl";const Nse=T.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=soe();return e.jsx("p",{ref:r,id:n,className:$t("text-sm text-muted-foreground",t),...s})});Nse.displayName="FormDescription";const gh=T.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=soe(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:$t("text-sm font-medium text-destructive",t),...r,children:l}):null});gh.displayName="FormMessage";const Rr=T.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:$t("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}));Rr.displayName="Textarea";const e_t=u_({category:lBe(["general","technology","crm","marketing"]),subject:Uo().min(5,"Subject must be at least 5 characters").max(200),description:Uo().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),t_t={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Zfe({trigger:t}){const[s,r]=T.useState(!1),[n,a]=T.useState(!1),{user:o}=Ys(),l=Jie({resolver:eoe(e_t),defaultValues:{category:"general",subject:"",description:""}}),i=async d=>{if(!o){be.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:h}=await Z.from("support_tickets").insert({user_id:o.id,category:d.category,subject:d.subject,description:d.description});if(h)throw h;try{await Z.functions.invoke("support-ticket-notify",{body:{category:t_t[d.category],subject:d.subject}})}catch(f){console.log("Notification send attempted:",f)}be.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(h){console.error("Error submitting ticket:",h),be.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(js,{open:s,onOpenChange:r,children:[e.jsx(Fi,{asChild:!0,children:t||e.jsxs(Y,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(IE,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(_s,{className:"sm:max-w-[500px]",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Need Help?"}),e.jsx(en,{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(Ha,{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(toe,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Jl,{control:l.control,name:"category",render:({field:d})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Category"}),e.jsxs(er,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx($l,{children:e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select a category"})})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"general",children:"General Support"}),e.jsx(Et,{value:"technology",children:"Technology Support"}),e.jsx(Et,{value:"crm",children:"CRM Support"}),e.jsx(Et,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(gh,{})]})}),e.jsx(Jl,{control:l.control,name:"subject",render:({field:d})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Subject"}),e.jsx($l,{children:e.jsx(Be,{placeholder:"Brief description of your issue",...d})}),e.jsx(gh,{})]})}),e.jsx(Jl,{control:l.control,name:"description",render:({field:d})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Description"}),e.jsx($l,{children:e.jsx(Rr,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),e.jsx(gh,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const s_t=()=>{const{user:t}=Ys(),s=Yr(),[r,n]=T.useState([]),[a,o]=T.useState(0),[l,i]=T.useState(!1),[d,h]=T.useState(null);T.useEffect(()=>{if(!t)return;const j=`notification_last_read_${t.id}`;let w=d;if(!w){const S=localStorage.getItem(j);S&&(w=S,h(S))}(async()=>{const{data:S,error:E}=await Z.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!E&&S){n(S);const D=w?new Date(w):null,L=S.filter(B=>D?new Date(B.created_at)>D:!0);o(L.length)}})();const M=Z.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},S=>{const E=S.new;n(L=>[E,...L].slice(0,20));const D=w?new Date(w):null;(!D||new Date(E.created_at)>D)&&o(L=>L+1),Notification.permission==="granted"&&new Notification(E.title,{body:E.body,icon:"/favicon.ico"})}).subscribe();return()=>{Z.removeChannel(M)}},[t,d]);const f=j=>{const w=j.toLowerCase();return w.includes("community")||w.includes("post")?Eo:w.includes("academy")||w.includes("video")?Wn:w.includes("template")?hd:w.includes("event")?xn:w.includes("newsletter")?r0:w.includes("brokerage")?Fu:w.includes("swag")||w.includes("social")?oo:w.includes("toolbox")||w.includes("tool")?a0:w.includes("brief")?Sn:Eo},g=j=>{i(!1),j.url&&j.url!=="/"&&s(j.url)},v=()=>{if(!t)return;const j=new Date().toISOString(),w=`notification_last_read_${t.id}`;localStorage.setItem(w,j),h(j),o(0)},_=j=>{i(j),j&&a>0&&v()};return e.jsxs(Hu,{open:l,onOpenChange:_,children:[e.jsx(Wu,{asChild:!0,children:e.jsxs(Y,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(dg,{className:"h-5 w-5"}),a>0&&e.jsx(ct,{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(ju,{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(Y,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:v,children:"Mark all read"})]}),e.jsx(po,{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(j=>{const w=f(j.title);return e.jsxs(Va,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>g(j),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(w,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:j.title}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:j.body}),e.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:_u(new Date(j.created_at),{addSuffix:!0})})]})]},j.id)})})]})]})};var l5e=1,r_t=.9,n_t=.8,a_t=.17,Que=.1,Jue=.999,i_t=.9999,o_t=.99,l_t=/[\\\/_+.#"@\[\(\{&]/,c_t=/[\\\/_+.#"@\[\(\{&]/g,d_t=/[\s-]/,KBe=/[\s-]/g;function Yfe(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?l5e:o_t;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var d=n.charAt(o),h=r.indexOf(d,a),f=0,g,v,_,j;h>=0;)g=Yfe(t,s,r,n,h+1,o+1,l),g>f&&(h===a?g*=l5e:l_t.test(t.charAt(h-1))?(g*=n_t,_=t.slice(a,h-1).match(c_t),_&&a>0&&(g*=Math.pow(Jue,_.length))):d_t.test(t.charAt(h-1))?(g*=r_t,j=t.slice(a,h-1).match(KBe),j&&a>0&&(g*=Math.pow(Jue,j.length))):(g*=a_t,a>0&&(g*=Math.pow(Jue,h-a))),t.charAt(h)!==s.charAt(o)&&(g*=i_t)),(gg&&(g=v*Que)),g>f&&(f=g),h=r.indexOf(d,h+1);return l[i]=f,f}function c5e(t){return t.toLowerCase().replace(KBe," ")}function u_t(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,Yfe(t,s,c5e(t),c5e(s),0,0,{})}var NA='[cmdk-group=""]',ehe='[cmdk-group-items=""]',h_t='[cmdk-group-heading=""]',ZBe='[cmdk-item=""]',d5e=`${ZBe}:not([aria-disabled="true"])`,Xfe="cmdk-item-select",zC="data-value",m_t=(t,s,r)=>u_t(t,s,r),YBe=T.createContext(void 0),q6=()=>T.useContext(YBe),XBe=T.createContext(void 0),_1e=()=>T.useContext(XBe),QBe=T.createContext(void 0),JBe=T.forwardRef((t,s)=>{let r=BC(()=>{var ye,Se;return{search:"",value:(Se=(ye=t.value)!=null?ye:t.defaultValue)!=null?Se:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=BC(()=>new Set),a=BC(()=>new Map),o=BC(()=>new Map),l=BC(()=>new Set),i=e9e(t),{label:d,children:h,value:f,onValueChange:g,filter:v,shouldFilter:_,loop:j,disablePointerSelection:w=!1,vimBindings:k=!0,...M}=t,S=Id(),E=Id(),D=Id(),L=T.useRef(null),B=k_t();aN(()=>{if(f!==void 0){let ye=f.trim();r.current.value=ye,$.emit()}},[f]),aN(()=>{B(6,ie)},[]);let $=T.useMemo(()=>({subscribe:ye=>(l.current.add(ye),()=>l.current.delete(ye)),snapshot:()=>r.current,setState:(ye,Se,Ke)=>{var Ae,Ee,He,Ue;if(!Object.is(r.current[ye],Se)){if(r.current[ye]=Se,ye==="search")ne(),G(),B(1,J);else if(ye==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let De=document.getElementById(D);De?De.focus():(Ae=document.getElementById(S))==null||Ae.focus()}if(B(7,()=>{var De;r.current.selectedItemId=(De=ee())==null?void 0:De.id,$.emit()}),Ke||B(5,ie),((Ee=i.current)==null?void 0:Ee.value)!==void 0){let De=Se??"";(Ue=(He=i.current).onValueChange)==null||Ue.call(He,De);return}}$.emit()}},emit:()=>{l.current.forEach(ye=>ye())}}),[]),V=T.useMemo(()=>({value:(ye,Se,Ke)=>{var Ae;Se!==((Ae=o.current.get(ye))==null?void 0:Ae.value)&&(o.current.set(ye,{value:Se,keywords:Ke}),r.current.filtered.items.set(ye,W(Se,Ke)),B(2,()=>{G(),$.emit()}))},item:(ye,Se)=>(n.current.add(ye),Se&&(a.current.has(Se)?a.current.get(Se).add(ye):a.current.set(Se,new Set([ye]))),B(3,()=>{ne(),G(),r.current.value||J(),$.emit()}),()=>{o.current.delete(ye),n.current.delete(ye),r.current.filtered.items.delete(ye);let Ke=ee();B(4,()=>{ne(),(Ke==null?void 0:Ke.getAttribute("id"))===ye&&J(),$.emit()})}),group:ye=>(a.current.has(ye)||a.current.set(ye,new Set),()=>{o.current.delete(ye),a.current.delete(ye)}),filter:()=>i.current.shouldFilter,label:d||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:D,labelId:E,listInnerRef:L}),[]);function W(ye,Se){var Ke,Ae;let Ee=(Ae=(Ke=i.current)==null?void 0:Ke.filter)!=null?Ae:m_t;return ye?Ee(ye,r.current.search,Se):0}function G(){if(!r.current.search||i.current.shouldFilter===!1)return;let ye=r.current.filtered.items,Se=[];r.current.filtered.groups.forEach(Ae=>{let Ee=a.current.get(Ae),He=0;Ee.forEach(Ue=>{let De=ye.get(Ue);He=Math.max(De,He)}),Se.push([Ae,He])});let Ke=L.current;de().sort((Ae,Ee)=>{var He,Ue;let De=Ae.getAttribute("id"),Ge=Ee.getAttribute("id");return((He=ye.get(Ge))!=null?He:0)-((Ue=ye.get(De))!=null?Ue:0)}).forEach(Ae=>{let Ee=Ae.closest(ehe);Ee?Ee.appendChild(Ae.parentElement===Ee?Ae:Ae.closest(`${ehe} > *`)):Ke.appendChild(Ae.parentElement===Ke?Ae:Ae.closest(`${ehe} > *`))}),Se.sort((Ae,Ee)=>Ee[1]-Ae[1]).forEach(Ae=>{var Ee;let He=(Ee=L.current)==null?void 0:Ee.querySelector(`${NA}[${zC}="${encodeURIComponent(Ae[0])}"]`);He==null||He.parentElement.appendChild(He)})}function J(){let ye=de().find(Ke=>Ke.getAttribute("aria-disabled")!=="true"),Se=ye==null?void 0:ye.getAttribute(zC);$.setState("value",Se||void 0)}function ne(){var ye,Se,Ke,Ae;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Ee=0;for(let He of n.current){let Ue=(Se=(ye=o.current.get(He))==null?void 0:ye.value)!=null?Se:"",De=(Ae=(Ke=o.current.get(He))==null?void 0:Ke.keywords)!=null?Ae:[],Ge=W(Ue,De);r.current.filtered.items.set(He,Ge),Ge>0&&Ee++}for(let[He,Ue]of a.current)for(let De of Ue)if(r.current.filtered.items.get(De)>0){r.current.filtered.groups.add(He);break}r.current.filtered.count=Ee}function ie(){var ye,Se,Ke;let Ae=ee();Ae&&(((ye=Ae.parentElement)==null?void 0:ye.firstChild)===Ae&&((Ke=(Se=Ae.closest(NA))==null?void 0:Se.querySelector(h_t))==null||Ke.scrollIntoView({block:"nearest"})),Ae.scrollIntoView({block:"nearest"}))}function ee(){var ye;return(ye=L.current)==null?void 0:ye.querySelector(`${ZBe}[aria-selected="true"]`)}function de(){var ye;return Array.from(((ye=L.current)==null?void 0:ye.querySelectorAll(d5e))||[])}function oe(ye){let Se=de()[ye];Se&&$.setState("value",Se.getAttribute(zC))}function ue(ye){var Se;let Ke=ee(),Ae=de(),Ee=Ae.findIndex(Ue=>Ue===Ke),He=Ae[Ee+ye];(Se=i.current)!=null&&Se.loop&&(He=Ee+ye<0?Ae[Ae.length-1]:Ee+ye===Ae.length?Ae[0]:Ae[Ee+ye]),He&&$.setState("value",He.getAttribute(zC))}function ce(ye){let Se=ee(),Ke=Se==null?void 0:Se.closest(NA),Ae;for(;Ke&&!Ae;)Ke=ye>0?w_t(Ke,NA):j_t(Ke,NA),Ae=Ke==null?void 0:Ke.querySelector(d5e);Ae?$.setState("value",Ae.getAttribute(zC)):ue(ye)}let ge=()=>oe(de().length-1),Te=ye=>{ye.preventDefault(),ye.metaKey?ge():ye.altKey?ce(1):ue(1)},ve=ye=>{ye.preventDefault(),ye.metaKey?oe(0):ye.altKey?ce(-1):ue(-1)};return T.createElement(Qr.div,{ref:s,tabIndex:-1,...M,"cmdk-root":"",onKeyDown:ye=>{var Se;(Se=M.onKeyDown)==null||Se.call(M,ye);let Ke=ye.nativeEvent.isComposing||ye.keyCode===229;if(!(ye.defaultPrevented||Ke))switch(ye.key){case"n":case"j":{k&&ye.ctrlKey&&Te(ye);break}case"ArrowDown":{Te(ye);break}case"p":case"k":{k&&ye.ctrlKey&&ve(ye);break}case"ArrowUp":{ve(ye);break}case"Home":{ye.preventDefault(),oe(0);break}case"End":{ye.preventDefault(),ge();break}case"Enter":{ye.preventDefault();let Ae=ee();if(Ae){let Ee=new Event(Xfe);Ae.dispatchEvent(Ee)}}}}},T.createElement("label",{"cmdk-label":"",htmlFor:V.inputId,id:V.labelId,style:S_t},d),roe(t,ye=>T.createElement(XBe.Provider,{value:$},T.createElement(YBe.Provider,{value:V},ye))))}),p_t=T.forwardRef((t,s)=>{var r,n;let a=Id(),o=T.useRef(null),l=T.useContext(QBe),i=q6(),d=e9e(t),h=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;aN(()=>{if(!h)return i.item(a,l==null?void 0:l.id)},[h]);let f=t9e(a,o,[t.value,t.children,o],t.keywords),g=_1e(),v=Q1(B=>B.value&&B.value===f.current),_=Q1(B=>h||i.filter()===!1?!0:B.search?B.filtered.items.get(a)>0:!0);T.useEffect(()=>{let B=o.current;if(!(!B||t.disabled))return B.addEventListener(Xfe,j),()=>B.removeEventListener(Xfe,j)},[_,t.onSelect,t.disabled]);function j(){var B,$;w(),($=(B=d.current).onSelect)==null||$.call(B,f.current)}function w(){g.setState("value",f.current,!0)}if(!_)return null;let{disabled:k,value:M,onSelect:S,forceMount:E,keywords:D,...L}=t;return T.createElement(Qr.div,{ref:f0(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!k,"aria-selected":!!v,"data-disabled":!!k,"data-selected":!!v,onPointerMove:k||i.getDisablePointerSelection()?void 0:w,onClick:k?void 0:j},t.children)}),f_t=T.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Id(),i=T.useRef(null),d=T.useRef(null),h=Id(),f=q6(),g=Q1(_=>a||f.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);aN(()=>f.group(l),[]),t9e(l,i,[t.value,t.heading,d]);let v=T.useMemo(()=>({id:l,forceMount:a}),[a]);return T.createElement(Qr.div,{ref:f0(i,s),...o,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},r&&T.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:h},r),roe(t,_=>T.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?h:void 0},T.createElement(QBe.Provider,{value:v},_))))}),g_t=T.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=T.useRef(null),o=Q1(l=>!l.search);return!r&&!o?null:T.createElement(Qr.div,{ref:f0(a,s),...n,"cmdk-separator":"",role:"separator"})}),x_t=T.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=_1e(),l=Q1(h=>h.search),i=Q1(h=>h.selectedItemId),d=q6();return T.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),T.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:h=>{a||o.setState("search",h.target.value),r==null||r(h.target.value)}})}),y_t=T.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=T.useRef(null),l=T.useRef(null),i=Q1(h=>h.selectedItemId),d=q6();return T.useEffect(()=>{if(l.current&&o.current){let h=l.current,f=o.current,g,v=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let _=h.offsetHeight;f.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return v.observe(h),()=>{cancelAnimationFrame(g),v.unobserve(h)}}},[]),T.createElement(Qr.div,{ref:f0(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},roe(t,h=>T.createElement("div",{ref:f0(l,d.listInnerRef),"cmdk-list-sizer":""},h)))}),v_t=T.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return T.createElement(Eie,{open:r,onOpenChange:n},T.createElement(Iie,{container:l},T.createElement(B3,{"cmdk-overlay":"",className:a}),T.createElement($3,{"aria-label":t.label,"cmdk-dialog":"",className:o},T.createElement(JBe,{ref:s,...i}))))}),__t=T.forwardRef((t,s)=>Q1(r=>r.filtered.count===0)?T.createElement(Qr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),b_t=T.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return T.createElement(Qr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},roe(t,l=>T.createElement("div",{"aria-hidden":!0},l)))}),fm=Object.assign(JBe,{List:y_t,Item:p_t,Input:x_t,Group:f_t,Separator:g_t,Dialog:v_t,Empty:__t,Loading:b_t});function w_t(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function j_t(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function e9e(t){let s=T.useRef(t);return aN(()=>{s.current=t}),s}var aN=typeof window>"u"?T.useEffect:T.useLayoutEffect;function BC(t){let s=T.useRef();return s.current===void 0&&(s.current=t()),s}function Q1(t){let s=_1e(),r=()=>t(s.snapshot());return T.useSyncExternalStore(s.subscribe,r,r)}function t9e(t,s,r,n=[]){let a=T.useRef(),o=q6();return aN(()=>{var l;let i=(()=>{var h;for(let f of r){if(typeof f=="string")return f.trim();if(typeof f=="object"&&"current"in f)return f.current?(h=f.current.textContent)==null?void 0:h.trim():a.current}})(),d=n.map(h=>h.trim());o.value(t,i,d),(l=s.current)==null||l.setAttribute(zC,i),a.current=i}),a}var k_t=()=>{let[t,s]=T.useState(),r=BC(()=>new Map);return aN(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function N_t(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function roe({asChild:t,children:s},r){return t&&T.isValidElement(s)?T.cloneElement(N_t(s),{ref:s.ref},r(s.props.children)):r(s)}var S_t={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const wg=T.forwardRef(({className:t,...s},r)=>e.jsx(fm,{ref:r,className:$t("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));wg.displayName=fm.displayName;const C_t=({children:t,...s})=>e.jsx(js,{...s,children:e.jsx(_s,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(wg,{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})})}),jg=T.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(On,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(fm.Input,{ref:r,className:$t("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})]}));jg.displayName=fm.Input.displayName;const kg=T.forwardRef(({className:t,...s},r)=>e.jsx(fm.List,{ref:r,className:$t("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));kg.displayName=fm.List.displayName;const Ng=T.forwardRef((t,s)=>e.jsx(fm.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Ng.displayName=fm.Empty.displayName;const Sg=T.forwardRef(({className:t,...s},r)=>e.jsx(fm.Group,{ref:r,className:$t("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}));Sg.displayName=fm.Group.displayName;const M_t=T.forwardRef(({className:t,...s},r)=>e.jsx(fm.Separator,{ref:r,className:$t("-mx-1 h-px bg-border",t),...s}));M_t.displayName=fm.Separator.displayName;const Vm=T.forwardRef(({className:t,...s},r)=>e.jsx(fm.Item,{ref:r,className:$t("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}));Vm.displayName=fm.Item.displayName;const T_t={event:{label:"Events",icon:Km,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:hd,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:C1,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:a0,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:Sn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},u5e=()=>{const[t,s]=T.useState(!1),[r,n]=T.useState(""),[a,o]=T.useState([]),[l,i]=T.useState(!1),d=Yr();T.useEffect(()=>{const v=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(j=>!j))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[]);const h=T.useCallback(async v=>{if(!v.trim()){o([]);return}i(!0);const _=`%${v}%`;try{const[j,w,k,M,S]=await Promise.all([Z.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),Z.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${_},description.ilike.${_}`).limit(5),Z.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),Z.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${_},description.ilike.${_}`).limit(5),Z.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5)]),E=[];j.data&&j.data.forEach(D=>{E.push({id:D.id,title:D.title,description:D.description,type:"event",date:D.event_date,path:`/event/${D.id}`})}),w.data&&w.data.forEach(D=>{E.push({id:D.id,title:D.name,description:D.description,type:"template",date:D.publish_date,path:`/templates/${D.id}`})}),k.data&&k.data.forEach(D=>{E.push({id:D.id,title:D.title,description:D.description,type:"academy",date:D.publish_date,path:`/academy/${D.id}`})}),M.data&&M.data.forEach(D=>{E.push({id:D.id,title:D.name,description:D.description,type:"toolbox",date:D.publish_date,path:`/toolbox/${D.id}`})}),S.data&&S.data.forEach(D=>{E.push({id:D.id,title:D.title,description:D.description,type:"social-swag",date:D.publish_date,path:`/social-swag/${D.id}`})}),o(E)}catch(j){console.error("Search error:",j)}finally{i(!1)}},[]);T.useEffect(()=>{const v=setTimeout(()=>{h(r)},300);return()=>clearTimeout(v)},[r,h]);const f=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(Y,{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(On,{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(C_t,{open:t,onOpenChange:s,children:[e.jsx(jg,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(kg,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Ng,{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 j=T_t[v],w=j.icon;return e.jsx(Sg,{heading:j.label,children:_.map(k=>e.jsxs(Vm,{value:`${k.type}-${k.id}-${k.title}`,onSelect:()=>f(k.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${j.color}`,children:e.jsx(w,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:k.title}),k.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:k.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(ct,{variant:"secondary",className:"text-xs",children:j.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_u(new Date(k.date),{addSuffix:!0})})]})]},`${k.type}-${k.id}`))},v)})]})]})]})},A_t=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=T.useState(null),o=Yr();if(T.useEffect(()=>{const h=()=>{const g=new Date().getTime(),_=new Date(t).getTime()-g;if(_<=0){a({days:0,hours:0,minutes:0});return}const j=Math.floor(_/(1e3*60*60*24)),w=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),k=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:j,hours:w,minutes:k})};h();const f=setInterval(h,6e4);return()=>clearInterval(f)},[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:$t("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(Lu,{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(Y,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(Sn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:$t("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(ca,{className:$t("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:$t("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:$t("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:$t("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:$t("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:$t("text-xs",i?"text-destructive/70":d?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(Y,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":d?"default":"outline",className:$t("text-xs h-7 px-3",d&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(Sn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},E_t=()=>{const t=Yr();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(Oe,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(Ht,{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(Lu,{className:"h-8 w-8 text-destructive"})}),e.jsx(Gt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(Tr,{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($e,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Oe,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs($e,{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(br,{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(Y,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Oe,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs($e,{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(Ya,{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(Y,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(Ya,{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(Ha,{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(zr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},I_t=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:e.jsxs(Y,{variant:"ghost",size:"icon",onClick:s,className:$t("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(fh,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var noe="Checkbox",[P_t]=Dc(noe),[L_t,b1e]=P_t(noe);function D_t(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:d,required:h,value:f="on",internal_do_not_use_render:g}=t,[v,_]=Sh({prop:r,defaultProp:a??!1,onChange:d,caller:noe}),[j,w]=T.useState(null),[k,M]=T.useState(null),S=T.useRef(!1),E=j?!!l||!!j.closest("form"):!0,D={checked:v,disabled:o,setChecked:_,control:j,setControl:w,name:i,form:l,value:f,hasConsumerStoppedPropagationRef:S,required:h,defaultChecked:R1(a)?!1:a,isFormControl:E,bubbleInput:k,setBubbleInput:M};return e.jsx(L_t,{scope:s,...D,children:O_t(g)?g(D):n})}var s9e="CheckboxTrigger",r9e=T.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:h,setControl:f,setChecked:g,hasConsumerStoppedPropagationRef:v,isFormControl:_,bubbleInput:j}=b1e(s9e,t),w=ba(a,f),k=T.useRef(d);return T.useEffect(()=>{const M=o==null?void 0:o.form;if(M){const S=()=>g(k.current);return M.addEventListener("reset",S),()=>M.removeEventListener("reset",S)}},[o,g]),e.jsx(Qr.button,{type:"button",role:"checkbox","aria-checked":R1(d)?"mixed":d,"aria-required":h,"data-state":l9e(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:w,onKeyDown:kr(s,M=>{M.key==="Enter"&&M.preventDefault()}),onClick:kr(r,M=>{g(S=>R1(S)?!0:!S),j&&_&&(v.current=M.isPropagationStopped(),v.current||M.stopPropagation())})})});r9e.displayName=s9e;var w1e=T.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:h,form:f,...g}=t;return e.jsx(D_t,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:h,name:n,form:f,value:d,internal_do_not_use_render:({isFormControl:v})=>e.jsxs(e.Fragment,{children:[e.jsx(r9e,{...g,ref:s,__scopeCheckbox:r}),v&&e.jsx(o9e,{__scopeCheckbox:r})]})})});w1e.displayName=noe;var n9e="CheckboxIndicator",a9e=T.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=b1e(n9e,r);return e.jsx(Qc,{present:n||R1(o.checked)||o.checked===!0,children:e.jsx(Qr.span,{"data-state":l9e(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});a9e.displayName=n9e;var i9e="CheckboxBubbleInput",o9e=T.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:h,value:f,form:g,bubbleInput:v,setBubbleInput:_}=b1e(i9e,t),j=ba(r,_),w=O6(o),k=k6(n);T.useEffect(()=>{const S=v;if(!S)return;const E=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(E,"checked").set,B=!a.current;if(w!==o&&L){const $=new Event("click",{bubbles:B});S.indeterminate=R1(o),L.call(S,R1(o)?!1:o),S.dispatchEvent($)}},[v,w,o,a]);const M=T.useRef(R1(o)?!1:o);return e.jsx(Qr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??M.current,required:i,disabled:d,name:h,value:f,form:g,...s,tabIndex:-1,ref:j,style:{...s.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});o9e.displayName=i9e;function O_t(t){return typeof t=="function"}function R1(t){return t==="indeterminate"}function l9e(t){return R1(t)?"indeterminate":t?"checked":"unchecked"}const Do=T.forwardRef(({className:t,...s},r)=>e.jsx(w1e,{ref:r,className:$t("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(a9e,{className:$t("flex items-center justify-center text-current"),children:e.jsx(ma,{className:"h-4 w-4"})})}));Do.displayName=w1e.displayName;var j1e="Radio",[R_t,c9e]=Dc(j1e),[F_t,z_t]=R_t(j1e),d9e=T.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:h,...f}=t,[g,v]=T.useState(null),_=ba(s,k=>v(k)),j=T.useRef(!1),w=g?h||!!g.closest("form"):!0;return e.jsxs(F_t,{scope:r,checked:a,disabled:l,children:[e.jsx(Qr.button,{type:"button",role:"radio","aria-checked":a,"data-state":p9e(a),"data-disabled":l?"":void 0,disabled:l,value:i,...f,ref:_,onClick:kr(t.onClick,k=>{a||d==null||d(),w&&(j.current=k.isPropagationStopped(),j.current||k.stopPropagation())})}),w&&e.jsx(m9e,{control:g,bubbles:!j.current,name:n,value:i,checked:a,required:o,disabled:l,form:h,style:{transform:"translateX(-100%)"}})]})});d9e.displayName=j1e;var u9e="RadioIndicator",h9e=T.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=z_t(u9e,r);return e.jsx(Qc,{present:n||o.checked,children:e.jsx(Qr.span,{"data-state":p9e(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});h9e.displayName=u9e;var B_t="RadioBubbleInput",m9e=T.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=T.useRef(null),i=ba(l,o),d=O6(r),h=k6(s);return T.useEffect(()=>{const f=l.current;if(!f)return;const g=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(g,"checked").set;if(d!==r&&_){const j=new Event("click",{bubbles:n});_.call(f,r),f.dispatchEvent(j)}},[d,r,n]),e.jsx(Qr.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});m9e.displayName=B_t;function p9e(t){return t?"checked":"unchecked"}var $_t=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],aoe="RadioGroup",[U_t]=Dc(aoe,[z3,c9e]),f9e=z3(),g9e=c9e(),[q_t,V_t]=U_t(aoe),x9e=T.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:d,dir:h,loop:f=!0,onValueChange:g,...v}=t,_=f9e(r),j=jN(h),[w,k]=Sh({prop:o,defaultProp:a??null,onChange:g,caller:aoe});return e.jsx(q_t,{scope:r,name:n,required:l,disabled:i,value:w,onValueChange:k,children:e.jsx(Ive,{asChild:!0,..._,orientation:d,dir:j,loop:f,children:e.jsx(Qr.div,{role:"radiogroup","aria-required":l,"aria-orientation":d,"data-disabled":i?"":void 0,dir:j,...v,ref:s})})})});x9e.displayName=aoe;var y9e="RadioGroupItem",v9e=T.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=V_t(y9e,r),l=o.disabled||n,i=f9e(r),d=g9e(r),h=T.useRef(null),f=ba(s,h),g=o.value===a.value,v=T.useRef(!1);return T.useEffect(()=>{const _=w=>{$_t.includes(w.key)&&(v.current=!0)},j=()=>v.current=!1;return document.addEventListener("keydown",_),document.addEventListener("keyup",j),()=>{document.removeEventListener("keydown",_),document.removeEventListener("keyup",j)}},[]),e.jsx(Pve,{asChild:!0,...i,focusable:!l,active:g,children:e.jsx(d9e,{disabled:l,required:o.required,checked:g,...d,...a,name:o.name,ref:f,onCheck:()=>o.onValueChange(a.value),onKeyDown:kr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:kr(a.onFocus,()=>{var _;v.current&&((_=h.current)==null||_.click())})})})});v9e.displayName=y9e;var H_t="RadioGroupIndicator",_9e=T.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=g9e(r);return e.jsx(h9e,{...a,...n,ref:s})});_9e.displayName=H_t;var b9e=x9e,w9e=v9e,W_t=_9e;const k1e=T.forwardRef(({className:t,...s},r)=>e.jsx(b9e,{className:$t("grid gap-2",t),...s,ref:r}));k1e.displayName=b9e.displayName;const Hre=T.forwardRef(({className:t,...s},r)=>e.jsx(w9e,{ref:r,className:$t("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(W_t,{className:"flex items-center justify-center",children:e.jsx(Td,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Hre.displayName=w9e.displayName;const G_t=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Ys(),[o,l]=T.useState({}),[i,d]=T.useState({}),[h,f]=T.useState([]);T.useEffect(()=>{s&&a&&t.polls.length>0&&g()},[s,a,t.polls]);const g=async()=>{if(!a)return;const k=t.polls.map(S=>S.id),{data:M}=await Z.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",k);if(M){const S={};M.forEach(E=>{S[E.poll_id]||(S[E.poll_id]=[]),S[E.poll_id].push(E.option_id)}),d(S)}},v=(k,M)=>{l(S=>({...S,[k]:M}))},_=(k,M,S)=>{l(E=>{const D=E[k]||[];return S?{...E,[k]:[...D,M]}:{...E,[k]:D.filter(L=>L!==M)}})},j=async k=>{if(!a)return;const M=o[k];if(!M||Array.isArray(M)&&M.length===0){be.error("Please select an option");return}f(S=>[...S,k]);try{await Z.from("levelup_brief_poll_responses").delete().eq("poll_id",k).eq("user_id",a.id);const S=Array.isArray(M)?M:[M],E=S.map(L=>({poll_id:k,option_id:L,user_id:a.id})),{error:D}=await Z.from("levelup_brief_poll_responses").insert(E);if(D)throw D;d(L=>({...L,[k]:S})),be.success("Response submitted!")}catch(S){console.error("Error submitting poll response:",S),be.error("Failed to submit response")}finally{f(S=>S.filter(E=>E!==k))}},w=k=>(k.includes("mediadelivery.net")||k.includes("bunny"),k);return e.jsx(js,{open:s,onOpenChange:k=>!k&&r(),children:e.jsxs(_s,{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(Xr,{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(ct,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(Ps,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(po,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:w(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(k=>e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>window.open(k.url,"_blank"),className:"gap-2",children:[e.jsx(bn,{className:"h-4 w-4"}),k.title]},k.id))})]}),t.polls.map(k=>{var E,D;const M=((E=i[k.id])==null?void 0:E.length)>0,S=h.includes(k.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:k.question}),M&&e.jsxs(ct,{variant:"secondary",className:"gap-1",children:[e.jsx(oi,{className:"h-3 w-3"}),"Responded"]})]}),k.poll_type==="single"?e.jsx(k1e,{value:o[k.id]||((D=i[k.id])==null?void 0:D[0])||"",onValueChange:L=>v(k.id,L),className:"space-y-2",children:k.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Hre,{value:L.id,id:L.id}),e.jsx(je,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id))}):e.jsx("div",{className:"space-y-2",children:k.options.map(L=>{const $=(o[k.id]||i[k.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Do,{id:L.id,checked:$,onCheckedChange:V=>_(k.id,L.id,V)}),e.jsx(je,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id)})}),e.jsx(Y,{size:"sm",onClick:()=>j(k.id),disabled:S,children:S?"Submitting...":M?"Update Response":"Submit"})]},k.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(Y,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},K_t=()=>{const{user:t}=Ys(),[s,r]=T.useState(null),[n,a]=T.useState(!1),[o,l]=T.useState(!0),[i,d]=T.useState(!1),h=T.useCallback(async()=>{if(!t){l(!1);return}try{const{data:j,error:w}=await Z.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(w||!j){l(!1);return}const{data:k}=await Z.from("levelup_brief_views").select("*").eq("brief_id",j.id).eq("user_id",t.id).maybeSingle(),[M,S]=await Promise.all([Z.from("levelup_brief_links").select("*").eq("brief_id",j.id).order("sort_order"),Z.from("levelup_brief_polls").select("*").eq("brief_id",j.id).order("sort_order")]),E=[];if(S.data)for(const V of S.data){const{data:W}=await Z.from("levelup_brief_poll_options").select("*").eq("poll_id",V.id).order("sort_order");E.push({...V,options:W||[]})}const D={brief:j,links:M.data||[],polls:E};r(D);const L=!!k,B=(k==null?void 0:k.dismissed_at)!=null,$=localStorage.getItem(`brief-dismissed-${j.id}`)==="true";if(B||$)d(!1),a(!1);else if(!L)a(!0),d(!0);else if(j.show_frequency==="every_login")a(!0),d(!0);else if(j.show_frequency==="daily"){const V=new Date(k.viewed_at);(new Date().getTime()-V.getTime())/(1e3*60*60)>=24&&(a(!0),d(!0))}else d(!1)}catch(j){console.error("Error fetching brief:",j)}finally{l(!1)}},[t]);T.useEffect(()=>{h()},[h]);const f=async()=>{if(!(!t||!s))try{const{data:j}=await Z.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();j?await Z.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",j.id):await Z.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(j){console.error("Error marking brief as viewed:",j)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),f()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),d(!1);try{const{data:j,error:w}=await Z.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(w&&console.error("Error checking existing brief view:",w),j){const{error:k}=await Z.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",j.id).eq("user_id",t.id);k&&console.error("Error updating brief dismiss:",k)}else{const{error:k}=await Z.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});k&&console.error("Error inserting brief dismiss:",k)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(j){console.error("Error dismissing brief:",j),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:h}};function Z_t(){const[t,s]=T.useState(!1),[r,n]=T.useState(!1),[a,o]=T.useState(null);T.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(Vi,{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(qE,{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(Y,{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(Xr,{className:"h-4 w-4"})})]})]})}):null}const Y_t=({children:t,onRefresh:s})=>{const[r,n]=T.useState(!1),[a,o]=T.useState(0),[l,i]=T.useState(!1),d=T.useRef(null),h=T.useRef(0),f=vs(),g=80,v=120,_=T.useCallback(S=>{const E=d.current;E&&E.scrollTop<=0&&(h.current=S.touches[0].clientY,n(!0))},[]),j=T.useCallback(S=>{if(!r||l)return;const E=d.current;if(!E||E.scrollTop>0){n(!1),o(0);return}const L=S.touches[0].clientY-h.current;if(L>0){const $=Math.min(L*.5,v);o($),$>10&&S.preventDefault()}},[r,l]),w=T.useCallback(async()=>{if(r)if(n(!1),a>=g&&!l){i(!0),o(g);try{s?await s():await f.invalidateQueries()}catch(S){console.error("Refresh failed:",S)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,f]),k=Math.min(a/g,1),M=k*180;return e.jsxs("div",{ref:d,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:j,onTouchEnd:w,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:k},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${M}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(el,{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})]})},j9e=()=>{const{user:t}=Ys(),[s,r]=T.useState(!1),[n,a]=T.useState(!1),[o,l]=T.useState(0),[i,d]=T.useState(!0);T.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{const{data:_}=await Z.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(_){a(!0),r(!1),d(!1);return}const{data:j}=await Z.from("profiles").select("login_count").eq("id",t.id).single(),w=(j==null?void 0:j.login_count)||0;l(w);const k=sessionStorage.getItem("review-prompt-dismissed");r(w>=4&&!k)}catch(_){console.error("Error checking review eligibility:",_)}finally{d(!1)}})()},[t]);const h=T.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),f=T.useCallback(async(v,_)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:j}=await Z.from("membership_reviews").insert({user_id:t.id,rating:v,review_text:_});if(j)throw j;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(j){return console.error("Error submitting review:",j),{success:!1,error:j.message}}},[t]),g=T.useCallback(async()=>{if(t)try{await Z.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:h,submitReview:f,markPostedToGoogle:g}},X_t="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",Q_t=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=j9e(),[o,l]=T.useState(!1),[i,d]=T.useState("review"),[h,f]=T.useState(0),[g,v]=T.useState(0),[_,j]=T.useState(""),[w,k]=T.useState(!1),[M,S]=T.useState(!1);if(s||!t&&!M)return null;const E=async()=>{if(h===0){pn({title:"Please select a rating",variant:"destructive"});return}k(!0);const B=await n(h,_);k(!1),B.success?(S(!0),pn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):pn({title:"Error submitting review",description:B.error,variant:"destructive"})},D=async B=>{B&&(await navigator.clipboard.writeText(_||`${h} star rating for LevelUp!`),pn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(X_t,"_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(qn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(js,{open:o,onOpenChange:L,children:e.jsx(_s,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(en,{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(B=>e.jsx("button",{type:"button",onClick:()=>f(B),onMouseEnter:()=>v(B),onMouseLeave:()=>v(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(qn,{className:$t("h-8 w-8 transition-colors",(g||h)>=B?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},B))}),e.jsx(Rr,{placeholder:"Tell us about your experience (optional)",value:_,onChange:B=>j(B.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(Y,{onClick:E,disabled:w||h===0,className:"flex-1",children:w?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(en,{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(Y,{variant:"outline",onClick:()=>D(!1),className:"flex-1",children:"No Thanks"}),e.jsx(Y,{onClick:()=>D(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function J_t(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 w="vapid_public_key";let k=localStorage.getItem(w);if(!k){const{data:E,error:D}=await Z.functions.invoke("get-vapid-public-key",{body:{}});if(D)throw D;if(k=(E==null?void 0:E.vapidPublicKey)??null,!k)throw new Error("Missing VAPID public key");localStorage.setItem(w,k)}f(k);const M=await navigator.serviceWorker.register("/push-sw.js");d(M),r(Notification.permission);const S=await M.pushManager.getSubscription();a(!!S)}catch(w){console.error("Error initializing push notifications:",w)}finally{l(!1)}})()},[g]);const v=T.useCallback(async()=>{if(!g||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!h)return be.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{l(!0);const j=await i.pushManager.getSubscription();if(j){try{await j.unsubscribe()}catch(D){console.warn("Failed to unsubscribe existing push subscription:",D)}const{error:E}=await Z.from("push_subscriptions").delete().eq("user_id",t.id);E&&console.warn("Failed to cleanup push_subscriptions rows:",E)}if(Notification.permission!=="granted"){const E=await Notification.requestPermission();if(r(E),E!=="granted")return E==="denied"?be.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):be.error("Notification permission was dismissed. Please try again."),!1}const w=J_t(h);let k;try{k=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w})}catch(E){console.error("PushManager.subscribe() failed:",E);const D=(E==null?void 0:E.message)||String(E);return D.includes("permission")?be.error("Push permission denied. Check your browser notification settings."):D.includes("key")||D.includes("VAPID")?be.error("Push configuration error. Please contact support."):D.includes("AbortError")?be.error("Push subscription was cancelled. Please try again."):be.error(`Failed to subscribe: ${D}`),!1}const M=k.toJSON(),{error:S}=await Z.from("push_subscriptions").upsert({user_id:t.id,endpoint:M.endpoint,p256dh_key:M.keys.p256dh,auth_key:M.keys.auth},{onConflict:"user_id,endpoint"});if(S)throw console.error("Error saving subscription:",S),be.error("Failed to save notification preferences. Please try again."),S;return a(!0),be.success("Push notifications enabled!"),!0}catch(j){if(console.error("Error subscribing to push notifications:",j),!(j instanceof Error&&j.message.includes("toast"))){const w=j instanceof Error?j.message:"Unknown error";be.error("Failed to enable push notifications: "+w)}return!1}finally{l(!1)}},[g,i,t,h]),_=T.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const j=await i.pushManager.getSubscription();return j&&await j.unsubscribe(),await Z.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),be.success("Push notifications disabled"),!0}catch(j){console.error("Error unsubscribing:",j);const w=j instanceof Error?j.message:"Unknown error";return be.error("Failed to disable push notifications: "+w),!1}finally{l(!1)}},[i,t]);return{isSupported:g,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:h,subscribe:v,unsubscribe:_}}const h5e="push_notification_prompt_dismissed",ebt=()=>{const{user:t}=Ys(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=k9e(),[o,l]=T.useState(!1),[i,d]=T.useState(!1);T.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${h5e}_${t.id}`))return;const v=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(v)},[t,s,r,n]);const h=async()=>{d(!0);const g=await a();d(!1),g&&l(!1)},f=()=>{t&&localStorage.setItem(`${h5e}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(js,{open:o,onOpenChange:g=>!g&&f(),children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{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(dg,{className:"h-6 w-6 text-primary"})}),e.jsx(Ps,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(en,{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(Y,{onClick:h,disabled:i,className:"w-full",children:i?"Enabling...":"Enable Notifications"}),e.jsx(Y,{variant:"ghost",onClick:f,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."})]})})},m5e=t=>{let s;const r=new Set,n=(h,f)=>{const g=typeof h=="function"?h(s):h;if(!Object.is(g,s)){const v=s;s=f??(typeof g!="object"||g===null)?g:Object.assign({},s,g),r.forEach(_=>_(s,v))}},a=()=>s,i={setState:n,getState:a,getInitialState:()=>d,subscribe:h=>(r.add(h),()=>r.delete(h))},d=s=t(n,a,i);return i},tbt=t=>t?m5e(t):m5e,sbt=t=>t;function rbt(t,s=sbt){const r=lt.useSyncExternalStore(t.subscribe,lt.useCallback(()=>s(t.getState()),[t,s]),lt.useCallback(()=>s(t.getInitialState()),[t,s]));return lt.useDebugValue(r),r}const nbt=t=>{const s=tbt(t),r=n=>rbt(s,n);return Object.assign(r,s),r},abt=t=>nbt;function ibt(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 Qfe=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return Qfe(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return Qfe(n)(r)}}}},obt=(t,s)=>(r,n,a)=>{let o={storage:ibt(()=>localStorage),partialize:w=>w,version:0,merge:(w,k)=>({...k,...w}),...s},l=!1;const i=new Set,d=new Set;let h=o.storage;if(!h)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...w)},n,a);const f=()=>{const w=o.partialize({...n()});return h.setItem(o.name,{state:w,version:o.version})},g=a.setState;a.setState=(w,k)=>(g(w,k),f());const v=t((...w)=>(r(...w),f()),n,a);a.getInitialState=()=>v;let _;const j=()=>{var w,k;if(!h)return;l=!1,i.forEach(S=>{var E;return S((E=n())!=null?E:v)});const M=((k=o.onRehydrateStorage)==null?void 0:k.call(o,(w=n())!=null?w:v))||void 0;return Qfe(h.getItem.bind(h))(o.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==o.version){if(o.migrate){const E=o.migrate(S.state,S.version);return E instanceof Promise?E.then(D=>[!0,D]):[!0,E]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var E;const[D,L]=S;if(_=o.merge(L,(E=n())!=null?E:v),r(_,!0),D)return f()}).then(()=>{M==null||M(_,void 0),_=n(),l=!0,d.forEach(S=>S(_))}).catch(S=>{M==null||M(void 0,S)})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(h=w.storage)},clearStorage:()=>{h==null||h.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>j(),hasHydrated:()=>l,onHydrate:w=>(i.add(w),()=>{i.delete(w)}),onFinishHydration:w=>(d.add(w),()=>{d.delete(w)})},o.skipHydration||j(),_||v},lbt=obt,ioe=abt()(lbt((t,s)=>({cartItems:[],addToCart:(r,n,a=1,o)=>{t(l=>{const i=l.cartItems.findIndex(d=>{var h;return d.product.id===r.id&&((h=d.variant)==null?void 0:h.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})})),N9e=T.createContext({onlineUsers:[],totalOnline:0}),cbt=async t=>{try{const{data:s}=await Z.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=Z.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},dbt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Ys(),[a,o]=T.useState([]),[l,i]=T.useState(null);T.useEffect(()=>{if(!s)return;const h=Z.channel("app-presence",{config:{presence:{key:s.id}}});return h.on("presence",{event:"sync"},()=>{const f=h.presenceState(),g=[];Object.entries(f).forEach(([v,_])=>{if(_&&_.length>0){const j=_[0];g.push({id:v,name:j.name||"Unknown",avatarUrl:j.avatarUrl,brokerageId:j.brokerageId,onlineSince:j.onlineSince})}}),o(g)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async f=>{var g;if(f==="SUBSCRIBED"){const{data:v}=await Z.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),_=await cbt(s.id);await h.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(h),()=>{h.unsubscribe()}},[s]);const d=a.filter(h=>h.id===(s==null?void 0:s.id)?!1:!!(n||r&&h.brokerageId===r||!r&&!h.brokerageId));return e.jsx(N9e.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:t})},S9e=()=>T.useContext(N9e),p5e="dashboard-sidebar-collapsed",Vs=({children:t,title:s})=>{var He,Ue,De;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Ys(),{isAssistant:i,actingAsAgent:d,hasPermission:h}=Ave(),{isImpersonating:f}=Tve(),v=(i&&!!d?40:0)+(f?40:0),{avatarUrl:_}=hBe(r==null?void 0:r.id),{isTrial:j,isExpired:w,expiresAt:k}=a1t(r==null?void 0:r.id),{isMarketplaceEnabled:M}=pBe(),{currentBrief:S,shouldShowPopup:E,hasUnseenBrief:D,openBrief:L,closeBrief:B,dismissBrief:$}=K_t(),{unreadCount:V}=i1t(),{openCount:W}=o1t(),{data:G}=h_(),J=!!G,ie=ioe(Ge=>Ge.cartItems).reduce((Ge,wt)=>Ge+wt.quantity,0),ee=Yr(),de=pm(),[oe,ue]=T.useState(()=>typeof window<"u"?localStorage.getItem(p5e)==="true":!1);T.useEffect(()=>{localStorage.setItem(p5e,String(oe))},[oe]);const[ce,ge]=T.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,help:!1}),Te=Ge=>{ge(wt=>({...wt,[Ge]:!wt[Ge]}))},ve=Ge=>Ge.split(" ").map(wt=>wt[0]).join("").toUpperCase().slice(0,2),ye=Ge=>de.pathname===Ge,Se=Ge=>Ge.some(wt=>de.pathname===wt),Ke=({path:Ge,icon:wt,label:Ie,badgeCount:st})=>{const he=e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",ye(Ge)&&"bg-sidebar-accent text-sidebar-accent-foreground",oe?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>ee(Ge),children:[e.jsxs("div",{className:"relative",children:[e.jsx(wt,{className:"h-4 w-4 shrink-0"}),oe&&st!=null&&st>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!oe&&Ie,!oe&&st!=null&&st>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:st>9?"9+":st})]});return oe?e.jsxs(em,{delayDuration:0,children:[e.jsx(tm,{asChild:!0,children:he}),e.jsxs(fh,{side:"right",className:"flex items-center gap-2",children:[Ie,st!=null&&st>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:st>9?"9+":st})]})]}):he},Ae=({id:Ge,label:wt,icon:Ie,children:st,activePaths:he,showBetaBadge:We,defaultPath:et,badgeCount:Ye})=>{if(oe){const ke=et||he[0];return e.jsxs(em,{delayDuration:0,children:[e.jsx(tm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"sm",className:$t("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Se(he)&&"text-primary"),onClick:()=>ee(ke),children:e.jsxs("div",{className:"relative",children:[e.jsx(Ie,{className:"h-4 w-4"}),Ye!=null&&Ye>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(fh,{side:"right",className:"flex items-center gap-2",children:[wt,We&&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"}),Ye!=null&&Ye>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:Ye>9?"9+":Ye})]})]})}return e.jsxs(Dk,{open:ce[Ge],onOpenChange:()=>Te(Ge),children:[e.jsx(Ok,{asChild:!0,children:e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Se(he)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(Ie,{className:"h-4 w-4"}),wt,We&&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:[Ye!=null&&Ye>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:Ye>9?"9+":Ye}),e.jsx(Gc,{className:$t("h-4 w-4 transition-transform duration-200",ce[Ge]&&"rotate-180")})]})]})}),e.jsx(Rk,{className:"pl-4 space-y-1 mt-1",children:st})]})},Ee=({isMobile:Ge=!1})=>{const wt=Ge?!1:oe;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:$t("p-3 border-b border-sidebar-border",wt?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[wt?e.jsx("img",{src:T1t,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:M1t,alt:"LevelUp",className:"h-8 w-auto"}),!Ge&&e.jsxs(em,{delayDuration:0,children:[e.jsx(tm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>ue(!wt),children:e.jsx(hc,{className:$t("h-4 w-4 transition-transform duration-300",wt&&"rotate-180")})})}),e.jsx(fh,{side:"right",children:wt?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(po,{className:"flex-1",children:e.jsxs("nav",{className:$t("p-3 space-y-1",wt&&"flex flex-col items-center"),children:[e.jsx(Ke,{path:"/dashboard",icon:Nk,label:"Dashboard"}),e.jsx(Ke,{path:"/events",icon:Km,label:"Events"}),e.jsxs(Ae,{id:"agentos",label:"Agent OS",icon:C4,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"],showBetaBadge:!0,defaultPath:"/mission-control",children:[h("contacts")&&e.jsx(Ke,{path:"/mission-control",icon:Ti,label:"Mission Control"}),h("contacts")&&e.jsx(Ke,{path:"/mission-control/contacts",icon:br,label:"Contacts"}),h("contacts")&&e.jsx(Ke,{path:"/mission-control/plans",icon:Km,label:"TouchPlans"}),h("pipeline")&&e.jsx(Ke,{path:"/mission-control/pipeline",icon:Sx,label:"Deal Pipeline"}),h("pipeline")&&e.jsx(Ke,{path:"/mission-control/tasks",icon:Oy,label:"Tasks"}),h("popbys")&&e.jsx(Ke,{path:"/mission-control/popbys",icon:oo,label:"Popbys"}),h("videos")&&e.jsx(Ke,{path:"/mission-control/video-library",icon:Wn,label:"Video Library"}),h("scorecard")&&e.jsx(Ke,{path:"/mission-control/scorecard",icon:Sc,label:"Scorecard"}),h("listings")&&e.jsx(Ke,{path:"/mission-control/listings",icon:Ya,label:"Listing Exchange"})]}),e.jsxs(Ae,{id:"tools",label:"Tools",icon:Im,activePaths:["/apps","/ai-toolkit","/mission-control/my-card","/mission-control/presentations","/mission-control/guest-book"],defaultPath:"/apps",children:[e.jsx(Ke,{path:"/apps",icon:Im,label:"Apps"}),h("digital_card")&&!wt&&e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/mission-control/my-card")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/mission-control/my-card"),children:[e.jsx(Zm,{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"})]}),h("digital_card")&&wt&&e.jsx(Ke,{path:"/mission-control/my-card",icon:Zm,label:"Smart Card"}),h("presentations")&&!wt&&e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("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:()=>ee("/mission-control/presentations"),children:[e.jsx(Gp,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:"Presentations"}),e.jsx("span",{className:"ml-auto shrink-0 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"})]}),h("presentations")&&wt&&e.jsx(Ke,{path:"/mission-control/presentations",icon:Gp,label:"Smart Presentations"}),h("guest_book")&&!wt&&e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/mission-control/guest-book")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/mission-control/guest-book"),children:[e.jsx(Yy,{className:"h-4 w-4"}),"Guest Book",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"})]}),h("guest_book")&&wt&&e.jsx(Ke,{path:"/mission-control/guest-book",icon:Yy,label:"Guest Book"}),!wt&&e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/mission-control/card-studio")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/mission-control/card-studio"),children:[e.jsx(zr,{className:"h-4 w-4"}),"Card Studio",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"})]}),wt&&e.jsx(Ke,{path:"/mission-control/card-studio",icon:zr,label:"Card Studio"})]}),e.jsxs(Ae,{id:"marketing",label:"Marketing",icon:fg,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Ke,{path:"/templates",icon:hd,label:"Templates"}),e.jsx(Ke,{path:"/social-swag-2",icon:n0,label:"Social Swag"}),e.jsx(Ke,{path:"/newsletters",icon:r0,label:"Newsletters"})]}),e.jsxs(Ae,{id:"learning",label:"Learning",icon:Yy,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Ke,{path:"/academy",icon:C1,label:"Academy"}),e.jsx(Ke,{path:"/toolbox",icon:a0,label:"Toolbox"})]}),e.jsxs(Ae,{id:"community",label:"Community",icon:Eo,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:V,children:[e.jsx(Ke,{path:"/community",icon:br,label:"Community",badgeCount:V}),e.jsx(Ke,{path:"/wishlist",icon:t0,label:"Wishlist",badgeCount:W}),!wt&&e.jsxs(Y,{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(bn,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(Ae,{id:"goods",label:"The Goods",icon:Jh,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[M&&!wt&&e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("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:()=>ee("/marketplace"),children:[e.jsx(Jh,{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"})]}),M&&wt&&e.jsx(Ke,{path:"/marketplace",icon:Jh,label:"Marketplace"}),e.jsx(Ke,{path:"/reward-store",icon:vo,label:"Reward Store"})]}),e.jsxs(Ae,{id:"help",label:"Help & Services",icon:Dy,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Ke,{path:"/support",icon:D4,label:"Support"}),e.jsx(Ke,{path:"/additional-services",icon:Sn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!wt&&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"})}),wt?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Ke,{path:"/admin",icon:zu,label:"Admin Dashboard"})}):e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("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:()=>ee("/admin"),children:[e.jsx(zu,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!wt&&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"})}),wt?e.jsxs("div",{className:"border-t border-sidebar-border mt-3 pt-3 space-y-1",children:[l&&e.jsx(Ke,{path:"/my-brokerage",icon:Ya,label:"My Brokerage"}),J&&!o&&e.jsx(Ke,{path:"/my-team",icon:br,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Ke,{path:"/brokerage/dashboard",icon:Ic,label:"Manage Brokerages"}),e.jsx(Ke,{path:"/brokerage/teams",icon:br,label:"Teams"}),e.jsx(Ke,{path:"/brokerage-resources",icon:Fu,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/my-brokerage"),children:[e.jsx(Ya,{className:"h-4 w-4"}),"My Brokerage"]}),J&&!o&&e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/my-team"),children:[e.jsx(br,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/brokerage/dashboard"),children:[e.jsx(Ic,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/brokerage/teams"),children:[e.jsx(br,{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(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/brokerage-resources"),children:[e.jsx(Fu,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(Y,{variant:"ghost",size:"sm",className:$t("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ye("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>ee("/profile"),children:[e.jsx(Wo,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(Y,{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(F4,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(dbt,{children:e.jsx(bN,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[j&&w&&e.jsx(E_t,{}),typeof document<"u"&&Qh.createPortal(e.jsx("aside",{className:$t("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-[2147483647] isolate !pointer-events-auto transition-[width] duration-300",oe?"w-16":"w-52"),style:{top:`${v}px`,height:`calc(100vh - ${v}px)`},children:e.jsx(Ee,{})}),document.body),e.jsxs("div",{className:$t("flex-1 flex flex-col overflow-hidden transition-all duration-300",oe?"md:ml-16":"md:ml-52"),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(z6,{children:[e.jsx(a1e,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(EE,{className:"h-5 w-5"})})}),e.jsx(q3,{side:"left",className:"w-52 p-0 bg-card",children:e.jsx(Ee,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:A1t,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(u5e,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[j&&!w&&k&&e.jsx(A_t,{expiresAt:k,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(u5e,{})}),S&&e.jsx(I_t,{hasUnseenBrief:D,onClick:L}),M&&e.jsxs(Y,{variant:"ghost",size:"icon",className:"relative",onClick:()=>ee("/marketplace/cart"),children:[e.jsx(Jh,{className:"h-5 w-5"}),ie>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:ie>99?"99+":ie})]}),e.jsx(s_t,{}),e.jsx(Zfe,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",((Ue=(He=r==null?void 0:r.user_metadata)==null?void 0:He.name)==null?void 0:Ue.split(" ")[0])||"User","!"]}),e.jsxs(Hu,{children:[e.jsx(Wu,{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(_a,{src:_||void 0}),e.jsx(gn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:ve(((De=r==null?void 0:r.user_metadata)==null?void 0:De.name)||(r==null?void 0:r.email)||"U")})]})})}),e.jsxs(ju,{align:"end",className:"w-48",children:[e.jsxs(Va,{onClick:()=>ee("/profile"),className:"cursor-pointer",children:[e.jsx(Wo,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Va,{onClick:()=>ee("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(FE,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(eN,{}),e.jsxs(Va,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(F4,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(Y_t,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),S&&e.jsx(G_t,{brief:S,open:E,onClose:B,onDismiss:$}),e.jsx(Z_t,{}),e.jsx(Q_t,{}),e.jsx(ebt,{})]})]})})})},ubt=()=>{const{user:t}=Ys(),[s,r]=T.useState(!1),[n,a]=T.useState(null),[o,l]=T.useState(""),i=async g=>{var v;if(!(t!=null&&t.email)){be.error("Please sign in to upgrade");return}r(!0),a(g);try{const{data:_,error:j}=await Z.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(j)throw j;if(_!=null&&_.url)window.open(_.url,"_blank","noopener,noreferrer"),be.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(_){console.error("Checkout error:",_),be.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"],h=["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"],f=["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(Vs,{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(je,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(Be,{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(Oe,{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(Ht,{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(br,{className:"h-7 w-7 text-primary"})}),e.jsx(Gt,{className:"text-xl",children:"Individual Agent"}),e.jsx(Tr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs($e,{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(ma,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),e.jsxs(Y,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Oe,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(Ht,{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(Ya,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Gt,{className:"text-xl",children:"Brokerage"}),e.jsx(Tr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs($e,{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:h.map((g,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ma,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),e.jsxs(Y,{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(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Oe,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(Ht,{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(Ya,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Gt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(Tr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs($e,{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:f.map((g,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ma,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:g})]},v))}),e.jsxs(Y,{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(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Oe,{className:"bg-muted/50",children:e.jsxs($e,{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(Ha,{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(zr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},hbt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Ys(),a=Yr(),[o,l]=T.useState(""),[i,d]=T.useState(!1),[h,f]=T.useState(!1);T.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),T.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const g=async()=>{if(!o.trim()){be.error("Please enter a brokerage name");return}const{data:v}=await Z.auth.getSession(),_=v.session;if(!t||!_){be.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:j,error:w}=await Z.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:j,error:w}),w)throw w;if(!(j!=null&&j.ok))throw new Error((j==null?void 0:j.error)||"Failed to create brokerage");d(!1),f(!0),be.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(j){console.error("Error creating brokerage:",j),be.error(j.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"})}):h?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(Oe,{className:"max-w-lg w-full",children:[e.jsxs(Ht,{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(Us,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Gt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(Tr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(yi,{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(Us,{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(Oe,{className:"max-w-lg w-full",children:[e.jsxs(Ht,{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(Ya,{className:"w-10 h-10 text-primary"})}),e.jsx(Gt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(Tr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs($e,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Be,{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(br,{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(yi,{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(yi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(yi,{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(yi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(Y,{onClick:g,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(qi,{className:"w-4 h-4 ml-2"})]})]})]})})},f5e=()=>{const t=Yr(),[s,r]=T.useState("verifying"),[n,a]=T.useState("");T.useEffect(()=>{(async()=>{try{const{data:{session:i},error:d}=await Z.auth.getSession();if(d)throw d;if(i!=null&&i.user){const{data:h}=await Z.from("profiles").select("login_count").eq("id",i.user.id).single();if(((h==null?void 0:h.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 Z.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(f){console.log("Trial claim hook (non-critical):",f)}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(Oe,{className:"w-full max-w-md",children:[e.jsxs(Ht,{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(Gt,{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(Tr,{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($e,{children:e.jsx(Y,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},mbt=()=>{const t=Yr(),[s]=Oc(),[r,n]=T.useState(s.get("code")||""),[a,o]=T.useState(""),[l,i]=T.useState(""),[d,h]=T.useState(""),[f,g]=T.useState(!1),[v,_]=T.useState(!1),[j,w]=T.useState(!1),[k,M]=T.useState(!1),[S,E]=T.useState(null),[D,L]=T.useState(null),[B,$]=T.useState(null),[V,W]=T.useState(null);T.useEffect(()=>{const ie=s.get("code");ie&&(n(ie),G(ie))},[s]);const G=async ie=>{w(!0);const{data:ee,error:de}=await Z.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",ie.toUpperCase().trim()).single();if(de||!ee){be.error("Invalid invite code"),w(!1);return}if(!ee.is_active){be.error("This invite code is no longer active"),w(!1);return}if(ee.max_uses&&ee.uses_count>=ee.max_uses){be.error("This invite code has reached its maximum uses"),w(!1);return}if(ee.expires_at&&new Date(ee.expires_at){ie.preventDefault(),G(r)},ne=async ie=>{var ee;if(ie.preventDefault(),!d.trim()){be.error("Please enter your name");return}if(l.length<6){be.error("Password must be at least 6 characters");return}_(!0);try{const de=`${window.location.origin}/`,{data:oe,error:ue}=await Z.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:de,data:{name:d.trim()}}});if(ue){ue.message.includes("already registered")?be.error("This email is already registered. Please sign in instead."):be.error(ue.message);return}oe.user&&(await Z.rpc("add_default_signup_tag",{user_id:oe.user.id}),D?await Z.functions.invoke("assign-brokerage",{body:{userId:oe.user.id,brokerageId:D}}):V?await Z.functions.invoke("assign-brokerage",{body:{userId:oe.user.id,trialDays:V}}):await Z.functions.invoke("assign-brokerage",{body:{userId:oe.user.id,grandfathered:!0}}),S&&await Z.from("invite_codes").update({uses_count:((ee=(await Z.from("invite_codes").select("uses_count").eq("id",S).single()).data)==null?void 0:ee.uses_count)+1}).eq("id",S),be.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(de){console.error("Signup error:",de),be.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(Oe,{className:"w-full max-w-md",children:[e.jsxs(Ht,{className:"text-center",children:[e.jsx(Gt,{className:"text-2xl font-bold text-primary",children:B?`Join ${B}`:"Join LevelUp"}),e.jsx(Tr,{children:k?B?`Create your account to join ${B}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx($e,{children:k?e.jsxs("form",{onSubmit:ne,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"name",children:"Full Name"}),e.jsx(Be,{id:"name",type:"text",placeholder:"John Doe",value:d,onChange:ie=>h(ie.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"email",children:"Email"}),e.jsx(Be,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:ie=>o(ie.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Be,{id:"password",type:f?"text":"password",placeholder:"••••••••",value:l,onChange:ie=>i(ie.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(!f),children:f?e.jsx(Wp,{className:"h-4 w-4"}):e.jsx(wi,{className:"h-4 w-4"})})]})]}),e.jsx(Y,{type:"submit",className:"w-full",disabled:v,children:v?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:J,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(Be,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:ie=>n(ie.target.value),required:!0,autoFocus:!0})]}),e.jsx(Y,{type:"submit",className:"w-full",disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},pbt="/assets/testimonial-avatar-1-BsCQFauB.jpg",fbt="/assets/testimonial-avatar-2-B6VPVc2t.jpg",gbt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",xbt="/assets/testimonial-avatar-4-98iKMtkB.jpg",ybt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",vbt=[pbt,fbt,gbt,xbt,ybt],_bt=u_({name:Uo().trim().min(2,"Name must be at least 2 characters").max(100),email:Uo().trim().email("Please enter a valid email address").max(255),phone:Uo().trim().min(10,"Please enter a valid phone number").max(20).optional().or(q5("")),brokerage:Uo().trim().max(200).optional().or(q5(""))}),bbt=[{icon:Om,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:hd,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:xn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Gl,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:Yn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:oo,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],wbt=[{icon:br,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:Sn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Ha,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Gm,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Gi,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Sc,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ti,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Ax,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],jbt=[{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."}],kbt=()=>{const t=Yr(),[s,r]=T.useState(!1),[n,a]=T.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=T.useState({}),i=async d=>{var f,g;d.preventDefault(),l({});const h=_bt.safeParse(n);if(!h.success){const v={};h.error.errors.forEach(_=>{_.path[0]&&(v[_.path[0]]=_.message)}),l(v);return}r(!0);try{const{data:v,error:_}=await Z.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((f=n.phone)==null?void 0:f.trim())||void 0,brokerage:((g=n.brokerage)==null?void 0:g.trim())||void 0}});if(_){console.error("Trial signup error:",_),be.error(_.message||"Something went wrong. Please try again.");return}if(v!=null&&v.error){be.error(v.error);return}be.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(v){console.error("Trial signup error:",v),be.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(Ih,{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:Fre,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(Y,{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(Y,{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(Sn,{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(oi,{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(oi,{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:vbt.map((d,h)=>e.jsx("img",{src:d,alt:`Agent ${h+1}`,className:"w-10 h-10 rounded-full border-2 border-white/20 object-cover"},h))}),e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(d=>e.jsx(qn,{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(Oe,{className:"bg-white shadow-2xl border-0",children:e.jsxs($e,{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(Cx,{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(je,{htmlFor:"name",children:"Full Name *"}),e.jsx(Be,{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(je,{htmlFor:"email",children:"Email Address *"}),e.jsx(Be,{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(je,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Be,{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(je,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(Be,{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(Y,{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(Us,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(qi,{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:bbt.map((d,h)=>e.jsxs(Oe,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Ht,{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(Gt,{className:"text-xl font-sans",children:d.title})]}),e.jsx($e,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:d.description})})]},h))})]})}),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(Sn,{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:wbt.map((d,h)=>e.jsxs(Oe,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Ht,{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(Gt,{className:"text-lg font-semibold text-white",children:d.title})]}),e.jsx($e,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:d.description})})]},h))})]})]}),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:jbt.map((d,h)=>e.jsx(Oe,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs($e,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(f=>e.jsx(qn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},f))}),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})]})]})},h))})]})}),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(Bu,{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(Ax,{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(br,{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(Oe,{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($e,{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(Y,{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(qi,{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:Wve,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."})]})})})]})]})},Nbt=()=>{const t=Yr();return e.jsxs(e.Fragment,{children:[e.jsx(Ih,{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:Fre,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(Y,{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(Oe,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs($e,{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(oi,{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(md,{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(zr,{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(Y,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx(qi,{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:Wve,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},Sbt=u_({viewerName:Uo().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Uo().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Uo().max(20,"Phone must be less than 20 characters").optional(),message:Uo().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function Cbt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=T.useState(!1),[o,l]=T.useState(!1),[i,d]=T.useState(null),h=Jie({resolver:eoe(Sbt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),f=async g=>{a(!0),d(null);try{const{data:v,error:_}=await Z.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(Oe,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs($e,{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(oi,{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(Oe,{children:[e.jsxs(Ht,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Gl,{className:"h-5 w-5 text-primary"}),e.jsx(Gt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(Tr,{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($e,{children:e.jsx(toe,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(f),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Jl,{control:h.control,name:"viewerName",render:({field:g})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Your Name *"}),e.jsx($l,{children:e.jsx(Be,{placeholder:"John Smith",...g})}),e.jsx(gh,{})]})}),e.jsx(Jl,{control:h.control,name:"viewerEmail",render:({field:g})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Email *"}),e.jsx($l,{children:e.jsx(Be,{type:"email",placeholder:"john@example.com",...g})}),e.jsx(gh,{})]})})]}),!r&&e.jsx(Jl,{control:h.control,name:"viewerPhone",render:({field:g})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Phone (optional)"}),e.jsx($l,{children:e.jsx(Be,{type:"tel",placeholder:"(555) 123-4567",...g})}),e.jsx(gh,{})]})}),e.jsx(Jl,{control:h.control,name:"message",render:({field:g})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Message *"}),e.jsx($l,{children:e.jsx(Rr,{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(gh,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(Y,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const Mbt=()=>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(qn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(qn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(qn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(qn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(qn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(e0,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),Tbt=()=>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(Sn,{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(qn,{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(Sn,{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(qn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(qn,{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(e0,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),Abt=()=>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(ng,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(ng,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(ng,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(ng,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Ti,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Ti,{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(Ti,{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"})]}),Ebt=()=>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(nc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(qn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(nc,{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(qn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(qn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),Ibt=()=>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(ng,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(ng,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(T4,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),Pbt=()=>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(jk,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(jk,{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(Sn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(Sn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),Lbt=()=>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(P1,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(P1,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(P1,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(o1,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(o1,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(o1,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(o1,{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(qn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),Dbt=()=>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(Ti,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Ti,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),Obt=()=>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(qn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(qn,{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(qn,{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(qn,{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(Sn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(md,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(md,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),Rbt=()=>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(qn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(Sn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(Sn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),Fbt=()=>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(qy,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(qy,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(qy,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(qy,{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"})]})]})]}),zbt=()=>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(qn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(qn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(nc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(nc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(e0,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),Bbt=()=>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(Gm,{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(md,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(oo,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),$bt=()=>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(Ti,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Ti,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Ti,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Ti,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Ti,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Ti,{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(Ti,{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(Ti,{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"})]}),Ubt=()=>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(I1,{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(I1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(Sn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(I1,{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"})]}),qbt=()=>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(Zn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Zn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Xm,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Xm,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Ti,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Ti,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(Sn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(md,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),Vbt=()=>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(md,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(md,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Xm,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(Zn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(Sn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(Sn,{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"})]}),Hbt=()=>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(Xm,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Xm,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Xm,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(Zn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(md,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(Sn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(qn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),Wbt=()=>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(Zn,{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(Xm,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Ti,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(Sn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(Xy,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),g5e=()=>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"})]}),Gbt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Ti,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Ti,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Ti,{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(Ti,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),Kbt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Xy,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(Sn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(Zn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),Zbt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(_k,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(z4,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(_k,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),SA=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Sn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(md,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(Sn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),x5e=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Zn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(Sn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(Zn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),Jfe=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(Sn,{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(Ti,{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(Gbt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(bE,{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(SA,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(_k,{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(Zbt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(Sc,{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(br,{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(SA,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(nc,{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(g5e,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Gi,{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(x5e,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(z4,{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(SA,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Gm,{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(Bbt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Ti,{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($bt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(I1,{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(Ubt,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(qn,{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(Obt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(T4,{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(Ibt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(ng,{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(Abt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(nc,{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(Ebt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(e0,{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(Mbt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(Ym,{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(Tbt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(nc,{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(zbt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(jk,{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(Pbt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Ti,{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(Dbt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(P1,{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(Lbt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(Sn,{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(Rbt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(qy,{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(Fbt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Zn,{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(qbt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(md,{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(Vbt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(xn,{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(x5e,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(Ad,{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(SA,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(Pk,{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(Xy,{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(Kbt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Xm,{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(Hbt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Zn,{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(Wbt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(Ed,{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(SA,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(nc,{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(g5e,{})}],Ybt=[{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 Xbt(t){return Jfe.filter(s=>s.category===t)}function e5(t){return Jfe.find(s=>s.id===t)||Jfe[0]}function Qbt(){const{shareToken:t}=wl(),[s,r]=T.useState(null),[n,a]=T.useState(null),[o,l]=T.useState(null),[i,d]=T.useState(!0),[h,f]=T.useState(null),[g,v]=T.useState(!0);T.useEffect(()=>{const B=()=>{['[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(G=>{document.querySelectorAll(G).forEach(J=>{J.style.display="none"})})};B();const $=[setTimeout(B,500),setTimeout(B,1500),setTimeout(B,3e3)],V=new MutationObserver(B);return V.observe(document.body,{childList:!0,subtree:!0}),()=>{$.forEach(clearTimeout),V.disconnect()}},[]),T.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),d(!1);return}const{data:$,error:V}=await Z.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(V||!$){f("Video not found or has been removed"),d(!1);return}r($);try{await Z.rpc("log_video_view",{p_video_id:$.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(W){console.warn("Failed to log video view:",W)}if($.owner_user_id){const{data:W}=await Z.from("profiles").select("id, name, email, phone").eq("id",$.owner_user_id).single();if(W){a(W);try{const{data:G}=await Z.storage.from("avatars").list(`${$.owner_user_id}`);if(G&&G.length>0){const{data:J}=Z.storage.from("avatars").getPublicUrl(`${$.owner_user_id}/${G[0].name}`);l(J.publicUrl)}}catch{}}}d(!1)})()},[t]);const _=B=>{if(!B)return"0:00";const $=Math.floor(B/60),V=B%60;return`${$}:${V.toString().padStart(2,"0")}`},j=B=>B.includes("iframe.mediadelivery.net/play/")?B.replace("/play/","/embed/")+"?autoplay=true&responsive=true":B,w=B=>{if(!B)return"?";const $=B.split(" ");return $.length>=2?`${$[0][0]}${$[1][0]}`.toUpperCase():B.substring(0,2).toUpperCase()},k=e5((s==null?void 0:s.page_template)||"default"),M=(s==null?void 0:s.recipient_name)||null,S=k.headerText(M),D=`https://dashboard.relevelup.com/share/video/${t}`;if(i)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-primary"})});if(h||!s)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Oe,{className:"max-w-md w-full",children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx(Wn,{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:h||"This video is no longer available."})]})})});const L=k.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(Ih,{children:[e.jsx("title",{children:S}),e.jsx("meta",{name:"description",content:k.subText}),e.jsx("meta",{property:"og:title",content:S}),e.jsx("meta",{property:"og:description",content:k.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:D}),s.preview_url&&e.jsx("meta",{property:"og:image",content:s.preview_url}),!s.preview_url&&s.thumbnail_url&&e.jsx("meta",{property:"og:image",content:s.thumbnail_url}),s.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:s.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:S}),e.jsx("meta",{name:"twitter:description",content:k.subText}),s.preview_url&&e.jsx("meta",{name:"twitter:image",content:s.preview_url}),s.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:s.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:$t("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",k.gradientClasses),children:[L&&k.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[L&&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:$t("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",k.accentColor==="primary"&&"bg-primary/10 text-primary",k.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",k.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",k.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",k.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",k.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",k.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",k.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",k.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",k.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",k.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",k.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",k.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:k.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:S}),e.jsx("p",{className:"text-muted-foreground",children:k.subText})]}),n&&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(_a,{src:o||void 0,alt:n.name||"Agent"}),e.jsx(gn,{className:"bg-primary/10 text-primary font-semibold",children:w(n.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:L?"A special video from":"A personal video from"}),e.jsx("h2",{className:"text-lg font-semibold truncate",children:n.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:[n.phone&&e.jsx(Y,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`tel:${n.phone}`,"aria-label":"Call agent",children:e.jsx(Ha,{className:"h-4 w-4"})})}),n.email&&e.jsx(Y,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`mailto:${n.email}`,"aria-label":"Email agent",children:e.jsx(zr,{className:"h-4 w-4"})})})]})]}),e.jsx(Oe,{className:"overflow-hidden shadow-lg",children:g&&s.playback_url?e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:e.jsx("iframe",{src:j(s.playback_url),title:s.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:()=>v(!0),children:[s.preview_url||s.thumbnail_url?e.jsx("img",{src:s.preview_url||s.thumbnail_url||"",alt:s.title?`${s.title} video preview`:"Video message preview",className:"w-full h-full object-cover",onError:B=>{var V;B.currentTarget.style.display="none";const $=(V=B.currentTarget.parentElement)==null?void 0:V.querySelector(".video-fallback");$&&($.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:s.preview_url||s.thumbnail_url?"none":"flex"},children:e.jsx(Wn,{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(Kl,{className:"h-10 w-10 text-primary ml-1"})})}),s.duration_seconds&&e.jsx("div",{className:"absolute bottom-3 right-3 bg-black/70 text-white text-sm px-2 py-1 rounded",children:_(s.duration_seconds)})]})}),!L&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:s.title||"Video Message"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:g?"Enjoy the video!":"Click to play the video"})]}),!g&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(Y,{size:"lg",onClick:()=>v(!0),className:"gap-2",children:[e.jsx(Kl,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(Cbt,{shareToken:t,agentName:(n==null?void 0:n.name)||null,hasContact:!!s.contact_id})]})]})]})}function Jbt(){return T.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(Dct,{})}function ewt(){const{token:t}=wl();return T.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(Us,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const twt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},swt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},CC={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function rwt(){var ee,de,oe,ue;const{slugOrId:t}=wl(),[s]=Oc(),{data:r,isLoading:n}=j7e(t||""),a=k7e(),o=Mgt(),l=s.get("ref"),[i,d]=T.useState(""),[h,f]=T.useState(""),[g,v]=T.useState(""),[_,j]=T.useState(""),[w,k]=T.useState(!1),[M,S]=T.useState(!1),[E,D]=T.useState(null),[L,B]=T.useState(!1);T.useEffect(()=>{l&&o.mutate(l)},[l]);const $=ce=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ce),V=async ce=>{if(ce.preventDefault(),!(!i.trim()||!g.trim()||!r)){k(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:h.trim(),email:g.trim(),phone:_.trim(),shareToken:l}),S(!0),be.success("Thanks! The agent will be in touch soon.")}catch(ge){console.error("Lead submission error:",ge),be.error(`Failed to submit: ${ge.message||"Please try again"}`)}finally{k(!1)}}},W=(r==null?void 0:r.photos)||[],G=W.find(ce=>ce.is_primary)||W[0],J=()=>{E!==null&&D(E===0?W.length-1:E-1)},ne=()=>{E!==null&&D(E===W.length-1?0:E+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(ys,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ys,{className:"h-10 w-48 mb-6"}),e.jsx(ys,{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(ys,{className:"h-12 w-48"}),e.jsx(ys,{className:"h-6 w-full"}),e.jsx(ys,{className:"h-6 w-3/4"})]}),e.jsx(ys,{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(bo,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Tre,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Zn,{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(Y,{asChild:!0,children:e.jsx(bo,{to:"/public/listings",children:"Browse All Listings"})})]})]});const ie=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(Ih,{children:[e.jsxs("title",{children:[ie," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${CC[r.property_type]} in ${r.city}, ${r.state}. ${((ee=r.description)==null?void 0:ee.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:ie}),e.jsx("meta",{property:"og:description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${CC[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}`}),G&&e.jsx("meta",{property:"og:image",content:G.photo_url}),G&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${CC[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:ie}),e.jsx("meta",{name:"twitter:description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),G&&e.jsx("meta",{name:"twitter:image",content:G.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||`${CC[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:W.map(ce=>ce.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(bo,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Tre,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(bo,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(bi,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),W.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:()=>D(0),children:e.jsx("img",{src:G==null?void 0:G.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${CC[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:W.slice(1,5).map((ce,ge)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>D(ge+1),children:[e.jsx("img",{src:ce.photo_url,alt:`${r.property_address||r.city} - Photo ${ge+2} of ${W.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),ge===3&&W.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",W.length-5," more"]})]},ce.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(ct,{className:`${twt[r.status]} text-white border-0`,children:swt[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(Gi,{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(k1,{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(j1,{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(Tx,{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(xn,{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(ct,{variant:"secondary",children:[e.jsx(Ya,{className:"h-3 w-3 mr-1"}),CC[r.property_type]]}),r.lot_size&&e.jsxs(ct,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(ct,{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(Y,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(bn,{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(Oe,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs($e,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>B(!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(Wn,{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(Kl,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(Y,{onClick:()=>B(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(Kl,{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(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Wo,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs($e,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((oe=r.agent.brokerage)==null?void 0:oe.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Oe,{className:"border-primary",children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx($e,{children:M?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(zr,{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:V,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Be,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:ce=>d(ce.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Be,{id:"lastName",type:"text",placeholder:"Doe",value:h,onChange:ce=>f(ce.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"email",children:"Email *"}),e.jsx(Be,{id:"email",type:"email",placeholder:"you@example.com",value:g,onChange:ce=>v(ce.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"phone",children:"Phone"}),e.jsx(Be,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:ce=>j(ce.target.value)})]}),e.jsx(Y,{type:"submit",className:"w-full",disabled:w,children:w?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(js,{open:E!==null,onOpenChange:()=>D(null),children:e.jsxs(_s,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Ls,{className:"sr-only",children:e.jsx(Ps,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>D(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(Xr,{className:"h-5 w-5"})}),E!==null&&W[E]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:W[E].photo_url,alt:`Photo ${E+1}`,className:"w-full max-h-[80vh] object-contain"}),W.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:J,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(hc,{className:"h-6 w-6"})}),e.jsx("button",{onClick:ne,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(Ri,{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:[E+1," / ",W.length]})]})]})]})}),e.jsx(js,{open:L,onOpenChange:B,children:e.jsxs(_s,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(Ls,{className:"sr-only",children:e.jsx(Ps,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>B(!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(Xr,{className:"h-5 w-5"})}),((ue=r==null?void 0:r.video)==null?void 0:ue.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 nwt(){var o;const{slug:t}=wl(),{data:s,isLoading:r,error:n}=M7e(t);if(T.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),T.useEffect(()=>{s!=null&&s.id&&eo(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(ys,{className:"h-28 w-28 rounded-full"}),e.jsx(ys,{className:"h-6 w-48"}),e.jsx(ys,{className:"h-4 w-36"})]}),e.jsx(ys,{className:"h-12 w-full"}),e.jsx(ys,{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(Ih,{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(Kve,{card:s})]})}function CA({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=T.useState(0),[o,l]=T.useState(!1),i=T.useCallback(()=>{a(g=>(g+1)%t.length)},[t.length]),d=T.useCallback(()=>{a(g=>(g-1+t.length)%t.length)},[t.length]),h=T.useCallback(g=>{a(g)},[]);if(T.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 f=t[n];return e.jsxs("div",{className:$t("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.jsxs("div",{className:"absolute inset-0 transition-opacity duration-500",children:[e.jsx("img",{src:f.image_url,alt:f.title,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"})]}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-6 md:p-8 text-white",children:[e.jsx("h2",{className:"text-xl md:text-3xl font-bold mb-2 drop-shadow-lg",children:f.title}),f.description&&e.jsx("p",{className:"text-sm md:text-base text-white/90 mb-4 max-w-2xl drop-shadow",children:f.description}),f.link_url&&e.jsx("a",{href:f.link_url,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:e.jsx(Y,{variant:"secondary",className:"bg-white/90 hover:bg-white text-foreground font-semibold",children:f.link_text||"Learn More"})})]}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"ghost",size:"icon",className:$t("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(hc,{className:"h-6 w-6"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:$t("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(Ri,{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:()=>h(v),className:$t("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))})]})}function awt(t){return"EST"}function cP(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=awt();return`${r} ${n}`}function t5(t){const s=new Date,r=new Date(t),n=N4e(r,-15),a=N4e(r,30);return s>a?"ended":Ire(s,{start:r,end:a})?"live":Ire(s,{start:n,end:r})?"starting_soon":"upcoming"}function N1e(t){const s=t5(t);return s==="starting_soon"||s==="live"}const y5e=N1e,iwt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=T.useState(new Date);T.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>N1e(_.event_date));if(o.length===0)return null;const l=o[0],i=t5(l.event_date),d=s.find(_=>_.event_id===l.id),h=(d==null?void 0:d.zoom_join_url)||l.zoom_link,f=!!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(Ek,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(ca,{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 ${cP(new Date(l.event_date))}`:`Starts at ${cP(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:f?e.jsxs(Y,{onClick:()=>window.open(h,"_blank"),className:`${v.button} text-white gap-2`,children:[e.jsx(bn,{className:"h-4 w-4"}),g?"Join Now":"Join When Live"]}):e.jsxs(Y,{variant:"outline",onClick:r,className:`${v.outlineButton} gap-2`,children:[e.jsx(br,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var S1e="Progress",C1e=100,[owt]=Dc(S1e),[lwt,cwt]=owt(S1e),C9e=T.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=dwt,...l}=t;(a||a===0)&&!v5e(a)&&console.error(uwt(`${a}`,"Progress"));const i=v5e(a)?a:C1e;n!==null&&!_5e(n,i)&&console.error(hwt(`${n}`,"Progress"));const d=_5e(n,i)?n:null,h=Wre(d)?o(d,i):void 0;return e.jsx(lwt,{scope:r,value:d,max:i,children:e.jsx(Qr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Wre(d)?d:void 0,"aria-valuetext":h,role:"progressbar","data-state":A9e(d,i),"data-value":d??void 0,"data-max":i,...l,ref:s})})});C9e.displayName=S1e;var M9e="ProgressIndicator",T9e=T.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=cwt(M9e,r);return e.jsx(Qr.div,{"data-state":A9e(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});T9e.displayName=M9e;function dwt(t,s){return`${Math.round(t/s*100)}%`}function A9e(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Wre(t){return typeof t=="number"}function v5e(t){return Wre(t)&&!isNaN(t)&&t>0}function _5e(t,s){return Wre(t)&&!isNaN(t)&&t<=s&&t>=0}function uwt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${C1e}\`.`}function hwt(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 ${C1e} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var E9e=C9e,mwt=T9e;const rl=T.forwardRef(({className:t,value:s,...r},n)=>e.jsx(E9e,{ref:n,className:$t("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(mwt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));rl.displayName=E9e.displayName;function pwt(){const{user:t,isBrokerageManager:s}=Ys(),[r,n]=T.useState([]),[a,o]=T.useState([]),[l,i]=T.useState(!1),[d,h]=T.useState(!0),f=s?"brokerage_manager":"agent";T.useEffect(()=>{if(!(t!=null&&t.id)){h(!1);return}g()},[t==null?void 0:t.id,f]);const g=async()=>{if(t!=null&&t.id)try{const{data:D,error:L}=await Z.from("onboarding_checklist_items").select("*").eq("target_role",f).eq("is_active",!0).order("sort_order");if(L)throw L;const{data:B,error:$}=await Z.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if($)throw $;const{data:V,error:W}=await Z.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(W)throw W;n(D||[]),o(B||[]),i(!!V),D&&D.length>0&&await v(D,B||[])}catch(D){console.error("Error fetching checklist data:",D)}finally{h(!1)}},v=async(D,L)=>{var Ue,De;if(!(t!=null&&t.id))return;const B=L.map(Ge=>Ge.item_id),$=D.filter(Ge=>!B.includes(Ge.id));if($.length===0)return;const[V,W,G,J,ne,ie,ee,de,oe,ue,ce,ge,Te,ve,ye]=await Promise.all([Z.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),Z.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),Z.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),Z.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),Z.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),Z.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),Z.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),Z.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),Z.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),Z.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),Z.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),Z.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),Z.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),Z.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),Z.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),Se={},Ke=(Ue=V.data)==null?void 0:Ue.brokerage_id;Se.share_resource=(W.count||0)>0,Se.post_community=(G.count||0)>0,Se.register_event=(J.count||0)>0,Se.view_template=(ne.count||0)>0,Se.watch_academy=(ie.count||0)>0,Se.use_toolbox=(ee.count||0)>0,Se.launch_app=(de.count||0)>0,Se.add_contact=(oe.count||0)>0,Se.create_video=(ue.count||0)>0,Se.complete_touch=(ce.count||0)>0,Se.add_transaction=(ge.count||0)>0,Se.add_listing=(Te.count||0)>0,Se.add_deal=(ye.count||0)>0;const Ae=((De=ve.data)==null?void 0:De.map(Ge=>Ge.id))||[],Ee=[];Ke?Ee.push(Z.from("profiles").select("id").eq("brokerage_id",Ke).neq("id",t.id).then(Ge=>{var wt;Se.add_agent=(((wt=Ge.data)==null?void 0:wt.length)||0)>0})):Se.add_agent=!1,Ae.length>0?(Ee.push(Z.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Ae).then(Ge=>{Se.add_plan=(Ge.count||0)>0})),Ee.push(Z.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Ae).then(Ge=>{Se.schedule_popby=(Ge.count||0)>0}))):(Se.add_plan=!1,Se.schedule_popby=!1),await Promise.all(Ee);const He=$.filter(Ge=>Se[Ge.action_type]);if(He.length>0){const Ge=He.map(Ie=>({user_id:t.id,item_id:Ie.id})),{error:wt}=await Z.from("onboarding_checklist_progress").upsert(Ge,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!wt){const Ie=He.map(st=>({item_id:st.id,completed_at:new Date().toISOString()}));o(st=>[...st,...Ie])}}},_=async D=>{if(t!=null&&t.id)try{const{error:L}=await Z.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:D});if(L)throw L;o(B=>[...B,{item_id:D,completed_at:new Date().toISOString()}])}catch(L){console.error("Error marking item complete:",L)}},j=async()=>{if(t!=null&&t.id)try{const{error:D}=await Z.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(D)throw D;i(!0)}catch(D){console.error("Error dismissing checklist:",D)}},w=a.length,k=r.length,M=k>0&&w>=k,S=k>0?w/k*100:0;return{items:r,progress:a,isDismissed:l,loading:d,completedCount:w,totalCount:k,isComplete:M,progressPercentage:S,isItemComplete:D=>a.some(L=>L.item_id===D),markComplete:_,dismiss:j,refetch:g}}const fwt={add_agent:e.jsx(br,{className:"h-4 w-4"}),share_resource:e.jsx(Kc,{className:"h-4 w-4"}),post_community:e.jsx(Eo,{className:"h-4 w-4"}),register_event:e.jsx(xn,{className:"h-4 w-4"}),view_template:e.jsx(Av,{className:"h-4 w-4"}),watch_academy:e.jsx(C1,{className:"h-4 w-4"}),use_toolbox:e.jsx(a0,{className:"h-4 w-4"}),launch_app:e.jsx(yE,{className:"h-4 w-4"}),add_deal:e.jsx(Sx,{className:"h-4 w-4"}),add_listing:e.jsx(Zn,{className:"h-4 w-4"})},gwt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function xwt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:h}=pwt(),f=Yr(),[g,v]=T.useState(!0);return r||s||a===0||o?null:e.jsxs(Oe,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(Ht,{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(Cx,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Gt,{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(Y,{variant:"ghost",size:"sm",onClick:()=>v(!g),className:"h-8 w-8 p-0",children:g?e.jsx(kx,{className:"h-4 w-4"}):e.jsx(Gc,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:h,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(Xr,{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(rl,{value:l,className:"h-2"})]})]}),g&&e.jsx($e,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(_=>{const j=i(_.id);return e.jsxs("div",{className:$t("flex items-start gap-3 p-3 rounded-lg transition-colors",j?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(j)return;const w=gwt[_.action_type];w?f(w):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:j?e.jsx(oi,{className:"h-5 w-5 text-primary"}):e.jsx(Td,{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:fwt[_.action_type]||e.jsx(Td,{className:"h-4 w-4"})}),e.jsx("span",{className:$t("font-medium",j&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:$t("text-sm text-muted-foreground mt-1",j&&"line-through"),children:_.description})]})]},_.id)})})})]})}const Ag=()=>zt({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await Z.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),of=t=>{const s=lo(),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 h=i??[];if(o.push(...h),h.length{let a=Z.from("innercircle_contacts").select(` *, tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).order("created_at",{ascending:!1}).order("first_name");return await n(a)},enabled:!!s})},ywt=t=>zt({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await Z.from("innercircle_contacts").select(` *, 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}),I9e=()=>{const t=lo();return zt({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await Z.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})},M1e=()=>{const t=vs(),s=lo();return Wt({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 Z.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:d}=await Z.from("innercircle_contact_tags").insert(n.map(h=>({contact_id:l.id,relationship_type_id:h})));if(d)throw d}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:"Contact created successfully"})},onError:r=>{pn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},P9e=()=>{const t=vs();return Wt({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 Z.from("innercircle_contacts").update(l).eq("id",s).select().single();if(d)throw d;if(n!==void 0&&(await Z.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:h}=await Z.from("innercircle_contact_tags").insert(n.map(f=>({contact_id:s,relationship_type_id:f})));if(h)throw h}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:"Contact updated successfully"})},onError:s=>{pn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},T1e=()=>{const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:"Contact deleted successfully"})},onError:s=>{pn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},A1e=()=>zt({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await Z.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),vwt=t=>zt({queryKey:["action-scripts",t],queryFn:async()=>{let s=Z.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),_wt=()=>zt({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await Z.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),bwt=()=>{const t=vs(),s=lo();return Wt({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await Z.from("touchpoint_plans").insert({name:r,description:n,owner_user_id:s,active:!0,is_template:!1}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan created successfully"})},onError:r=>{pn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},wwt=()=>{const t=vs(),s=lo();return Wt({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await Z.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 Z.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(f=>({plan_id:l.id,month_number:f.month_number,action_type_id:f.action_type_id,default_script_id:f.default_script_id,notes:f.notes})),{error:h}=await Z.from("touchpoint_plan_items").insert(d);if(h)throw h}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{pn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},jwt=()=>{const t=vs();return Wt({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await Z.from("touchpoint_plans").update({name:r,description:n}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan updated successfully"})}})},kwt=()=>{const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan deleted successfully"})}})},Nwt=()=>{const t=vs();return Wt({mutationFn:async({planId:s,items:r})=>{if(await Z.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await Z.from("touchpoint_plan_items").insert(r.map(a=>({plan_id:s,month_number:a.month_number,action_type_id:a.action_type_id,default_script_id:a.default_script_id||null,notes:a.notes})));if(n)throw n}},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),pn({title:"Plan schedule updated"})}})},Swt=()=>{const t=vs();return Wt({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await Z.auth.getUser(),{data:i,error:d}=await Z.from("action_scripts").insert({action_type_id:s,title:r,script_body:n,email_subject:a||null,tone:o||null,active:!0,user_id:l==null?void 0:l.id}).select().single();if(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),pn({title:"Script created successfully"})},onError:s=>{pn({title:"Error creating script",description:s.message,variant:"destructive"})}})},Cwt=()=>{const t=lo();return zt({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await Z.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},Mwt=()=>{const t=vs(),s=lo();return Wt({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await Z.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await Z.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await Z.from("user_plan_enrollments").insert({owner_user_id:s,plan_id:r,relationship_type_id:n,active:!0,start_date:new Date().toISOString().split("T")[0]});if(l)throw l}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-plan-enrollments"]}),pn({title:"Plan enrollment updated"})}})},ooe=(t=7)=>{const s=lo();return zt({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await Z.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},L9e=()=>{const t=lo();return zt({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await Z.from("contact_touch_logs").select("contact_id, completed_at").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})},Twt=(t=90)=>{const{data:s}=of(),{data:r}=L9e();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=vs(),s=lo();return Wt({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o})=>{const{data:l,error:i}=await Z.from("contact_touch_logs").insert({owner_user_id:s,contact_id:r,action_type_id:n,script_used_id:a,notes:o,completed_at:new Date().toISOString()}).select().single();if(i)throw i;return l},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-touch-logs"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),t.invalidateQueries({queryKey:["today-actions"]}),pn({title:"Action completed!"})}})},O9e="agentos_weekly_touch_goal",b5e=20,Gre=()=>{if(typeof window>"u")return b5e;const t=localStorage.getItem(O9e);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return b5e},R9e=t=>{localStorage.setItem(O9e,t.toString())},F9e=()=>{const{data:t}=ooe(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=Gre();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},Awt=()=>{const t=lo();return zt({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await Z.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})},Ewt=()=>{const t=vs();return lo(),Wt({mutationFn:async()=>{const{data:s}=await Z.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await Z.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await Z.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(h=>h.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 Z.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&pn({title:`${s} contact(s) enrolled in plans`})}})},z9e=()=>{const t=lo(),{data:s}=Awt(),{data:r}=ooe(30);return zt({queryKey:["today-actions",t,s==null?void 0:s.length,r==null?void 0:r.length],queryFn:async()=>{var j;if(!s||s.length===0)return[];const{data:n}=await Z.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(w=>w.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),d=new Set((r==null?void 0:r.filter(w=>new Date(w.completed_at)>=i).map(w=>`${w.contact_id}-${w.action_type_id}`))||[]);for(const w of s){if(!((j=w.plan)!=null&&j.items)||w.plan.items.length===0||!w.contact||a.has(w.contact_id))continue;const k=new Date(w.cycle_start_date),S=Math.floor((o.getTime()-k.getTime())/(30.44*24*60*60*1e3))%12+1,E=w.plan.items.find(D=>D.month_number===S);if(E&&E.action_type){const D=`${w.contact_id}-${E.action_type_id}`;if(!d.has(D)){const{data:L}=await Z.from("relationship_types").select("name").eq("id",w.relationship_type_id).single();l.push({contact:w.contact,actionType:E.action_type,script:E.default_script||void 0,planName:w.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:S})}}}const h=5,f=o.getDate(),g=l.sort((w,k)=>w.contact.first_name.localeCompare(k.contact.first_name)),v=(f-1)%Math.max(1,g.length);return[...g.slice(v),...g.slice(0,v)].slice(0,h)},enabled:!!t&&!!s})};function Iwt(){const t=Yr(),{data:s,isLoading:r}=z9e(),{data:n}=of(),a=F9e(),[o,l]=T.useState(Gre()),[i,d]=T.useState(""),[h,f]=T.useState(!1);T.useEffect(()=>{l(Gre())},[]);const g=()=>{const B=parseInt(i,10);if(isNaN(B)||B<1){pn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(B),R9e(B),f(!1),pn({title:"Goal updated",description:`Weekly touch goal set to ${B}`})},v=()=>{d(o.toString()),f(!0)},_=ip(new Date),j=Ul(_,7),w=B=>{if(!B)return null;const $=B.split(/[-/T]/);if($.length<3)return null;const V=parseInt($[1],10)-1,W=parseInt($[2],10);return isNaN(V)||isNaN(W)?null:new Date(_.getFullYear(),V,W)},k=(n==null?void 0:n.map(B=>{const $=w(B.birthday),V=w(B.home_anniversary),W=[];return $&&$>=_&&$<=j&&W.push({contact:B,type:"birthday",date:$,isToday:Vl($,_)}),V&&V>=_&&V<=j&&W.push({contact:B,type:"anniversary",date:V,isToday:Vl(V,_)}),W}).flat().sort((B,$)=>B.date.getTime()-$.date.getTime()).slice(0,3))||[],M=(n==null?void 0:n.filter(B=>{const $=w(B.birthday),V=w(B.home_anniversary);return $&&Vl($,_)||V&&Vl(V,_)}).length)||0,S=(s==null?void 0:s.length)||0,E=M+S,D=(a==null?void 0:a.actionsThisWeek)||0,L=(a==null?void 0:a.streak)||0;return r?e.jsx(Oe,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx($e,{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(Oe,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Ht,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:L>0&&e.jsxs(ct,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(Ym,{className:"h-3 w-3"}),L," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[E>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[E," tasks"]})," for today"]}):"No tasks for today",D>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:D})," touches this week"]})]})]}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Y,{size:"sm",variant:"outline",className:"gap-1.5",onClick:B=>{B.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(Zc,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(Y,{size:"sm",variant:"outline",className:"gap-1.5",onClick:B=>{B.stopPropagation(),t("/mission-control")},children:[e.jsx(Ha,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(Y,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:B=>{B.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(Wn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(Y,{size:"sm",variant:"outline",className:"gap-1.5",onClick:B=>{B.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(Gi,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(Y,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:B=>{B.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(Sx,{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(hm,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(js,{open:h,onOpenChange:f,children:[e.jsx(Fi,{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(Ic,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(_s,{className:"sm:max-w-[360px]",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Set Weekly Goal"}),e.jsx(en,{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(je,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(Be,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:B=>d(B.target.value),placeholder:"20",onKeyDown:B=>{B.key==="Enter"&&g()}})]}),e.jsx(Y,{onClick:g,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:D}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(rl,{value:Math.min(D/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),D>=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."]}),D0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-D," more to hit your weekly goal"]})]}),k.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(Gm,{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:k.map((B,$)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${B.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:V=>{V.stopPropagation(),t(`/mission-control/contacts/${B.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[B.type==="birthday"?e.jsx(Gm,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(Zn,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[B.contact.first_name," ",B.contact.last_name]}),B.isToday&&e.jsx(ct,{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:B.isToday?B.type==="birthday"?"🎂":"🏠":Bs(B.date,"EEE, MMM d")}),e.jsx(Ri,{className:"h-3 w-3"})]})]},`${B.contact.id}-${B.type}-${$}`))})]}),e.jsxs(Y,{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(qi,{className:"h-4 w-4"})]})]})]})}const B9e=()=>zt({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await Z.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),$9e=t=>{const{user:s,brokerageId:r}=Ys();return zt({queryKey:["listings",t,r],queryFn:async()=>{let n=Z.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 Z.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const d=i.map(g=>g.id);let h=Z.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&&(h=h.eq("status",t.status)),t!=null&&t.propertyType&&(h=h.eq("property_type",t.propertyType)),t!=null&&t.city&&(h=h.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(h=h.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(h=h.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(h=h.eq("open_to_referrals",!0));const{data:f}=await h;if(f){const g=new Set(l.map(_=>_.id)),v=f.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}})},U9e=()=>{const{user:t}=Ys();return zt({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},q9e=t=>{const{user:s}=Ys();return zt({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await Z.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 Z.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},Pwt=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await Z.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"]})}})},Lwt=()=>{const t=vs();return Wt({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await Z.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"]})}})},Dwt=()=>{const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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]})}})},V9e=()=>{const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},Owt=()=>{const t=vs();return Wt({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await Z.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"]})}})},Rwt=()=>{const t=vs();return Wt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await Z.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"]})}})},Fwt=()=>{const{user:t}=Ys();return zt({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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})},H9e=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await Z.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await Z.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await Z.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},W9e=t=>{const{user:s}=Ys();return zt({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await Z.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},zwt=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await Z.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await Z.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await Z.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},Bwt=t=>{const{user:s}=Ys();return zt({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await Z.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},$wt=()=>{const{user:t}=Ys();return Wt({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await Z.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},Uwt=()=>{const{user:t}=Ys();return zt({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([Z.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),Z.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})},qwt=()=>{const t=vs(),{user:s}=Ys();return Wt({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 Z.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"]})}})},Vwt=()=>zt({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await Z.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 h;const i=l.sharing_agent_id;if(!i)return;const d=s.get(i);d?d.count++:s.set(i,{name:((h=l.profiles)==null?void 0:h.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 Z.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}}}),Hwt=()=>{const{user:t,brokerageId:s}=Ys();return zt({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await Z.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 Z.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})},E1e=({className:t,variant:s="default"})=>e.jsx(ct,{variant:"outline",className:$t("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"}),Wwt={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"},Gwt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function Kwt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Zwt(){const t=Yr(),{data:s,isLoading:r}=B9e(),{data:n,isLoading:a}=$9e({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(f=>f.is_approved&&f.is_public))||[],l=o.filter(f=>f.is_featured),i=o.filter(f=>!f.is_featured),d=[...l,...i].slice(0,6),h=r||a;return!h&&!s?null:h?e.jsx(Oe,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx($e,{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(E1e,{})]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(qi,{className:"h-4 w-4"})]})]}),d.length===0?e.jsx(Oe,{className:"bg-muted/30 border-dashed",children:e.jsx($e,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Zn,{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(Y,{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(f=>{var v,_;const g=((v=f.photos)==null?void 0:v.find(j=>j.is_primary))||((_=f.photos)==null?void 0:_[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${f.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:`${f.city}, ${f.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(Zn,{className:"h-8 w-8 text-muted-foreground/50"})}),f.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(ct,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(qn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(ct,{className:`text-[10px] px-1.5 py-0.5 ${Wwt[f.status]}`,children:Gwt[f.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:Kwt(f.price)}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[f.city,", ",f.state]}),(f.bedrooms||f.bathrooms)&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[f.bedrooms&&`${f.bedrooms} bed`,f.bedrooms&&f.bathrooms&&" · ",f.bathrooms&&`${f.bathrooms} bath`]})]})]},f.id)})})]})}function G9e(t=10,s){return zt({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await Z.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 Z.from("profiles").select("id").eq("brokerage_id",s);a=new Set((v==null?void 0:v.map(_=>_.id))||[])}const{data:o,error:l}=await Z.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),h=d.map(v=>v.user_id),{data:f}=await Z.from("profiles").select("id, name").in("id",h),g=new Map((f==null?void 0:f.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 K9e(t){return zt({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await Z.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function Z9e(t){return zt({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Y9e(t,s){return zt({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await Z.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await Z.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 Z.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 Z.from("profiles").select("id").eq("brokerage_id",s),h=new Set((d==null?void 0:d.map(f=>f.id))||[]);i=i.filter(f=>h.has(f.user_id))}return i.length+1},enabled:!!t})}function Ywt(){const{user:t,brokerageId:s,isAdmin:r}=Ys();Yr();const n=!!s,[a,o]=T.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:d}=G9e(5,l()),{data:h}=K9e(t==null?void 0:t.id),{data:f}=Y9e(t==null?void 0:t.id,l()),{data:g}=Z9e(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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx($e,{children:e.jsx("div",{className:"space-y-2",children:[...Array(v?5:3)].map((w,k)=>e.jsx(ys,{className:"h-10 w-full"},k))})})]});const j=w=>w===0?e.jsx(vo,{className:"h-4 w-4 text-yellow-500 mx-auto"}):w===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):w===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:w+1});if(v){const w=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"pb-2",children:[e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4 text-yellow-500"}),_()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(Y,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(Y,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs($e,{children:[!r&&h&&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:["#",f||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:h.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:h.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[w.map((k,M)=>{var S,E,D;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${k.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":M===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:j(M)}),e.jsx(fn,{className:"h-6 w-6",children:e.jsx(gn,{className:"text-xs",children:((E=(S=k.profile)==null?void 0:S.name)==null?void 0:E.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((D=k.profile)==null?void 0:D.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:k.total_points})]},k.user_id)}),w.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(bo,{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(oo,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Ri,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx($e,{children:h?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:h.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:h.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(Ym,{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:[h.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(nc,{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(w=>e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-600 border border-yellow-500/20",children:w.badge_name},w.id)),g.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",g.length-4," more"]})]})]}),e.jsxs(bo,{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(oo,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Ri,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(qn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(bo,{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(oo,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(Ri,{className:"h-4 w-4"})]})]})})]})}const loe=()=>zt({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await Z.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),Xwt=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{data:n,error:a}=await Z.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"]}),be.success("Lead source added")},onError:r=>{be.error("Failed to add lead source"),console.error(r)}})},I1e=(t,s)=>{const{user:r,isAdmin:n}=Ys(),a=n&&s?s:r==null?void 0:r.id;return zt({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=Z.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})},X9e=t=>{const{user:s,isAdmin:r}=Ys(),n=r&&t?t:s==null?void 0:s.id;return zt({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await Z.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})},coe=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{data:n,error:a}=await Z.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"]}),be.success("Transaction added")},onError:r=>{be.error("Failed to add transaction"),console.error(r)}})},Qwt=()=>{const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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"]}),be.success("Transaction updated")},onError:s=>{be.error("Failed to update transaction"),console.error(s)}})},Jwt=()=>{const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),be.success("Transaction deleted")},onError:s=>{be.error("Failed to delete transaction"),console.error(s)}})},Q9e=(t,s)=>{const{user:r,isAdmin:n}=Ys(),a=n&&s?s:r==null?void 0:r.id;return zt({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await Z.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},e2t=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{data:n,error:a}=await Z.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]}),be.success("Goals saved")},onError:r=>{be.error("Failed to save goals"),console.error(r)}})},doe=()=>{const{user:t}=Ys();return zt({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},t2t=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{data:n,error:a}=await Z.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"]}),be.success("Settings saved")},onError:r=>{be.error("Failed to save settings"),console.error(r)}})},J9e=(t,s)=>{const{data:r,isLoading:n}=I1e(t,s),{data:a,isLoading:o}=X9e(s),{data:l}=doe(),i=(l==null?void 0:l.show_commission)??!0,d=h=>{if(!h||h.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const f=h.filter(D=>D.transaction_type==="buyer").length,g=h.filter(D=>D.transaction_type==="seller").length,v=h.reduce((D,L)=>D+Number(L.sale_price),0),_=h.reduce((D,L)=>D+(Number(L.commission_amount)||0),0),j={};h.forEach(D=>{var B;const L=((B=D.lead_source)==null?void 0:B.name)||"Unknown";j[L]=(j[L]||0)+1});const w=Object.entries(j).map(([D,L])=>({name:D,count:L})).sort((D,L)=>L.count-D.count),k=w[0]||null,M={};h.forEach(D=>{const L=new Date(D.close_date).toLocaleString("default",{month:"short"});M[L]=(M[L]||0)+1});const E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(D=>({month:D,count:M[D]||0}));return{totalTransactions:h.length,buyerCount:f,sellerCount:g,totalVolume:v,averagePrice:h.length>0?v/h.length:0,totalCommission:i?_:0,topLeadSource:k,transactionsByMonth:E,leadSourceBreakdown:w}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},s2t=()=>{const{isAdmin:t}=Ys();return zt({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await Z.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 Z.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},Lv={recency:40,touchpoints:30,transactions:20},w5e={warm:70,cooling:40};function r2t(t){return t===null?0:t<=14?Lv.recency:t<=30?Lv.recency*.85:t<=60?Lv.recency*.65:t<=90?Lv.recency*.4:t<=180?Lv.recency*.2:Lv.recency*.05}function n2t(t){const s=Math.min(t/12,1);return Math.round(Lv.touchpoints*s)}function a2t(t){return t?Lv.transactions:0}function i2t(){return 0}function o2t(t){return t>=w5e.warm?"warm":t>=w5e.cooling?"cooling":"at-risk"}function P1e(){const{data:t,isLoading:s}=of(),{data:r}=L9e(),{data:n}=ooe(365),{data:a}=X9e(),o=T.useMemo(()=>{if(!t)return[];const i=new Date,d=nBe(i,12),h={};n==null||n.forEach(g=>{new Date(g.completed_at)>=d&&(h[g.contact_id]=(h[g.contact_id]||0)+1)});const f=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?bg(i,new Date(v)):null,j=h[g.id]||0,w=f.has(g.id),k=r2t(_),M=n2t(j),S=a2t(w),E=i2t(),D=Math.round(k+M+S+E),L={score:D,status:o2t(D),breakdown:{recency:Math.round(k),touchpoints:Math.round(M),transactions:Math.round(S),referrals:Math.round(E)},lastTouchDate:v,daysSinceTouch:_,touchCountLast12Months:j,hasTransaction:w};return{...g,relationshipScore:L}})},[t,r,n,a]),l=T.useMemo(()=>{const i=o.filter(v=>v.relationshipScore.status==="warm").length,d=o.filter(v=>v.relationshipScore.status==="cooling").length,h=o.filter(v=>v.relationshipScore.status==="at-risk").length,f=o.length,g=f>0?Math.round(o.reduce((v,_)=>v+_.relationshipScore.score,0)/f):0;return{warm:i,cooling:d,atRisk:h,total:f,averageScore:g}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function e$e(){const t=Yr(),{stats:s,contactsWithScores:r,isLoading:n}=P1e();if(n)return e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(ys,{className:"h-5 w-40"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsx(ys,{className:"h-20 w-full"}),e.jsx(ys,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs($e,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(Y,{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,h)=>d.relationshipScore.score-h.relationshipScore.score).slice(0,3);return e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Jd,{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($e,{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(rl,{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(rl,{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(rl,{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(Pk,{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(Ri,{className:"h-3 w-3"})]})]},d.id))})]}),e.jsxs(Y,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(Ri,{className:"h-4 w-4 ml-1"})]})]})]})}const l2t=()=>{var oe;const{user:t,isAdmin:s}=Ys(),r=Yr(),[n,a]=T.useState([]),[o,l]=T.useState([]),[i,d]=T.useState([]),[h,f]=T.useState([]),[g,v]=T.useState([]),[_,j]=T.useState([]),[w,k]=T.useState(new Set),[M,S]=T.useState([]),[E,D]=T.useState([]),[L,B]=T.useState([]),[$,V]=T.useState(null),[W,G]=T.useState(!0);T.useEffect(()=>{J()},[t]);const J=async()=>{var ue,ce,ge,Te,ve;try{const[ye,Se,Ke,Ae,Ee,He,Ue,De,Ge,wt,Ie]=await Promise.all([Z.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),Z.from("app_tiles").select("*").order("name"),Z.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),Z.from("events").select("*").order("event_date",{ascending:!0}),Z.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),Z.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),Z.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),Z.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),Z.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),Z.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),Z.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(ue=Ie.data)!=null&&ue.name&&V(Ie.data.name);const st=((ce=ye.data)==null?void 0:ce.map(at=>at.tag))||[],he=new Set(((ge=Ke.data)==null?void 0:ge.map(at=>at.app_id))||[]);k(he);const et=(((Te=Se.data)==null?void 0:Te.filter(at=>!at.required_tags||at.required_tags.length===0?!0:at.required_tags.some(Fe=>st.includes(Fe))))||[]).sort((at,Fe)=>at.name==="LevelUp Members Portal"?-1:Fe.name==="LevelUp Members Portal"?1:0);a(et.slice(0,6));const Ye=((ve=Ae.data)==null?void 0:ve.filter(at=>t5(at.event_date)!=="ended"))||[];l(Ye.slice(0,4)),S(Ee.data||[]),d(He.data||[]),f(Ue.data||[]),v(De.data||[]),j(Ge.data||[]);const ke=wt.data||[];D(ke.filter(at=>at.placement==="top")),B(ke.filter(at=>at.placement==="between"))}catch(ye){console.error("Error loading dashboard:",ye),be.error("Failed to load dashboard data")}finally{G(!1)}},ne=async ue=>{var ge;const ce=window.open("about:blank","_blank");try{await Z.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:ue.app_id,app_name:ue.name,user_agent:navigator.userAgent});const{data:Te,error:ve}=await Z.functions.invoke("sso-launch",{body:{app_id:ue.app_id}});if(ve)throw ve;Te!=null&&Te.redirect_url?ce&&!ce.closed?(ce.location.href=Te.redirect_url,(ge=ce.focus)==null||ge.call(ce)):window.location.assign(Te.redirect_url):(ce==null||ce.close(),be.error("Launch link unavailable"))}catch(Te){ce==null||ce.close(),console.error("Error launching app:",Te),be.error("Failed to launch app")}},ie=ue=>M==null?void 0:M.some(ce=>ce.event_id===ue),ee=ue=>{const ce=M==null?void 0:M.find(ge=>ge.event_id===ue);return ce==null?void 0:ce.zoom_join_url};if(W)return e.jsx(Vs,{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=ue=>L.filter(ce=>ce.section_after===ue);return e.jsxs(Vs,{title:"Dashboard",children:[e.jsx(iwt,{events:o,registrations:M,onNavigateToEvents:()=>r("/events")}),E.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(CA,{banners:E})}),e.jsx(xwt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",($||((oe=t==null?void 0:t.user_metadata)==null?void 0:oe.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(Iwt,{}),e.jsx(e$e,{}),e.jsx(Ywt,{})]}),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(Y,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(qi,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Oe,{className:"bg-muted/30 border-dashed",children:e.jsx($e,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(xn,{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(ue=>{const ce=ie(ue.id),ge=ee(ue.id)||ue.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 ${y5e(ue.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[y5e(ue.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(Ek,{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(ue.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(ue.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:ue.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(ue.event_date))," at ",cP(new Date(ue.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:ce?e.jsxs(Y,{size:"sm",variant:"default",className:"gap-1",onClick:Te=>{Te.stopPropagation(),window.open(ge,"_blank")},children:[e.jsx(bn,{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(Ri,{className:"h-4 w-4"})]})})]},ue.id)})})]}),de("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(CA,{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(Y,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(qi,{className:"h-4 w-4"})]})]}),g.length===0?e.jsx(Oe,{className:"bg-muted/30 border-dashed",children:e.jsx($e,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Om,{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(ue=>e.jsxs("div",{onClick:()=>r(`/academy/${ue.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:[ue.thumbnail_url?e.jsx("img",{src:ue.thumbnail_url,alt:ue.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(Om,{className:"h-8 w-8 text-muted-foreground/50"})}),ue.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:ue.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:ue.title})})]},ue.id))})]}),de("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(CA,{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(Y,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(qi,{className:"h-4 w-4"})]})]}),h.length===0?e.jsx(Oe,{className:"bg-muted/30 border-dashed",children:e.jsx($e,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(om,{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:h.map(ue=>e.jsxs("div",{onClick:()=>r(`/toolbox/${ue.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:ue.featured_image_url?e.jsx("img",{src:ue.featured_image_url,alt:ue.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(om,{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:ue.name})})]},ue.id))})]}),de("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(CA,{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(Y,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(qi,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Oe,{className:"bg-muted/30 border-dashed",children:e.jsx($e,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(S1,{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(ue=>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:ue.preview_image_url?e.jsx("img",{src:ue.preview_image_url,alt:ue.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(S1,{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:ue.name})})]},ue.id))})]}),de("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(CA,{banners:de("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(Zwt,{})}),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(Y,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(qi,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Oe,{className:"bg-muted/30 border-dashed",children:e.jsx($e,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ug,{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(ue=>{const ce=w.has(ue.id);return e.jsxs("div",{onClick:()=>ne(ue),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:ue.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:ue.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ue.description})]}),ce&&e.jsx(ug,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},ue.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(Y,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(qi,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(Oe,{className:"bg-muted/30 border-dashed",children:e.jsx($e,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Sn,{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(ue=>e.jsxs("div",{onClick:()=>window.open(ue.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:ue.preview_image_url?e.jsx("img",{src:ue.preview_image_url,alt:ue.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(Sn,{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:ue.name}),ue.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:ue.description})]})]},ue.id))})]})]})};var t$e="AlertDialog",[c2t]=Dc(t$e,[_ze]),N0=_ze(),s$e=t=>{const{__scopeAlertDialog:s,...r}=t,n=N0(s);return e.jsx(Eie,{...n,...r,modal:!0})};s$e.displayName=t$e;var d2t="AlertDialogTrigger",r$e=T.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=N0(r);return e.jsx(Hve,{...a,...n,ref:s})});r$e.displayName=d2t;var u2t="AlertDialogPortal",n$e=t=>{const{__scopeAlertDialog:s,...r}=t,n=N0(s);return e.jsx(Iie,{...n,...r})};n$e.displayName=u2t;var h2t="AlertDialogOverlay",a$e=T.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=N0(r);return e.jsx(B3,{...a,...n,ref:s})});a$e.displayName=h2t;var s5="AlertDialogContent",[m2t,p2t]=c2t(s5),f2t=sOe("AlertDialogContent"),i$e=T.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=N0(r),l=T.useRef(null),i=ba(s,l),d=T.useRef(null);return e.jsx(Bft,{contentName:s5,titleName:o$e,docsSlug:"alert-dialog",children:e.jsx(m2t,{scope:r,cancelRef:d,children:e.jsxs($3,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:kr(a.onOpenAutoFocus,h=>{var f;h.preventDefault(),(f=d.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:h=>h.preventDefault(),onInteractOutside:h=>h.preventDefault(),children:[e.jsx(f2t,{children:n}),e.jsx(x2t,{contentRef:l})]})})})});i$e.displayName=s5;var o$e="AlertDialogTitle",l$e=T.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=N0(r);return e.jsx(L6,{...a,...n,ref:s})});l$e.displayName=o$e;var c$e="AlertDialogDescription",d$e=T.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=N0(r);return e.jsx(D6,{...a,...n,ref:s})});d$e.displayName=c$e;var g2t="AlertDialogAction",u$e=T.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=N0(r);return e.jsx(Pie,{...a,...n,ref:s})});u$e.displayName=g2t;var h$e="AlertDialogCancel",m$e=T.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=p2t(h$e,r),o=N0(r),l=ba(s,a);return e.jsx(Pie,{...o,...n,ref:l})});m$e.displayName=h$e;var x2t=({contentRef:t})=>{const s=`\`${s5}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${s5}\` by passing a \`${c$e}\` 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 \`${s5}\`. 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 T.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},y2t=s$e,v2t=r$e,_2t=n$e,p$e=a$e,f$e=i$e,g$e=u$e,x$e=m$e,y$e=l$e,v$e=d$e;const Ec=y2t,sm=v2t,b2t=_2t,_$e=T.forwardRef(({className:t,...s},r)=>e.jsx(p$e,{className:$t("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}));_$e.displayName=p$e.displayName;const ac=T.forwardRef(({className:t,...s},r)=>e.jsxs(b2t,{children:[e.jsx(_$e,{}),e.jsx(f$e,{ref:r,className:$t("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})]}));ac.displayName=f$e.displayName;const ic=({className:t,...s})=>e.jsx("div",{className:$t("flex flex-col space-y-2 text-center sm:text-left",t),...s});ic.displayName="AlertDialogHeader";const oc=({className:t,...s})=>e.jsx("div",{className:$t("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});oc.displayName="AlertDialogFooter";const lc=T.forwardRef(({className:t,...s},r)=>e.jsx(y$e,{ref:r,className:$t("text-lg font-semibold",t),...s}));lc.displayName=y$e.displayName;const cc=T.forwardRef(({className:t,...s},r)=>e.jsx(v$e,{ref:r,className:$t("text-sm text-muted-foreground",t),...s}));cc.displayName=v$e.displayName;const Hl=T.forwardRef(({className:t,...s},r)=>e.jsx(g$e,{ref:r,className:$t(rP(),t),...s}));Hl.displayName=g$e.displayName;const dc=T.forwardRef(({className:t,...s},r)=>e.jsx(x$e,{ref:r,className:$t(rP({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));dc.displayName=x$e.displayName;const w2t=[{key:"contacts",label:"Contacts",icon:Ha,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:Nk,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:om,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:Wn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Zn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:jE,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Gi,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:Zm,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:Yy,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Gp,description:"Create and manage smart presentations"}];function j2t(){var $;const{user:t}=Ys(),[s,r]=T.useState([]),[n,a]=T.useState(!0),[o,l]=T.useState(!1),[i,d]=T.useState(!1),[h,f]=T.useState(null),[g,v]=T.useState({email:"",name:"",password:""}),[_,j]=T.useState("create"),[w,k]=T.useState(!1),[M,S]=T.useState(null);T.useEffect(()=>{t&&E()},[t]);const E=async()=>{if(t){a(!0);try{const{data:V,error:W}=await Z.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(W)throw W;if(V&&V.length>0){const G=V.map(ie=>ie.assistant_id),{data:J}=await Z.from("profiles").select("id, name, email").in("id",G),ne=V.map(ie=>{const ee=J==null?void 0:J.find(de=>de.id===ie.assistant_id);return{...ie,permissions:ie.permissions,assistant_profile:ee?{name:ee.name||"",email:ee.email||""}:void 0}});r(ne)}else r([])}catch(V){console.error("Error loading assistants:",V)}finally{a(!1)}}},D=async()=>{if(t){if(_==="link"){if(!g.email.trim()){be.error("Please enter the assistant's email");return}k(!0);try{const{data:{session:V}}=await Z.auth.getSession();if(!V)throw new Error("Not authenticated");const{data:W,error:G}=await Z.from("profiles").select("id, name, email").eq("email",g.email.trim().toLowerCase()).single();if(G||!W){be.error("No account found with that email. Try creating a new assistant instead.");return}const{data:J}=await Z.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",W.id);if(J&&J.length>0){be.error("This assistant is already assigned to you");return}const ne=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V.access_token}`},body:JSON.stringify({userId:W.id,role:"assistant",action:"add",agentId:t.id})}),ie=await ne.json();if(!ne.ok)throw new Error(ie.error||"Failed to assign assistant role");const{error:ee}=await Z.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:W.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(ee)throw ee;be.success(`${W.name||W.email} linked as your assistant`),l(!1),v({email:"",name:"",password:""}),E()}catch(V){console.error("Error linking assistant:",V),be.error(V.message||"Failed to link assistant")}finally{k(!1)}return}if(!g.email.trim()||!g.name.trim()||!g.password.trim()){be.error("Please fill in all fields");return}if(g.password.length<6){be.error("Password must be at least 6 characters");return}k(!0);try{const{data:{session:V}}=await Z.auth.getSession();if(!V)throw new Error("Not authenticated");const W=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V.access_token}`},body:JSON.stringify({email:g.email.trim(),password:g.password,name:g.name.trim(),purpose:"assistant"})}),G=await W.json();if(!W.ok)throw new Error(G.error||"Failed to create assistant account");const J=G.userId||G.id;if(!J)throw new Error("No user ID returned");const ne=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V.access_token}`},body:JSON.stringify({userId:J,role:"assistant",action:"add",agentId:t.id})}),ie=await ne.json();if(!ne.ok)throw new Error(ie.error||"Failed to assign assistant role");const{error:ee}=await Z.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:J,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(ee)throw ee;be.success(`Assistant account created for ${g.name.trim()}`),l(!1),v({email:"",name:"",password:""}),E()}catch(V){console.error("Error adding assistant:",V),be.error(V.message||"Failed to add assistant")}finally{k(!1)}}},L=async()=>{if(!(!h||!t))try{const{data:{session:V}}=await Z.auth.getSession();if(!V)throw new Error("Not authenticated");const{error:W}=await Z.from("agent_assistant_assignments").delete().eq("id",h.id);if(W)throw W;const{data:G}=await Z.from("agent_assistant_assignments").select("id").eq("assistant_id",h.assistant_id);(!G||G.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V.access_token}`},body:JSON.stringify({userId:h.assistant_id,role:"assistant",action:"remove"})}),be.success("Assistant removed"),d(!1),f(null),E()}catch(V){console.error("Error removing assistant:",V),be.error(V.message||"Failed to remove assistant")}},B=async(V,W,G)=>{S(V);try{const J=s.find(ee=>ee.id===V);if(!J)return;const ne={...J.permissions,[W]:G},{error:ie}=await Z.from("agent_assistant_assignments").update({permissions:ne}).eq("id",V);if(ie)throw ie;r(ee=>ee.map(de=>de.id===V?{...de,permissions:ne}:de))}catch(J){console.error("Error updating permissions:",J),be.error("Failed to update permissions")}finally{S(null)}};return n?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx($e,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(Tr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(Y,{size:"sm",onClick:()=>{j("create"),l(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx($e,{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(V=>{var W,G,J,ne;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:((G=(W=V.assistant_profile)==null?void 0:W.name)==null?void 0:G.split(" ").map(ie=>ie[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((J=V.assistant_profile)==null?void 0:J.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((ne=V.assistant_profile)==null?void 0:ne.email)||""})]}),e.jsxs(ct,{variant:"secondary",className:"ml-2",children:[e.jsx(Bu,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(Y,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{f(V),d(!0)},children:e.jsx(Ir,{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:w2t.map(ie=>{const ee=ie.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(ee,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:ie.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ie.description})]})]}),e.jsx(ln,{checked:V.permissions[ie.key]||!1,onCheckedChange:de=>B(V.id,ie.key,de),disabled:M===V.id})]},ie.key)})})]})]},V.id)})})})]}),e.jsx(js,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Add Assistant"}),e.jsx(en,{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(Y,{variant:_==="create"?"default":"outline",size:"sm",onClick:()=>j("create"),children:[e.jsx(ar,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(Y,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>j("link"),children:[e.jsx(Ro,{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(je,{htmlFor:"assistant-name",children:"Name"}),e.jsx(Be,{id:"assistant-name",value:g.name,onChange:V=>v({...g,name:V.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"assistant-email",children:"Email"}),e.jsx(Be,{id:"assistant-email",type:"email",value:g.email,onChange:V=>v({...g,email:V.target.value}),placeholder:"assistant@email.com"})]}),_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(Be,{id:"assistant-password",type:"password",value:g.password,onChange:V=>v({...g,password:V.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(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(Y,{onClick:D,disabled:w,children:[w&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(Ec,{open:i,onOpenChange:d,children:e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Remove Assistant?"}),e.jsxs(cc,{children:["This will remove ",($=h==null?void 0:h.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(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function mu(t){this.content=t}mu.prototype={constructor:mu,find:function(t){for(var s=0;s>1}};mu.from=function(t){if(t instanceof mu)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new mu(s)};function b$e(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=b$e(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function w$e(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 h=0,f=Math.min(l.text.length,i.text.length);for(;hs&&n(d,a+i,o||null,l)!==!1&&d.content.size){let f=i+1;d.nodesBetween(Math.max(0,s-f),Math.min(d.content.size,r-f),n,a+f)}i=h}}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 h=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&&h||i.isTextblock)&&n&&(l?l=!1:o+=n),o+=h},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 jr(n,a)}cutByIndex(s,r){return s==r?jr.empty:s==0&&r==this.content.length?this:new jr(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 jr(a,o)}addToStart(s){return new jr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new jr(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?GO(r+1,o):GO(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 jr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new jr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return jr.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}};tl.none=[];class Zre extends Error{}class cn{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=k$e(this.content,s+this.openStart,r);return n&&new cn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new cn(j$e(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 cn.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 cn(jr.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 cn(s,n,a)}}cn.empty=new cn(jr.empty,0,0);function j$e(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(j$e(o.content,s-a-1,r-a-1)))}function k$e(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=k$e(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function k2t(t,s,r){if(r.openStart>t.depth)throw new Zre("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Zre("Inconsistent open depths");return N$e(t,s,r,0)}function N$e(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 oI(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&&(Fk(t.nodeAfter,n),o++));for(let i=o;ia&&tge(t,s,a+1),l=n.depth>a&&tge(r,n,a+1),i=[];return oI(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(S$e(o,l),Fk(zk(o,C$e(t,s,r,n,a+1)),i)):(o&&Fk(zk(o,Yre(t,s,a+1)),i),oI(s,r,a,i),l&&Fk(zk(l,Yre(r,n,a+1)),i)),oI(n,null,a,i),new jr(i)}function Yre(t,s,r){let n=[];if(oI(null,t,r,n),t.depth>r){let a=tge(t,s,r+1);Fk(zk(a,Yre(t,s,r+1)),n)}return oI(s,null,r,n),new jr(n)}function N2t(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(jr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class dP{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 Xre(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),h=o-d;if(n.push(l,i,a+d),!h||(l=l.child(i),l.isText))break;o=h-1,a+=d+1}return new dP(r,n,o)}static resolveCached(s,r){let n=j5e.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()+")"),M$e(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=jr.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=jr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};F1.prototype.text=void 0;class Qre extends F1{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):M$e(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 Qre(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new Qre(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 M$e(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class iN{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new T2t(s,r);if(n.next==null)return iN.empty;let a=T$e(n);n.next&&n.err("Unexpected trailing text");let o=O2t(D2t(a));return R2t(o,n),o}matchType(s){for(let r=0;rh.createAndFill()));for(let h=0;h=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(` `)}}iN.empty=new iN(!0);class T2t{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 T$e(t){let s=[];do s.push(A2t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function A2t(t){let s=[];do s.push(E2t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function E2t(t){let s=L2t(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=I2t(t,s);else break;return s}function k5e(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function I2t(t,s){let r=k5e(t),n=r;return t.eat(",")&&(t.next!="}"?n=k5e(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function P2t(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 L2t(t){if(t.eat("(")){let s=T$e(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=P2t(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 D2t(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,d){let h={term:d,to:i};return s[l].push(h),h}function a(l,i){l.forEach(d=>d.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((d,h)=>d.concat(o(h,i)),[]);if(l.type=="seq")for(let d=0;;d++){let h=o(l.exprs[d],i);if(d==l.exprs.length-1)return h;a(h,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 h=0;h{t[l].forEach(({term:i,to:d})=>{if(!i)return;let h;for(let f=0;f{h||a.push([i,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let o=s[n.join(",")]=new iN(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:I$e(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new F1(this,this.computeAttrs(s),jr.from(r),tl.setFrom(n))}createChecked(s=null,r,n){return r=jr.from(r),this.checkContent(r),new F1(this,this.computeAttrs(s),r,tl.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=jr.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(jr.empty,!0);return o?new F1(this,s,r.append(o),tl.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 D$e(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 F2t(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 z2t{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?F2t(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class uoe{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=L$e(s,a.attrs),this.excluded=null;let o=E$e(this.attrs);this.instance=o?new tl(this,o):null}create(s=null){return!s&&this.instance?this.instance:new tl(this,I$e(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new uoe(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class O$e{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=mu.from(s.nodes),r.marks=mu.from(s.marks||{}),this.nodes=S5e.compile(this.spec.nodes,this),this.marks=uoe.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]=iN.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?C5e(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==""?[]:C5e(this,l.split(" "))}this.nodeFromJSON=a=>F1.fromJSON(this,a),this.markFromJSON=a=>tl.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 S5e){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 Qre(n,n.defaultAttrs,s,tl.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 C5e(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 B2t(t){return t.tag!=null}function $2t(t){return t.style!=null}let lI=class rge{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(B2t(a))this.tags.push(a);else if($2t(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 T5e(this,r,!1);return n.addAll(s,tl.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new T5e(this,r,!0);return n.addAll(s,tl.none,r.from,r.to),cn.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=A5e(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=A5e(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new rge(s,rge.schemaRules(s)))}};const R$e={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},U2t={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},F$e={ol:!0,ul:!0},uP=1,nge=2,cI=4;function M5e(t,s,r){return s!=null?(s?uP:0)|(s==="full"?nge:0):t&&t.whitespace=="pre"?uP|nge:r&~cI}class KO{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=tl.none,this.match=o||(l&cI?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(jr.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&uP)){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=jr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(jr.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&&!R$e.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class T5e{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=M5e(null,r.preserveWhitespace,0)|(n?cI:0);a?o=new KO(a.type,a.attrs,tl.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new KO(null,null,tl.none,!0,null,l):o=new KO(s.schema.topNodeType,null,tl.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&nge?"full":this.localPreserveWS||(a.options&uP)>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(h)):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],h=d.findWrapping(s);if(h&&(!a||a.length>h.length+i)&&(a=h,o=d,!h.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(h.type):E5e(h.type,s))?(d=h.addToSet(d),!1):!0),this.nodes.push(new KO(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|=uP)}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 h=r[i];if(h==""){if(i==r.length-1||i==0)continue;for(;d>=o;d--)if(l(i-1,d))return!0;return!1}else{let f=d>0||d==0&&a?this.nodes[d].type:n&&d>=o?n.node(d-o).type:null;if(!f||f.name!=h&&!f.isInGroup(h))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 q2t(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&F$e.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function V2t(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function A5e(t){let s={};for(let r in t)s[r]=t[r];return s}function E5e(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&&Sse(she(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Sse(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new SN(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=I5e(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return I5e(s.marks)}}function I5e(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function she(t){return t.document||window.document}const P5e=new WeakMap;function H2t(t){let s=P5e.get(t);return s===void 0&&P5e.set(t,s=W2t(t)),s}function W2t(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),h=s[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let g in h)if(h[g]!=null){let v=g.indexOf(" ");v>0?d.setAttributeNS(g.slice(0,v),g.slice(v+1),h[g]):g=="style"&&d.style?d.style.cssText=h[g]:d.setAttribute(g,h[g])}}for(let g=f;gf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:j}=Sse(t,v,r,n);if(d.appendChild(_),j){if(i)throw new RangeError("Multiple content holes");i=j}}}return{dom:d,contentDOM:i}}const z$e=65535,B$e=Math.pow(2,16);function G2t(t,s){return t+s*B$e}function L5e(t){return t&z$e}function K2t(t){return(t-(t&z$e))/B$e}const $$e=1,U$e=2,Cse=4,q$e=8;class age{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&q$e)>0}get deletedBefore(){return(this.delInfo&($$e|Cse))>0}get deletedAfter(){return(this.delInfo&(U$e|Cse))>0}get deletedAcross(){return(this.delInfo&Cse)>0}}class Bm{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&Bm.empty)return Bm.empty}recover(s){let r=0,n=L5e(s);if(!this.inverted)for(let a=0;as)break;let h=this.ranges[i+o],f=this.ranges[i+l],g=d+h;if(s<=g){let v=h?s==d?-1:s==g?1:r:r,_=d+a+(v<0?0:f);if(n)return _;let j=s==(r<0?d:g)?null:G2t(i/3,s-d),w=s==d?U$e:s==g?$$e:Cse;return(r<0?s!=d:s!=g)&&(w|=q$e),new age(_,w,j)}a+=f-h}return n?s+a:new age(s+a,0,null)}touches(s,r){let n=0,a=L5e(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let h=this.ranges[i+o],f=d+h;if(s<=f&&i==a*3)return!0;n+=this.ranges[i+l]-h}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 hP;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 dd.fromReplace(s,this.from,this.to,o)}invert(){return new yx(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 d1(r.pos,n.pos,this.mark)}merge(s){return s instanceof d1&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new d1(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 d1(r.from,r.to,s.markFromJSON(r.mark))}}Gu.jsonID("addMark",d1);class yx extends Gu{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 cn(L1e(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return dd.fromReplace(s,this.from,this.to,n)}invert(){return new d1(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 yx(r.pos,n.pos,this.mark)}merge(s){return s instanceof yx&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new yx(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 yx(r.from,r.to,s.markFromJSON(r.mark))}}Gu.jsonID("removeMark",yx);class u1 extends Gu{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return dd.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return dd.fromReplace(s,this.pos,this.pos+1,new cn(jr.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 eu(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 eu(r.from,r.to,r.gapFrom,r.gapTo,cn.fromJSON(s,r.slice),r.insert,!!r.structure)}}Gu.jsonID("replaceAround",eu);function ige(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 Z2t(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(d,h,f)=>{if(!d.isInline)return;let g=d.marks;if(!n.isInSet(g)&&f.type.allowsMarkType(n.type)){let v=Math.max(h,s),_=Math.min(h+d.nodeSize,r),j=n.addToSet(g);for(let w=0;wt.step(d)),o.forEach(d=>t.step(d))}function Y2t(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 uoe){let h=l.marks,f;for(;f=n.isInSet(h);)(d||(d=[])).push(f),h=f.removeFromSet(h)}else n?n.isInSet(l.marks)&&(d=[n]):d=l.marks;if(d&&d.length){let h=Math.min(i+l.nodeSize,r);for(let f=0;ft.step(new yx(l.from,l.to,l.style)))}function D1e(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 X2t(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function V3(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;j--)w||n.index(j)>0?(w=!0,f=jr.from(n.node(j).copy(f)),g++):d--;let v=jr.empty,_=0;for(let j=o,w=!1;j>r;j--)w||a.after(j+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=jr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new eu(a,o,a,o,new cn(n,0,0),r.length,!0))}function sjt(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)&&rjt(t.doc,t.mapping.slice(o).map(i),n)){let h=null;if(n.schema.linebreakReplacement){let _=n.whitespace=="pre",j=!!n.contentMatch.matchType(n.schema.linebreakReplacement);_&&!j?h=!1:!_&&j&&(h=!0)}h===!1&&H$e(t,l,i,o),D1e(t,t.mapping.slice(o).map(i,1),n,void 0,h===null);let f=t.mapping.slice(o),g=f.map(i,1),v=f.map(i+l.nodeSize,1);return t.step(new eu(g,v,g+1,v-1,new cn(jr.from(n.create(d,null,l.marks)),0,0),1,!0)),h===!0&&V$e(t,l,i,o),!1}})}function V$e(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 H$e(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 rjt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function njt(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 eu(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new cn(jr.from(l),0,0),1,!0))}function i0(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 h=a.depth-1,f=r-2;h>o;h--,f--){let g=a.node(h),v=a.index(h);if(g.type.spec.isolating)return!1;let _=g.content.cutByIndex(v,g.childCount),j=n&&n[f+1];j&&(_=_.replaceChild(0,j.type.create(j.attrs)));let w=n&&n[f]||g;if(!g.canReplace(v+1,g.childCount)||!w.type.validContent(_))return!1}let i=a.indexAfter(o),d=n&&n[0];return a.node(o).canReplaceWith(i,i,d?d.type:a.node(o+1).type)}function ajt(t,s,r=1,n){let a=t.doc.resolve(s),o=jr.empty,l=jr.empty;for(let i=a.depth,d=a.depth-r,h=r-1;i>d;i--,h--){o=jr.from(a.node(i).copy(o));let f=n&&n[h];l=jr.from(f?f.type.create(f.attrs,l):a.node(i).copy(l))}t.step(new Kd(s,s,new cn(o.append(l),r,r),!0))}function m_(t,s){let r=t.resolve(s),n=r.index();return W$e(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function ijt(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&&W$e(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 ojt(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 f=l.whitespace=="pre",g=!!l.contentMatch.matchType(a);f&&!g?n=!1:!f&&g&&(n=!0)}let i=t.steps.length;if(n===!1){let f=t.doc.resolve(s+r);H$e(t,f.node(),f.before(),i)}l.inlineContent&&D1e(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let d=t.mapping.slice(i),h=d.map(s-r);if(t.step(new Kd(h,d.map(s+r,-1),cn.empty,!0)),n===!0){let f=t.doc.resolve(h);V$e(t,f.node(),f.before(),t.steps.length)}return t}function ljt(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),h=n.node(l),f=!1;if(o==1)f=h.canReplace(d,d,a);else{let g=h.contentMatchAt(d).findWrapping(a.firstChild.type);f=g&&h.canReplaceWith(d,d,g[0])}if(f)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function moe(t,s,r=s,n=cn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return K$e(a,o,n)?new Kd(s,r,n):new cjt(a,o,n).fit()}function K$e(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class cjt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=jr.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=jr.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):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 cn(o,l,i);return s>-1?new eu(n.pos,s,this.$to.pos,this.$to.end(),d,r):d.size||n.pos!=this.$to.pos?new Kd(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=nhe(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:h}=this.frontier[i],f,g=null;if(r==1&&(l?h.matchType(l.type)||(g=h.fillBefore(jr.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:g};if(r==2&&l&&(f=h.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:f};if(o&&h.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=nhe(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new cn(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=nhe(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new cn(tE(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new cn(tE(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let w=0;w1||d==0||w.content.size)&&(g=k,f.push(Z$e(w.mark(v.allowedMarks(w.marks)),h==1?d:0,h==i.childCount?_:-1)))}let j=h==i.childCount;j||(_=-1),this.placed=sE(this.placed,r,jr.from(f)),this.frontier[r].match=g,j&&_<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,k=i;w<_;w++){let M=k.lastChild;this.frontier.push({type:M.type,match:M.contentMatchAt(M.childCount)}),k=M.content}this.unplaced=j?s==0?cn.empty:new cn(tE(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new cn(tE(l.content,s,h),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let s=this.frontier[this.depth],r;if(!s.type.isTextblock||!ahe(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:h}=this.frontier[i],f=ahe(s,i,h,d,!0);if(!f||f.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=sE(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=sE(this.placed,this.depth,jr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(jr.empty,!0);r.childCount&&(this.placed=sE(this.placed,this.frontier.length,r))}}function tE(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(tE(t.firstChild.content,s-1,r)))}function sE(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(sE(t.lastChild.content,s-1,r)))}function nhe(t,s){for(let r=0;r1&&(n=n.replaceChild(0,Z$e(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(jr.empty,!0)))),t.copy(n)}function ahe(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&&!djt(r,o.content,l)?i:null}function djt(t,s,r){for(let n=r;n0;v--,_--){let j=a.node(v).type.spec;if(j.defining||j.definingAsContext||j.isolating)break;l.indexOf(v)>-1?i=v:a.before(v)==_&&l.splice(1,0,-v)}let d=l.indexOf(i),h=[],f=n.openStart;for(let v=n.content,_=0;;_++){let j=v.firstChild;if(h.push(j),_==n.openStart)break;v=j.content}for(let v=f-1;v>=0;v--){let _=h[v],j=ujt(_.type);if(j&&!_.sameMarkup(a.node(Math.abs(i)-1)))f=v;else if(j||!_.type.isTextblock)break}for(let v=n.openStart;v>=0;v--){let _=(v+f+1)%(n.openStart+1),j=h[_];if(j)for(let w=0;w=0&&(t.replace(s,r,n),!(t.steps.length>g));v--){let _=l[v];_<0||(s=a.before(_),r=o.after(_))}}function Y$e(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(jr.empty,!0))}return t}function mjt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=ljt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new cn(jr.from(n),0,0))}function pjt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=X$e(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 X$e(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 r5 extends Gu{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 dd.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 dd.fromReplace(s,this.pos,this.pos+1,new cn(jr.from(a),0,r.isLeaf?0:1))}getMap(){return Bm.empty}invert(s){return new r5(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 r5(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 r5(r.pos,r.attr,r.value)}}Gu.jsonID("attr",r5);class mP extends Gu{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 dd.ok(n)}getMap(){return Bm.empty}invert(s){return new mP(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 mP(r.attr,r.value)}}Gu.jsonID("docAttr",mP);let H5=class extends Error{};H5=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};H5.prototype=Object.create(Error.prototype);H5.prototype.constructor=H5;H5.prototype.name="TransformError";class R1e{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new hP}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new H5(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=cn.empty){let a=moe(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new cn(jr.from(n),0,0))}delete(s,r){return this.replace(s,r,cn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return hjt(this,s,r,n),this}replaceRangeWith(s,r,n){return mjt(this,s,r,n),this}deleteRange(s,r){return pjt(this,s,r),this}lift(s,r){return Q2t(this,s,r),this}join(s,r=1){return ojt(this,s,r),this}wrap(s,r){return tjt(this,s,r),this}setBlockType(s,r=s,n,a=null){return sjt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return njt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new r5(s,r,n)),this}setDocAttribute(s,r){return this.step(new mP(s,r)),this}addNodeMark(s,r){return this.step(new u1(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 tl)r.isInSet(n.marks)&&this.step(new oN(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new oN(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 ajt(this,s,r,n),this}addMark(s,r,n){return Z2t(this,s,r,n),this}removeMark(s,r,n){return Y2t(this,s,r,n),this}clearIncompatible(s,r,n){return D1e(this,s,r,n),this}}const ihe=Object.create(null);class Za{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new Q$e(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?$C(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):$C(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 sp(s.node(0))}static atStart(s){return $C(s,s,0,0,1)||new sp(s)}static atEnd(s){return $C(s,s,s.content.size,s.childCount,-1)||new sp(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ihe[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 ihe)throw new RangeError("Duplicate use of selection JSON ID "+s);return ihe[s]=r,r.prototype.jsonID=s,r}getBookmark(){return Ea.between(this.$anchor,this.$head).getBookmark()}}Za.prototype.visible=!0;class Q$e{constructor(s,r){this.$from=s,this.$to=r}}let O5e=!1;function R5e(t){!O5e&&!t.parent.inlineContent&&(O5e=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ea extends Za{constructor(s,r=s){R5e(s),R5e(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 Za.near(n);let a=s.resolve(r.map(this.anchor));return new Ea(a.parent.inlineContent?a:n,n)}replace(s,r=cn.empty){if(super.replace(s,r),r==cn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof Ea&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new poe(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 Ea(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=Za.findFrom(r,n,!0)||Za.findFrom(r,-n,!0);if(o)r=o.$head;else return Za.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(Za.findFrom(s,-n,!0)||Za.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&&ja.isSelectable(i))return ja.create(t,r-(a<0?i.nodeSize:0))}else{let d=$C(t,i,r+a,a<0?i.childCount:0,a,o);if(d)return d}r+=i.nodeSize*a}return null}function F5e(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=f)}),t.setSelection(Za.near(t.doc.resolve(l),r))}const z5e=1,ZO=2,B5e=4;class gjt extends R1e{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|=ZO,this}ensureMarks(s){return tl.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&ZO)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~ZO,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)||tl.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(Za.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|=B5e,this}get scrolledIntoView(){return(this.updated&B5e)>0}}function $5e(t,s){return!s||!t?t:t.bind(s)}class rE{constructor(s,r,n){this.name=s,this.init=$5e(r.init,n),this.apply=$5e(r.apply,n)}}const xjt=[new rE("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new rE("selection",{init(t,s){return t.selection||Za.atStart(s.doc)},apply(t){return t.selection}}),new rE("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new rE("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class ohe{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xjt.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 rE(n.key,n.spec.state,n))})}}class r4{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 ohe(s.schema,s.plugins),o=new r4(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=F1.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=Za.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],h=d.spec.state;if(d.key==l.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(r,i)){o[l.name]=h.fromJSON.call(d,s,r[i],o);return}}o[l.name]=l.init(s,o)}}),o}}function J$e(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=J$e(a,s,{})),r[n]=a}return r}class Pd{constructor(s){this.spec=s,this.props={},s.props&&J$e(s.props,this,this.props),this.key=s.key?s.key.key:eUe("plugin")}getState(s){return s[this.key]}}const lhe=Object.create(null);function eUe(t){return t in lhe?t+"$"+ ++lhe[t]:(lhe[t]=0,t+"$")}class Ku{constructor(s="key"){this.key=eUe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const gu=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},W5=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let oge=null;const Iy=function(t,s,r){let n=oge||(oge=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},yjt=function(){oge=null},lN=function(t,s,r,n){return r&&(U5e(t,s,r,n,-1)||U5e(t,s,r,n,1))},vjt=/^(img|br|input|textarea|hr)$/i;function U5e(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:zp(t))){let l=t.parentNode;if(!l||l.nodeType!=1||V6(t)||vjt.test(t.nodeName)||t.contentEditable=="false")return!1;s=gu(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?zp(t):0}else return!1}}function zp(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _jt(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=zp(t)}else if(t.parentNode&&!V6(t))s=gu(t),t=t.parentNode;else return null}}function bjt(t,s){for(;;){if(t.nodeType==3&&s2),Pp=G5||(zx?/Mac/.test(zx.platform):!1),rUe=zx?/Win/.test(zx.platform):!1,Vy=/Android \d/.test(p_),H6=!!q5e&&"webkitFontSmoothing"in q5e.documentElement.style,Njt=H6?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Sjt(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 wy(t,s){return typeof t=="number"?t:t[s]}function Cjt(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 V5e(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=W5(l);continue}let i=l,d=i==o.body,h=d?Sjt(o):Cjt(i),f=0,g=0;if(s.toph.bottom-wy(n,"bottom")&&(g=s.bottom-s.top>h.bottom-h.top?s.top+wy(a,"top")-h.top:s.bottom-h.bottom+wy(a,"bottom")),s.lefth.right-wy(n,"right")&&(f=s.right-h.right+wy(a,"right")),f||g)if(d)o.defaultView.scrollBy(f,g);else{let _=i.scrollLeft,j=i.scrollTop;g&&(i.scrollTop+=g),f&&(i.scrollLeft+=f);let w=i.scrollLeft-_,k=i.scrollTop-j;s={left:s.left-w,top:s.top-k,right:s.right-w,bottom:s.bottom-k}}let v=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(v))break;l=v=="absolute"?l.offsetParent:W5(l)}}function Mjt(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:nUe(t.dom)}}function nUe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=W5(n));return s}function Tjt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;aUe(r,n==0?0:n-s)}function aUe(t,s){for(let r=0;r=i){l=Math.max(j.bottom,l),i=Math.min(j.top,i);let w=j.left>s.left?j.left-s.left:j.right=(j.left+j.right)/2?1:0));continue}}else j.top>s.top&&!d&&j.left<=s.left&&j.right>=s.left&&(d=f,h={left:Math.max(j.left,Math.min(j.right,s.left)),top:j.top});!r&&(s.left>=j.right&&s.top>=j.top||s.left>=j.left&&s.top>=j.bottom)&&(o=g+1)}}return!r&&d&&(r=d,a=h,n=0),r&&r.nodeType==3?Ejt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:iUe(r,a)}function Ejt(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 z1e(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function Ijt(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 Ljt(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 oUe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let h;H6&&a&&n.nodeType==1&&(h=n.childNodes[a-1]).nodeType==1&&h.contentEditable=="false"&&h.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=Ljt(t,n,a,s))}i==null&&(i=Pjt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function H5e(t){return t.top=0&&a==n.nodeValue.length?(d--,f=1):r<0?d--:h++,MA(kv(Iy(n,d,h),f),f<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==zp(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return che(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==zp(n))){let d=n.childNodes[a-1],h=d.nodeType==3?Iy(d,zp(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(h)return MA(kv(h,1),!1)}if(o==null&&a=0)}function MA(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 che(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 cUe(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 Rjt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return cUe(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=lUe(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=Iy(i,0,i.nodeValue.length).getClientRects();else continue;for(let h=0;hf.top+1&&(r=="up"?l.top-f.top>(f.bottom-l.top)*2:f.bottom-l.bottom>(l.bottom-f.top)*2))return!1}}return!0})}const Fjt=/[\u0590-\u08ac]/;function zjt(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?!Fjt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:cUe(t,s,()=>{let{focusNode:d,focusOffset:h,anchorNode:f,anchorOffset:g}=t.domSelectionRange(),v=i.caretBidiLevel;i.modify("move",r,"character");let _=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:j,focusOffset:w}=t.domSelectionRange(),k=j&&!_.contains(j.nodeType==1?j:j.parentNode)||d==j&&h==w;try{i.collapse(f,g),d&&(d!=f||h!=g)&&i.extend&&i.extend(d,h)}catch{}return v!=null&&(i.caretBidiLevel=v),k}):n.pos==n.start()||n.pos==n.end()}let W5e=null,G5e=null,K5e=!1;function Bjt(t,s,r){return W5e==s&&G5e==r?K5e:(W5e=s,G5e=r,K5e=r=="up"||r=="down"?Rjt(t,s,r):zjt(t,s,r))}const Xp=0,Z5e=1,Zj=2,Bx=3;class W6{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=Xp,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;rgu(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 uUe){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 dUe&&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?gu(o.dom)+1:0}}else{let o,l=!0;for(;o=n=f&&r<=h-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(s,r,f);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=gu(v.dom)+1;break}s-=v.size}a==-1&&(a=0)}if(a>-1&&(h>r||i==this.children.length-1)){r=h;for(let f=i+1;fj&&lr){let j=i;i=d,d=j}let _=document.createRange();_.setEnd(d.node,d.offset),_.setStart(i.node,i.offset),h.removeAllRanges(),h.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?Zj:Z5e,s==i&&r==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Bx:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Zj:Bx}n=l}this.dirty=Zj}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?Zj:Z5e;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==Xp&&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 $jt extends W6{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 cN extends W6{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=SN.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new cN(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&Bx||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=Bx&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=Xp){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=hge(o,0,s,n));for(let i=0;i{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},n,a),f=h&&h.dom,g=h&&h.contentDOM;if(r.isText){if(!f)f=document.createTextNode(r.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:g}=SN.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!g&&!r.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),r.type.spec.draggable&&(f.draggable=!0));let v=f;return f=pUe(f,n,r),h?d=new Ujt(s,r,n,a,f,g||null,v,h,o,l+1):r.isText?new goe(s,r,n,a,f,v,o):new B1(s,r,n,a,f,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=()=>jr.empty)}return s}matchesNode(s,r,n){return this.dirty==Xp&&s.eq(this.node)&&Jre(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 Vjt(this,l&&l.node,s);Gjt(this.node,this.innerDeco,(h,f,g)=>{h.spec.marks?d.syncToMarks(h.spec.marks,n,s):h.type.side>=0&&!g&&d.syncToMarks(f==this.node.childCount?tl.none:this.node.child(f).marks,n,s),d.placeWidget(h,s,a)},(h,f,g,v)=>{d.syncToMarks(h.marks,n,s);let _;d.findNodeMatch(h,f,g,v)||i&&s.state.selection.from>a&&s.state.selection.to-1&&d.updateNodeAt(h,f,g,_,s)||d.updateNextNode(h,f,g,s,v,a)||d.addNode(h,f,g,s,a),a+=h.nodeSize}),d.syncToMarks([],n,s),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==Zj)&&(l&&this.protectLocalComposition(s,l),hUe(this.contentDOM,this.children,s),G5&&Kjt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof Ea)||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=Zjt(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 $jt(this,o,r,a);s.input.compositionNodes.push(l),this.children=hge(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==Bx||!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=Xp}updateOuterDeco(s){if(Jre(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=mUe(this.dom,this.nodeDOM,uge(this.outerDeco,this.node,r),uge(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 Y5e(t,s,r,n,a){pUe(n,s,t);let o=new B1(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class goe extends B1{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==Bx||this.dirty!=Xp&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Xp||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=Xp,!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 goe(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=Bx)}get domAtom(){return!1}isText(s){return this.node.text==s}}class uUe extends W6{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==Xp&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ujt extends B1{constructor(s,r,n,a,o,l,i,d,h,f){super(s,r,n,a,o,l,i,h,f),this.spec=d}update(s,r,n,a){if(this.dirty==Bx)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 hUe(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=cN.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 h=r.children[n-1];if(h instanceof cN)r=h,n=h.children.length;else{i=h,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 Wjt(t,s){return t.type.side-s.type.side}function Gjt(t,s,r,n){let a=s.locals(t),o=0;if(a.length==0){for(let h=0;ho;)i.push(a[l++]);let j=o+v.nodeSize;if(v.isText){let k=j;l!k.inline):i.slice();n(v,w,s.forChild(o,v),_),o=j}}function Kjt(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 Zjt(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 h=i=0&&h+s.length+i>=r)return i+h;if(r==n&&d.length>=n+s.length-i&&d.slice(n-i,n-i+s.length)==s)return n}}return-1}function hge(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||f<=s?o.push(d):(hr&&o.push(d.slice(r-h,d.size,n)))}return o}function B1e(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,h;if(foe(r)){for(d=l;a&&!a.node;)a=a.parent;let g=a.node;if(a&&g.isAtom&&ja.isSelectable(g)&&a.parent&&!(g.isInline&&wjt(r.focusNode,r.focusOffset,a.dom))){let v=a.posBefore;h=new ja(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(()=>{(!fUe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Xjt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,gu(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&mm&&z1<=11&&(r.disabled=!0,r.disabled=!1)}function gUe(t,s){if(s instanceof ja){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(t3e(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else t3e(t)}function t3e(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function $1e(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||Ea.between(s,r,n)}function s3e(t){return t.editable&&!t.hasFocus()?!1:xUe(t)}function xUe(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 Qjt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return lN(s.node,s.offset,r.anchorNode,r.anchorOffset)}function mge(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&&Za.findFrom(o,s)}function Dv(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function r3e(t,s,r){let n=t.state.selection;if(n instanceof Ea)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 Dv(t,new Ea(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=mge(t.state,s);return a&&a instanceof ja?Dv(t,a):!1}else if(!(Pp&&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?ja.isSelectable(o)?Dv(t,new ja(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):H6?Dv(t,new Ea(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof ja&&n.node.isInline)return Dv(t,new Ea(s>0?n.$to:n.$from));{let a=mge(t.state,s);return a?Dv(t,a):!1}}}function ene(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function uI(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function TC(t,s){return s<0?Jjt(t):ekt(t)}function Jjt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(Yp&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(uI(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(yUe(r))break;{let i=r.previousSibling;for(;i&&uI(i,-1);)a=r.parentNode,o=gu(i),i=i.previousSibling;if(i)r=i,n=ene(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?pge(t,r,n):a&&pge(t,a,o)}function ekt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=ene(r),o,l;for(;;)if(n{t.state==a&&o0(t)},50)}function n3e(t,s){let r=t.state.doc.resolve(s);if(!(Yd||rUe)&&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 a3e(t,s,r){let n=t.state.selection;if(n instanceof Ea&&!n.empty||r.indexOf("s")>-1||Pp&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=mge(t.state,s);if(l&&l instanceof ja)return Dv(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof sp?Za.near(l,s):Za.findFrom(l,s);return i?Dv(t,i):!1}return!1}function i3e(t,s){if(!(t.state.selection instanceof Ea))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 o3e(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function rkt(t){if(!qu||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;o3e(t,n,"true"),setTimeout(()=>o3e(t,n,"false"),20)}return!1}function nkt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function akt(t,s){let r=s.keyCode,n=nkt(s);if(r==8||Pp&&r==72&&n=="c")return i3e(t,-1)||TC(t,-1);if(r==46&&!s.shiftKey||Pp&&r==68&&n=="c")return i3e(t,1)||TC(t,1);if(r==13||r==27)return!0;if(r==37||Pp&&r==66&&n=="c"){let a=r==37?n3e(t,t.state.selection.from)=="ltr"?-1:1:-1;return r3e(t,a,n)||TC(t,a)}else if(r==39||Pp&&r==70&&n=="c"){let a=r==39?n3e(t,t.state.selection.from)=="ltr"?1:-1:1;return r3e(t,a,n)||TC(t,a)}else{if(r==38||Pp&&r==80&&n=="c")return a3e(t,-1,n)||TC(t,-1);if(r==40||Pp&&r==78&&n=="c")return rkt(t)||a3e(t,1,n)||TC(t,1);if(n==(Pp?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function U1e(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")||SN.fromSchema(t.state.schema),i=kUe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let h=d.firstChild,f,g=0;for(;h&&h.nodeType==1&&(f=jUe[h.nodeName.toLowerCase()]);){for(let _=f.length-1;_>=0;_--){let j=i.createElement(f[_]);for(;d.firstChild;)j.appendChild(d.firstChild);d.appendChild(j),g++}h=d.firstChild}h&&h.nodeType==1&&h.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 vUe(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 cn(jr.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,j=SN.fromSchema(_);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(w=>{let k=l.appendChild(document.createElement("p"));w&&k.appendChild(j.serializeNode(_.text(w,v)))})}}else t.someProp("transformPastedHTML",g=>{r=g(r,t)}),l=ckt(r),H6&&dkt(l);let h=l&&l.querySelector("[data-pm-slice]"),f=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let g=+f[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")||lI.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||f),context:a,ruleFromNode(v){return v.nodeName=="BR"&&!v.nextSibling&&v.parentNode&&!ikt.test(v.parentNode.nodeName)?{ignore:!0}:null}})),f)i=ukt(l3e(i,+f[1],+f[2]),f[4]);else if(i=cn.maxOpen(okt(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 ikt=/^(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 okt(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),h;if(!d)return l=null;if(h=l.length&&o.length&&bUe(d,o,i,l[l.length-1],0))l[l.length-1]=h;else{l.length&&(l[l.length-1]=wUe(l[l.length-1],o.length));let f=_Ue(i,d);l.push(f),a=a.matchType(f.type),o=d}}),l)return jr.from(l)}return t}function _Ue(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,jr.from(t));return t}function bUe(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(jr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function l3e(t,s,r){return sr})),uhe.createHTML(t)):t}function ckt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=kUe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&jUe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=lkt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=jr.from(d.create(n[i+1],a)),o++,l++}return new cn(a,o,l)}const Mh={},Th={},hkt={touchstart:!0,touchmove:!0};class mkt{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 pkt(t){for(let s in Mh){let r=Mh[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{gkt(t,n)&&!q1e(t,n)&&(t.editable||!(n.type in Th))&&r(t,n)},hkt[s]?{passive:!0}:void 0)}qu&&t.dom.addEventListener("input",()=>null),gge(t)}function h1(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function fkt(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 gge(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>q1e(t,n))})}function q1e(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function gkt(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 xkt(t,s){!q1e(t,s)&&Mh[s.type]&&(t.editable||!(s.type in Th))&&Mh[s.type](t,s)}Th.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!SUe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Vy&&Yd&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),G5&&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,Bj(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||akt(t,r)?r.preventDefault():h1(t,"key")};Th.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Th.keypress=(t,s)=>{let r=s;if(SUe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Pp&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Ea)||!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 xoe(t){return{left:t.clientX,top:t.clientY}}function ykt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function V1e(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 n5(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 vkt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&ja.isSelectable(n)?(n5(t,new ja(r)),!0):!1}function _kt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof ja&&(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(ja.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?(n5(t,ja.create(t.state.doc,a)),!0):!1}function bkt(t,s,r,n,a){return V1e(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?_kt(t,r):vkt(t,r))}function wkt(t,s,r,n){return V1e(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function jkt(t,s,r,n){return V1e(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||kkt(t,r,n)}function kkt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(n5(t,Ea.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)n5(t,Ea.create(n,i+1,i+1+l.content.size));else if(ja.isSelectable(l))n5(t,ja.create(n,i));else continue;return!0}}function H1e(t){return tne(t)}const NUe=Pp?"metaKey":"ctrlKey";Mh.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=H1e(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&ykt(r,t.input.lastClick)&&!r[NUe]&&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(xoe(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Nkt(t,l,r,!!n)):(o=="doubleClick"?wkt:jkt)(t,l.pos,l.inside,r)?r.preventDefault():h1(t,"pointer"))};class Nkt{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[NUe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let f=s.state.doc.resolve(r.pos);o=f.parent,l=f.depth?f.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:h}=s.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||h instanceof ja&&h.from<=l&&h.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Yp&&!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)),h1(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(xoe(s))),this.updateAllowDefault(s),this.allowDefault||!r?h1(this.view,"pointer"):bkt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||qu&&this.mightDrag&&!this.mightDrag.node.isAtom||Yd&&!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)?(n5(this.view,Za.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):h1(this.view,"pointer")}move(s){this.updateAllowDefault(s),h1(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)}}Mh.touchstart=t=>{t.input.lastTouch=Date.now(),H1e(t),h1(t,"pointer")};Mh.touchmove=t=>{t.input.lastTouch=Date.now(),h1(t,"pointer")};Mh.contextmenu=t=>H1e(t);function SUe(t,s){return t.composing?!0:qu&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Skt=Vy?5e3:-1;Th.compositionstart=Th.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof Ea&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Yd&&rUe&&Ckt(t)))t.markCursor=t.state.storedMarks||r.marks(),tne(t,!0),t.markCursor=null;else if(tne(t,!s.selection.empty),Yp&&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}CUe(t,Skt)};function Ckt(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"}Th.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++,CUe(t,20))};function CUe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>tne(t),s))}function MUe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Tkt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Mkt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=_jt(s.focusNode,s.focusOffset),n=bjt(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 Tkt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function tne(t,s=!1){if(!(Vy&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),MUe(t),s||t.docView&&t.docView.dirty){let r=B1e(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 Akt(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 pP=mm&&z1<15||G5&&Njt<604;Mh.copy=Th.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=pP?null:r.clipboardData,l=n.content(),{dom:i,text:d}=U1e(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):Akt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ekt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ikt(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?fP(t,n.value,null,a,s):fP(t,n.textContent,n.innerHTML,a,s)},50)}function fP(t,s,r,n,a){let o=vUe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,a,o||cn.empty)))return!0;if(!o)return!1;let l=Ekt(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 TUe(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," "):""}Th.paste=(t,s)=>{let r=s;if(t.composing&&!Vy)return;let n=pP?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&fP(t,TUe(n),n.getData("text/html"),a,r)?r.preventDefault():Ikt(t,r)};class AUe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const Pkt=Pp?"altKey":"ctrlKey";function EUe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[Pkt]}Mh.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(xoe(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof ja?a.to-1:a.to))){if(n&&n.mightDrag)l=ja.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=ja.create(t.state.doc,g.posBefore))}}let i=(l||t.state.selection).content(),{dom:d,text:h,slice:f}=U1e(t,i);(!r.dataTransfer.files.length||!Yd||sUe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(pP?"Text":"text/html",d.innerHTML),r.dataTransfer.effectAllowed="copyMove",pP||r.dataTransfer.setData("text/plain",h),t.dragging=new AUe(f,EUe(t,r),l)};Mh.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Th.dragover=Th.dragenter=(t,s)=>s.preventDefault();Th.drop=(t,s)=>{try{Lkt(t,s,t.dragging)}finally{t.dragging=null}};function Lkt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(xoe(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=vUe(t,TUe(s.dataTransfer),pP?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&EUe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||cn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?G$e(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 h=d.mapping.map(i),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,g=d.doc;if(f?d.replaceRangeWith(h,h,o.content.firstChild):d.replaceRange(h,h,o),d.doc.eq(g))return;let v=d.doc.resolve(h);if(f&&ja.isSelectable(o.content.firstChild)&&v.nodeAfter&&v.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new ja(v));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((j,w,k,M)=>_=M),d.setSelection($1e(t,v,d.doc.resolve(_)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Mh.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))};Mh.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)};Mh.beforeinput=(t,s)=>{if(Yd&&Vy&&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,Bj(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 Th)Mh[t]=Th[t];function gP(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 sne{constructor(s,r){this.toDOM=s,this.spec=r||Bk,this.side=this.spec.side||0}map(s,r,n,a){let{pos:o,deleted:l}=s.mapResult(r.from+a,this.side<0?-1:1);return l?null:new xh(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof sne&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&gP(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class $1{constructor(s,r){this.attrs=s,this.spec=r||Bk}map(s,r,n,a){let o=s.map(r.from+a,this.spec.inclusiveStart?-1:1)-n,l=s.map(r.to+a,this.spec.inclusiveEnd?1:-1)-n;return o>=l?null:new xh(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==Eu||s.maps.length==0?this:this.mapInner(s,r,0,0,n||Bk)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let h=d+n,f;if(f=PUe(r,i,h)){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 $1){let h=Math.max(o,d.from)-o,f=Math.min(l,d.to)-o;ha.map(s,r,Bk));return Hv.from(n)}forChild(s,r){if(r.isLeaf)return kc.empty;let n=[];for(let a=0;ar instanceof kc)?s:s.reduce((r,n)=>r.concat(n instanceof kc?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let k=w-j-(_-v);for(let M=0;MS+f-g)continue;let E=i[M]+f-g;_>=E?i[M+1]=v<=E?-2:-1:v>=f&&k&&(i[M]+=k,i[M+1]+=k)}g+=k}),f=r.maps[h].map(f,-1)}let d=!1;for(let h=0;h=n.content.size){d=!0;continue}let v=r.map(t[h+1]+o,-1),_=v-a,{index:j,offset:w}=n.content.findIndex(g),k=n.maybeChild(j);if(k&&w==g&&w+k.nodeSize==_){let M=i[h+2].mapInner(r,k,f+1,t[h]+o+1,l);M!=Eu?(i[h]=g,i[h+1]=_,i[h+2]=M):(i[h+1]=-2,d=!0)}else d=!0}if(d){let h=Okt(i,t,s,r,a,o,l),f=rne(h,n,0,l);s=f.local;for(let g=0;gr&&l.to{let h=PUe(t,i,d+r);if(h){o=!0;let f=rne(h,i,r+d+1,n);f!=Eu&&a.push(d,d+i.nodeSize,f)}});let l=IUe(o?LUe(t):t,-r).sort($k);for(let i=0;i0;)s++;t.splice(s,0,r)}function hhe(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Eu&&s.push(n)}),t.cursorWrapper&&s.push(kc.create(t.state.doc,[t.cursorWrapper.deco])),Hv.from(s)}const Rkt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fkt=mm&&z1<=11;class zkt{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 Bkt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new zkt,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()}),Fkt&&(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,Rkt)),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(s3e(this.view)){if(this.suppressingSelectionUpdates)return o0(this.view);if(mm&&z1<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&lN(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=W5(o))r.add(o);for(let o=s.anchorNode;o;o=W5(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)&&s3e(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,d=[];if(s.editable)for(let f=0;fg.nodeName=="BR");if(f.length==2){let[g,v]=f;g.parentNode&&g.parentNode.parentNode==v.parentNode?v.remove():g.remove()}else{let{focusNode:g}=this.currentSelection;for(let v of f){let _=v.parentNode;_&&_.nodeName=="LI"&&(!g||qkt(s,g)!=_)&&v.remove()}}}else if((Yd||qu)&&d.some(f=>f.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let f of d)if(f.nodeName=="BR"&&f.parentNode){let g=f.nextSibling;g&&g.nodeType==1&&g.contentEditable=="false"&&f.parentNode.removeChild(f)}}let h=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),$kt(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 f=0;fa;k--){let M=n.childNodes[k-1],S=M.pmViewDesc;if(M.nodeName=="BR"&&!S){o=k;break}if(!S||S.size)break}let g=t.state.doc,v=t.someProp("domParser")||lI.fromSchema(t.state.schema),_=g.resolve(l),j=null,w=v.parse(n,{topNode:_.parent,topMatch:_.parent.contentMatchAt(_.index()),topOpen:!0,from:a,to:o,preserveWhitespace:_.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:Hkt,context:_});if(h&&h[0].pos!=null){let k=h[0].pos,M=h[1]&&h[1].pos;M==null&&(M=k),j={anchor:k+l,head:M+l}}return{doc:w,sel:j,from:l,to:i}}function Hkt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(qu&&/^(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||qu&&/^(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 Wkt=/^(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 Gkt(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,V=B1e(t,$);if(V&&!t.state.selection.eq(V)){if(Yd&&Vy&&t.input.lastKeyCode===13&&Date.now()-100G(t,Bj(13,"Enter"))))return;let W=t.state.tr.setSelection(V);$=="pointer"?W.setMeta("pointer",!0):$=="key"&&W.scrollIntoView(),o&&W.setMeta("composition",o),t.dispatch(W)}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,h=Vkt(t,s,r),f=t.state.doc,g=f.slice(h.from,h.to),v,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Vy)&&a.some($=>$.nodeType==1&&!Wkt.test($.nodeName))&&(!j||j.endA>=j.endB)&&t.someProp("handleKeyDown",$=>$(t,Bj(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!j)if(n&&d instanceof Ea&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))j={start:d.from,endA:d.to,endB:d.to};else{if(h.sel){let $=p3e(t,t.state.doc,h.sel);if($&&!$.eq(t.state.selection)){let V=t.state.tr.setSelection($);o&&V.setMeta("composition",o),t.dispatch(V)}}return}t.state.selection.fromt.state.selection.from&&j.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?j.start=t.state.selection.from:j.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(j.endB+=t.state.selection.to-j.endA,j.endA=t.state.selection.to)),mm&&z1<=11&&j.endB==j.start+1&&j.endA==j.start&&j.start>h.from&&h.doc.textBetween(j.start-h.from-1,j.start-h.from+1)=="  "&&(j.start--,j.endA--,j.endB--);let w=h.doc.resolveNoCache(j.start-h.from),k=h.doc.resolveNoCache(j.endB-h.from),M=f.resolve(j.start),S=w.sameParent(k)&&w.parent.inlineContent&&M.end()>=j.endA;if((G5&&t.input.lastIOSEnter>Date.now()-225&&(!S||a.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!S&&w.pos$(t,Bj(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>j.start&&Zkt(f,j.start,j.endA,w,k)&&t.someProp("handleKeyDown",$=>$(t,Bj(8,"Backspace")))){Vy&&Yd&&t.domObserver.suppressSelectionUpdates();return}Yd&&j.endB==j.start&&(t.input.lastChromeDelete=Date.now()),Vy&&!S&&w.start()!=k.start()&&k.parentOffset==0&&w.depth==k.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==j.endA&&(j.endB-=2,k=h.doc.resolveNoCache(j.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function($){return $(t,Bj(13,"Enter"))})},20));let E=j.start,D=j.endA,L=$=>{let V=$||t.state.tr.replace(E,D,h.doc.slice(j.start-h.from,j.endB-h.from));if(h.sel){let W=p3e(t,V.doc,h.sel);W&&!(Yd&&t.composing&&W.empty&&(j.start!=j.endB||t.input.lastChromeDeleteo0(t),20));let $=L(t.state.tr.delete(E,D)),V=f.resolve(j.start).marksAcross(f.resolve(j.endA));V&&$.ensureMarks(V),t.dispatch($)}else if(j.endA==j.endB&&(B=Kkt(w.parent.content.cut(w.parentOffset,k.parentOffset),M.parent.content.cut(M.parentOffset,j.endA-M.start())))){let $=L(t.state.tr);B.type=="add"?$.addMark(E,D,B.mark):$.removeMark(E,D,B.mark),t.dispatch($)}else if(w.parent.child(w.index()).isText&&w.index()==k.index()-(k.textOffset?0:1)){let $=w.parent.textBetween(w.parentOffset,k.parentOffset),V=()=>L(t.state.tr.insertText($,E,D));t.someProp("handleTextInput",W=>W(t,E,D,$,V))||t.dispatch(V())}else t.dispatch(L());else t.dispatch(L())}function p3e(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:$1e(t,s.resolve(r.anchor),s.resolve(r.head))}function Kkt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,d;for(let f=0;ff.mark(i.addToSet(f.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",d=f=>f.mark(i.removeFromSet(f.marks));else return null;let h=[];for(let f=0;fr||mhe(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 Ykt(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 DUe{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 mkt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(_3e),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=y3e(this),x3e(this),this.nodeViews=v3e(this),this.docView=Y5e(this.state.doc,g3e(this),hhe(this),this.dom,this),this.domObserver=new Bkt(this,(n,a,o,l)=>Gkt(this,n,a,o,l)),this.domObserver.start(),pkt(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&&gge(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(_3e),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&&(MUe(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 _=v3e(this);Qkt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&gge(this),this.editable=y3e(this),x3e(this);let d=hhe(this),h=g3e(this),f=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",g=o||!this.docView.matchesNode(s.doc,h,d);(g||!s.selection.eq(a.selection))&&(l=!0);let v=f=="preserve"&&l&&this.dom.style.overflowAnchor==null&&Mjt(this);if(l){this.domObserver.stop();let _=g&&(mm||Yd)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&Xkt(a.selection,s.selection);if(g){let j=Yd?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Mkt(this)),(o||!this.docView.update(s.doc,h,d,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=Y5e(s.doc,h,d,this.dom,this)),j&&!this.trackWrites&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Qjt(this))?o0(this,_):(gUe(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),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():v&&Tjt(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 ja){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&V5e(this,r.getBoundingClientRect(),s)}else V5e(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 AUe(s.slice,s.move,a<0?void 0:ja.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 Djt(this,s)}coordsAtPos(s,r=1){return lUe(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 Bjt(this,r||this.state,s)}pasteHTML(s,r){return fP(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return fP(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return U1e(this,s)}destroy(){this.docView&&(fkt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hhe(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,yjt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return xkt(this,s)}domSelectionRange(){let s=this.domSelection();return s?qu&&this.root.nodeType===11&&jjt(this.dom.ownerDocument)==this.dom&&Ukt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}DUe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function g3e(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"),[xh.node(0,t.state.doc.content.size,s)]}function x3e(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:xh.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function y3e(t){return!t.someProp("editable",s=>s(t.state)===!1)}function Xkt(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 v3e(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 Qkt(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 _3e(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 J1={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:"'"},nne={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Jkt=typeof navigator<"u"&&/Mac/.test(navigator.platform),eNt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var xu=0;xu<10;xu++)J1[48+xu]=J1[96+xu]=String(xu);for(var xu=1;xu<=24;xu++)J1[xu+111]="F"+xu;for(var xu=65;xu<=90;xu++)J1[xu]=String.fromCharCode(xu+32),nne[xu]=String.fromCharCode(xu);for(var phe in J1)nne.hasOwnProperty(phe)||(nne[phe]=J1[phe]);function tNt(t){var s=Jkt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||eNt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?nne:J1)[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 sNt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),rNt=typeof navigator<"u"&&/Win/.test(navigator.platform);function nNt(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 OUe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const RUe=(t,s,r)=>{let n=OUe(t,r);if(!n)return!1;let a=Y1e(n);if(!a){let l=n.blockRange(),i=l&&V3(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(WUe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(K5(o,"end")||ja.isSelectable(o)))for(let l=n.depth;;l--){let i=moe(t.doc,n.before(l),n.after(l),cn.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},oNt=(t,s,r)=>{let n=OUe(t,r);if(!n)return!1;let a=Y1e(n);return a?FUe(t,a,s):!1},lNt=(t,s,r)=>{let n=BUe(t,r);if(!n)return!1;let a=X1e(n);return a?FUe(t,a,s):!1};function FUe(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 f=a.lastChild;if(!f)return!1;a=f}let l=s.nodeAfter,i=l,d=s.pos+1;for(;!i.isTextblock;d++){if(i.type.spec.isolating)return!1;let f=i.firstChild;if(!f)return!1;i=f}let h=moe(t.doc,o,d,cn.empty);if(!h||h.from!=o||h instanceof Kd&&h.slice.size>=d-o)return!1;if(r){let f=t.tr.step(h);f.setSelection(Ea.create(f.doc,o)),r(f.scrollIntoView())}return!0}function K5(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 zUe=(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=Y1e(n)}let l=o&&o.nodeBefore;return!l||!ja.isSelectable(l)?!1:(s&&s(t.tr.setSelection(ja.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function Y1e(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 BUe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=BUe(t,r);if(!n)return!1;let a=X1e(n);if(!a)return!1;let o=a.nodeAfter;if(WUe(t,a,s,1))return!0;if(n.parent.content.size==0&&(K5(o,"start")||ja.isSelectable(o))){let l=moe(t.doc,n.before(),n.after(),cn.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 ja,a;if(n){if(r.node.isTextblock||!m_(t.doc,r.from))return!1;a=r.from}else if(a=hoe(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(ja.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},dNt=(t,s)=>{let r=t.selection,n;if(r instanceof ja){if(r.node.isTextblock||!m_(t.doc,r.to))return!1;n=r.to}else if(n=hoe(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},uNt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&V3(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},qUe=(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 Q1e(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=Q1e(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(Za.near(d.doc.resolve(i),1)),s(d.scrollIntoView())}return!0},VUe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof sp||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=Q1e(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(i0(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&V3(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function mNt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof ja&&s.selection.node.isBlock)return!n.parentOffset||!i0(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,h=!1;for(let _=n.depth;;_--)if(n.node(_).isBlock){d=n.end(_)==n.pos+(n.depth-_),h=n.start(_)==n.pos-(n.depth-_),i=Q1e(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 f=s.tr;(s.selection instanceof Ea||s.selection instanceof sp)&&f.deleteSelection();let g=f.mapping.map(n.pos),v=i0(f.doc,g,o.length,o);if(v||(o[0]=i?{type:i}:null,v=i0(f.doc,g,o.length,o)),!v)return!1;if(f.split(g,o.length,o),!d&&h&&n.node(l).type!=i){let _=f.mapping.map(n.before(l)),j=f.doc.resolve(_);i&&n.node(l-1).canReplaceWith(j.index(),j.index()+1,i)&&f.setNodeMarkup(f.mapping.map(n.before(l)),i)}return r&&r(f.scrollIntoView()),!0}}const pNt=mNt(),fNt=(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(ja.create(t.doc,a))),!0)};function gNt(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||m_(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function WUe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&gNt(t,s,r))return!0;let h=!d&&s.parent.canReplace(s.index(),s.index()+1);if(h&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(r){let _=s.pos+o.nodeSize,j=jr.empty;for(let M=l.length-1;M>=0;M--)j=jr.from(l[M].create(null,j));j=jr.from(a.copy(j));let w=t.tr.step(new eu(s.pos-1,_,s.pos,_,new cn(j,1,0),l.length,!0)),k=w.doc.resolve(_+2*l.length);k.nodeAfter&&k.nodeAfter.type==a.type&&m_(w.doc,k.pos)&&w.join(k.pos),r(w.scrollIntoView())}return!0}let f=o.type.spec.isolating||n>0&&d?null:Za.findFrom(s,1),g=f&&f.$from.blockRange(f.$to),v=g&&V3(g);if(v!=null&&v>=s.depth)return r&&r(t.tr.lift(g,v).scrollIntoView()),!0;if(h&&K5(o,"start",!0)&&K5(a,"end")){let _=a,j=[];for(;j.push(_),!_.isTextblock;)_=_.lastChild;let w=o,k=1;for(;!w.isTextblock;w=w.firstChild)k++;if(_.canReplace(_.childCount,_.childCount,w.content)){if(r){let M=jr.empty;for(let E=j.length-1;E>=0;E--)M=jr.from(j[E].copy(M));let S=t.tr.step(new eu(s.pos-j.length,s.pos+o.nodeSize,s.pos+k,s.pos+o.nodeSize-k,new cn(M,j.length,0),0,!0));r(S.scrollIntoView())}return!0}}return!1}function GUe(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(Ea.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const xNt=GUe(-1),yNt=GUe(1);function vNt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&O1e(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function b3e(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 f=r.doc.resolve(h),g=f.index();a=f.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 Xre(d,d,s.depth),s.endIndex=0;f--)o=jr.from(r[f].type.create(r[f].attrs,o));t.step(new eu(s.start-(n?2:0),s.end,s.start,s.end,new cn(o,0,0),r.length,!0));let l=0;for(let f=0;fl.childCount>0&&l.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?kNt(s,r,t,o):NNt(s,r,o):!0:!1}}function kNt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);ow;j--)_-=a.child(j).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,h=o.node(-1),f=o.index(-1);if(!h.canReplace(f+(i?0:1),f+1,l.content.append(d?jr.empty:jr.from(a))))return!1;let g=o.pos,v=g+l.nodeSize;return n.step(new eu(g-(i?1:0),v+(d?1:0),g+1,v-1,new cn((i?jr.empty:jr.from(a.copy(jr.empty))).append(d?jr.empty:jr.from(a.copy(jr.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function SNt(t){return function(s,r){let{$from:n,$to:a}=s.selection,o=n.blockRange(a,h=>h.childCount>0&&h.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 h=d.lastChild&&d.lastChild.type==i.type,f=jr.from(h?t.create():null),g=new cn(jr.from(t.create(null,jr.from(i.type.create(null,f)))),h?3:1,0),v=o.start,_=o.end;r(s.tr.step(new eu(v-(h?3:1),_,v,_,g,1,!0)).scrollIntoView())}return!0}}function yoe(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 voe{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,(...f)=>{const g=d(...f)(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,h=s||o.tr,f=()=>(!d&&r&&!h.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(h),i.every(v=>v===!0)),g={...Object.fromEntries(Object.entries(n).map(([v,_])=>[v,(...w)=>{const k=this.buildProps(h,r),M=_(...w)(k);return i.push(M),g}])),run:f};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,h])=>[d,(...f)=>h(...f)({...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:yoe({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,h])=>[d,(...f)=>h(...f)(i)]))}};return i}}let CNt=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 Kn(t,s,r){return t.config[s]===void 0&&t.parent?Kn(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?Kn(t.parent,s,r):null}):t.config[s]}function _oe(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 KUe(t){const s=[],{nodeExtensions:r,markExtensions:n}=_oe(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=Kn(l,"addGlobalAttributes",i);if(!d)return;d().forEach(f=>{f.types.forEach(g=>{Object.entries(f.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=Kn(l,"addAttributes",i);if(!d)return;const h=d();Object.entries(h).forEach(([f,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:f,attribute:v})})}),s}function su(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 fc(...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(" "):[],h=i.filter(f=>!d.includes(f));n[a]=[...d,...h].join(" ")}else if(a==="style"){const i=o?o.split(";").map(f=>f.trim()).filter(Boolean):[],d=n[a]?n[a].split(";").map(f=>f.trim()).filter(Boolean):[],h=new Map;d.forEach(f=>{const[g,v]=f.split(":").map(_=>_.trim());h.set(g,v)}),i.forEach(f=>{const[g,v]=f.split(":").map(_=>_.trim());h.set(g,v)}),n[a]=Array.from(h.entries()).map(([f,g])=>`${f}: ${g}`).join("; ")}else n[a]=o}),n},{})}function xge(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)=>fc(r,n),{})}function ZUe(t){return typeof t=="function"}function Li(t,s=void 0,...r){return ZUe(t)?s?t.bind(s)(...r):t(...r):t}function MNt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function TNt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function w3e(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):TNt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function j3e(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&MNt(r)?!1:r!=null))}function ANt(t,s){var r;const n=KUe(t),{nodeExtensions:a,markExtensions:o}=_oe(t),l=(r=a.find(h=>Kn(h,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(h=>{const f=n.filter(M=>M.type===h.name),g={name:h.name,options:h.options,storage:h.storage,editor:s},v=t.reduce((M,S)=>{const E=Kn(S,"extendNodeSchema",g);return{...M,...E?E(h):{}}},{}),_=j3e({...v,content:Li(Kn(h,"content",g)),marks:Li(Kn(h,"marks",g)),group:Li(Kn(h,"group",g)),inline:Li(Kn(h,"inline",g)),atom:Li(Kn(h,"atom",g)),selectable:Li(Kn(h,"selectable",g)),draggable:Li(Kn(h,"draggable",g)),code:Li(Kn(h,"code",g)),whitespace:Li(Kn(h,"whitespace",g)),linebreakReplacement:Li(Kn(h,"linebreakReplacement",g)),defining:Li(Kn(h,"defining",g)),isolating:Li(Kn(h,"isolating",g)),attrs:Object.fromEntries(f.map(M=>{var S;return[M.name,{default:(S=M==null?void 0:M.attribute)===null||S===void 0?void 0:S.default}]}))}),j=Li(Kn(h,"parseHTML",g));j&&(_.parseDOM=j.map(M=>w3e(M,f)));const w=Kn(h,"renderHTML",g);w&&(_.toDOM=M=>w({node:M,HTMLAttributes:xge(M,f)}));const k=Kn(h,"renderText",g);return k&&(_.toText=k),[h.name,_]})),d=Object.fromEntries(o.map(h=>{const f=n.filter(k=>k.type===h.name),g={name:h.name,options:h.options,storage:h.storage,editor:s},v=t.reduce((k,M)=>{const S=Kn(M,"extendMarkSchema",g);return{...k,...S?S(h):{}}},{}),_=j3e({...v,inclusive:Li(Kn(h,"inclusive",g)),excludes:Li(Kn(h,"excludes",g)),group:Li(Kn(h,"group",g)),spanning:Li(Kn(h,"spanning",g)),code:Li(Kn(h,"code",g)),attrs:Object.fromEntries(f.map(k=>{var M;return[k.name,{default:(M=k==null?void 0:k.attribute)===null||M===void 0?void 0:M.default}]}))}),j=Li(Kn(h,"parseHTML",g));j&&(_.parseDOM=j.map(k=>w3e(k,f)));const w=Kn(h,"renderHTML",g);return w&&(_.toDOM=k=>w({mark:k,HTMLAttributes:xge(k,f)})),[h.name,_]}));return new O$e({topNode:l,nodes:i,marks:d})}function ghe(t,s){return s.nodes[t]||s.marks[t]||null}function k3e(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function e_e(t,s){const r=SN.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const ENt=(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,h;const f=((h=(d=a.type.spec).toText)===null||h===void 0?void 0:h.call(d,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";r+=a.isAtom&&!a.isText?f:f.slice(0,Math.max(0,n-o))}),r};function t_e(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class boe{constructor(s){this.find=s.find,this.handler=s.handler}}const INt=(t,s)=>{if(t_e(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 YO(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 h=d.state.doc.resolve(n);if(h.parent.type.spec.code||!((s=h.nodeBefore||h.nodeAfter)===null||s===void 0)&&s.marks.find(v=>v.type.spec.code))return!1;let f=!1;const g=ENt(h)+o;return l.forEach(v=>{if(f)return;const _=INt(g,v.find);if(!_)return;const j=d.state.tr,w=yoe({state:d.state,transaction:j}),k={from:n-(_[0].length-o.length),to:a},{commands:M,chain:S,can:E}=new voe({editor:r,state:w});v.handler({state:w,range:k,match:_,commands:M,chain:S,can:E})===null||!j.steps.length||(j.setMeta(i,{transform:j,from:n,to:a,text:o}),d.dispatch(j),f=!0)}),f}function PNt(t){const{editor:s,rules:r}=t,n=new Pd({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:f}=d;typeof f=="string"?f=f:f=e_e(jr.from(f),l.schema);const{from:g}=d,v=g+f.length;YO({editor:s,from:g,to:v,text:f,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return YO({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&YO({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?YO({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function LNt(t){return Object.prototype.toString.call(t).slice(8,-1)}function XO(t){return LNt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function woe(t,s){const r={...t};return XO(t)&&XO(s)&&Object.keys(s).forEach(n=>{XO(s[n])&&XO(t[n])?r[n]=woe(t[n],s[n]):r[n]=s[n]}),r}class $x{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=Li(Kn(this,"addOptions",{name:this.name}))),this.storage=Li(Kn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new $x(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>woe(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new $x(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=Li(Kn(r,"addOptions",{name:r.name})),r.storage=Li(Kn(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(h=>(h==null?void 0:h.type.name)===r.name))return!1;const d=l.find(h=>(h==null?void 0:h.type.name)===r.name);return d&&n.removeStoredMark(d),n.insertText(" ",a.pos),s.view.dispatch(n),!0}return!1}}function DNt(t){return typeof t=="number"}class ONt{constructor(s){this.find=s.find,this.handler=s.handler}}const RNt=(t,s,r)=>{if(t_e(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 FNt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:h,can:f}=new voe({editor:s,state:r}),g=[];return r.doc.nodesBetween(n,a,(_,j)=>{if(!_.isTextblock||_.type.spec.code)return;const w=Math.max(n,j),k=Math.min(a,j+_.content.size),M=_.textBetween(w-j,k-j,void 0,"");RNt(M,o.find,l).forEach(E=>{if(E.index===void 0)return;const D=w+E.index+1,L=D+E[0].length,B={from:r.tr.mapping.map(D),to:r.tr.mapping.map(L)},$=o.handler({state:r,range:B,match:E,commands:d,chain:h,can:f,pasteEvent:l,dropEvent:i});g.push($)})}),g.every(_=>_!==null)}let QO=null;const zNt=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 BNt(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:f,from:g,to:v,rule:_,pasteEvt:j})=>{const w=f.tr,k=yoe({state:f,transaction:w});if(!(!FNt({editor:s,state:k,from:Math.max(g-1,0),to:v.b-1,rule:_,pasteEvent:j,dropEvent:i})||!w.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return r.map(f=>new Pd({view(g){const v=j=>{var w;n=!((w=g.dom.parentElement)===null||w===void 0)&&w.contains(j.target)?g.dom.parentElement:null,n&&(QO=s)},_=()=>{QO&&(QO=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 _=QO;_!=null&&_.isEditable&&setTimeout(()=>{const j=_.state.selection;j&&_.commands.deleteRange({from:j.from,to:j.to})},10)}return!1},paste:(g,v)=>{var _;const j=(_=v.clipboardData)===null||_===void 0?void 0:_.getData("text/html");return l=v,a=!!(j!=null&&j.includes("data-pm-slice")),!1}}},appendTransaction:(g,v,_)=>{const j=g[0],w=j.getMeta("uiEvent")==="paste"&&!a,k=j.getMeta("uiEvent")==="drop"&&!o,M=j.getMeta("applyPasteRules"),S=!!M;if(!w&&!k&&!S)return;if(S){let{text:L}=M;typeof L=="string"?L=L:L=e_e(jr.from(L),_.schema);const{from:B}=M,$=B+L.length,V=zNt(L);return d({rule:f,state:_,from:B,to:{b:$},pasteEvt:V})}const E=v.doc.content.findDiffStart(_.doc.content),D=v.doc.content.findDiffEnd(_.doc.content);if(!(!DNt(E)||!D||E===D.b))return d({rule:f,state:_,from:E,to:D,pasteEvt:l})}}))}function $Nt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class n4{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=n4.resolve(s),this.schema=ANt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=n4.sort(n4.flatten(s)),n=$Nt(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=Kn(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=Kn(n,"priority")||100,l=Kn(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:ghe(r.name,this.schema)},a=Kn(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=n4.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:ghe(l.name,this.schema)},d=[],h=Kn(l,"addKeyboardShortcuts",i);let f={};if(l.type==="mark"&&Kn(l,"exitable",i)&&(f.ArrowRight=()=>$x.handleExit({editor:s,mark:l})),h){const w=Object.fromEntries(Object.entries(h()).map(([k,M])=>[k,()=>M({editor:s})]));f={...f,...w}}const g=iNt(f);d.push(g);const v=Kn(l,"addInputRules",i);k3e(l,s.options.enableInputRules)&&v&&n.push(...v());const _=Kn(l,"addPasteRules",i);k3e(l,s.options.enablePasteRules)&&_&&a.push(..._());const j=Kn(l,"addProseMirrorPlugins",i);if(j){const w=j();d.push(...w)}return d}).flat();return[PNt({editor:s,rules:n}),...BNt({editor:s,rules:a}),...o]}get attributes(){return KUe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=_oe(this.extensions);return Object.fromEntries(r.filter(n=>!!Kn(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:su(n.name,this.schema)},l=Kn(n,"addNodeView",o);if(!l)return[];const i=(d,h,f,g,v)=>{const _=xge(d,a);return l()({node:d,view:h,getPos:f,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:ghe(s.name,this.schema)};s.type==="mark"&&(!((r=Li(Kn(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=Kn(s,"onBeforeCreate",n),o=Kn(s,"onCreate",n),l=Kn(s,"onUpdate",n),i=Kn(s,"onSelectionUpdate",n),d=Kn(s,"onTransaction",n),h=Kn(s,"onFocus",n),f=Kn(s,"onBlur",n),g=Kn(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),h&&this.editor.on("focus",h),f&&this.editor.on("blur",f),g&&this.editor.on("destroy",g)})}}class wu{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=Li(Kn(this,"addOptions",{name:this.name}))),this.storage=Li(Kn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new wu(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>woe(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new wu({...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=Li(Kn(r,"addOptions",{name:r.name})),r.storage=Li(Kn(r,"addStorage",{name:r.name,options:r.options})),r}}function YUe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(d,h,f,g)=>{var v;d.isBlock&&h>n&&(i+=o);const _=l==null?void 0:l[d.type.name];if(_)return f&&(i+=_({node:d,pos:h,parent:f,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,h)-h,a-h))}),i}function XUe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const UNt=wu.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Pd({key:new Ku("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(f=>f.$from.pos)),i=Math.max(...o.map(f=>f.$to.pos)),d=XUe(r);return YUe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),qNt=()=>({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),VNt=(t=!1)=>({commands:s})=>s.setContent("",t),HNt=()=>({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:h,mapping:f}=s,g=h.resolve(f.map(d)),v=h.resolve(f.map(d+i.nodeSize)),_=g.blockRange(v);if(!_)return;const j=V3(_);if(i.type.isTextblock){const{defaultType:w}=g.parent.contentMatchAt(g.index());s.setNodeMarkup(_.start,w)}(j||j===0)&&s.lift(_,j)})}),!0},WNt=t=>s=>t(s),GNt=()=>({state:t,dispatch:s})=>VUe(t,s),KNt=(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 Ea(n.doc.resolve(Math.max(l-1,0)))),!0},ZNt=()=>({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},YNt=t=>({tr:s,state:r,dispatch:n})=>{const a=su(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),h=o.after(l);s.delete(d,h).scrollIntoView()}return!0}return!1},XNt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},QNt=()=>({state:t,dispatch:s})=>Z1e(t,s),JNt=()=>({commands:t})=>t.keyboardShortcut("Enter"),eSt=()=>({state:t,dispatch:s})=>hNt(t,s);function ane(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:t_e(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function QUe(t,s,r={}){return t.find(n=>n.type===s&&ane(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function N3e(t,s,r={}){return!!QUe(t,s,r)}function s_e(t,s,r){var n;if(!t||!s)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(f=>f.type===s))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(f=>f.type===s)||(r=r||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!QUe([...a.node.marks],s,r)))return;let l=a.index,i=t.start()+a.offset,d=l+1,h=i+a.node.nodeSize;for(;l>0&&N3e([...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=f_(t,n.schema),{doc:l,selection:i}=r,{$from:d,from:h,to:f}=i;if(a){const g=s_e(d,o,s);if(g&&g.from<=h&&g.to>=f){const v=Ea.create(l,g.from,g.to);r.setSelection(v)}}return!0},sSt=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=()=>{(r_e()||rSt())&&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&&!JUe(r.state.selection))return l(),!0;const i=eqe(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},aSt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),iSt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),tqe=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&&tqe(n)}return t};function JO(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return tqe(r)}function xP(t,s,r){if(t instanceof F1||t instanceof jr)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 jr.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),xP("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const d=new O$e({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:h=>(l=!0,i=typeof h=="string"?h:h.outerHTML,null)}]}})});if(r.slice?lI.fromSchema(d).parseSlice(JO(t),r.parseOptions):lI.fromSchema(d).parse(JO(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=lI.fromSchema(s);return r.slice?o.parseSlice(JO(t),r.parseOptions).content:o.parse(JO(t),r.parseOptions)}return xP("",s,r)}function oSt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=f)}),t.setSelection(Za.near(t.doc.resolve(l),r))}const lSt=t=>!("type"in t),cSt=(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=k=>{o.emit("contentError",{editor:o,error:k,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{xP(s,o.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(k){d(k)}try{i=xP(s,o.schema,{parseOptions:h,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(k){return d(k),!1}let{from:f,to:g}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},v=!0,_=!0;if((lSt(i)?i:[i]).forEach(k=>{k.check(),v=v?k.isText&&k.marks.length===0:!1,_=_?k.isBlock:!1}),f===g&&_){const{parent:k}=n.doc.resolve(f);k.isTextblock&&!k.type.spec.code&&!k.childCount&&(f-=1,g+=1)}let w;if(v){if(Array.isArray(s))w=s.map(k=>k.text||"").join("");else if(s instanceof jr){let k="";s.forEach(M=>{M.text&&(k+=M.text)}),w=k}else typeof s=="object"&&s&&s.text?w=s.text:w=s;n.insertText(w,f,g)}else w=i,n.replaceWith(f,g,w);r.updateSelection&&oSt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:f,text:w}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:f,text:w})}return!0},dSt=()=>({state:t,dispatch:s})=>cNt(t,s),uSt=()=>({state:t,dispatch:s})=>dNt(t,s),hSt=()=>({state:t,dispatch:s})=>RUe(t,s),mSt=()=>({state:t,dispatch:s})=>$Ue(t,s),pSt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=hoe(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},fSt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=hoe(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},gSt=()=>({state:t,dispatch:s})=>oNt(t,s),xSt=()=>({state:t,dispatch:s})=>lNt(t,s);function sqe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ySt(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=ySt(t).split(/-(?!$)/),l=o.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),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",h=>h(r,i))});return d==null||d.steps.forEach(h=>{const f=h.map(n.mapping);f&&a&&n.maybeStep(f)}),!0};function yP(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?su(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(g,v)=>{if(g.isText)return;const _=Math.max(n,v),j=Math.min(a,v+g.nodeSize);i.push({node:g,from:_,to:j})});const d=a-n,h=i.filter(g=>l?l.name===g.node.type.name:!0).filter(g=>ane(g.node.attrs,r,{strict:!1}));return o?!!h.length:h.reduce((g,v)=>g+v.to-v.from,0)>=d}const _St=(t,s={})=>({state:r,dispatch:n})=>{const a=su(t,r.schema);return yP(r,a,s)?uNt(r,n):!1},bSt=()=>({state:t,dispatch:s})=>HUe(t,s),wSt=t=>({state:s,dispatch:r})=>{const n=su(t,s.schema);return jNt(n)(s,r)},jSt=()=>({state:t,dispatch:s})=>qUe(t,s);function joe(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function S3e(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 kSt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=joe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=su(t,n.schema)),i==="mark"&&(l=f_(t,n.schema)),a&&r.selection.ranges.forEach(d=>{n.doc.nodesBetween(d.$from.pos,d.$to.pos,(h,f)=>{o&&o===h.type&&r.setNodeMarkup(f,void 0,S3e(h.attrs,s)),l&&h.marks.length&&h.marks.forEach(g=>{l===g.type&&r.addMark(f,f+h.nodeSize,l.create(S3e(g.attrs,s)))})})}),!0):!1},NSt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),SSt=()=>({tr:t,dispatch:s})=>{if(s){const r=new sp(t.doc);t.setSelection(r)}return!0},CSt=()=>({state:t,dispatch:s})=>zUe(t,s),MSt=()=>({state:t,dispatch:s})=>UUe(t,s),TSt=()=>({state:t,dispatch:s})=>fNt(t,s),ASt=()=>({state:t,dispatch:s})=>yNt(t,s),ESt=()=>({state:t,dispatch:s})=>xNt(t,s);function yge(t,s,r={},n={}){return xP(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const ISt=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var d,h;const{doc:f}=o;if(r.preserveWhitespace!=="full"){const g=yge(t,a.schema,r,{errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:a.options.enableContentCheck});return l&&o.replaceWith(0,f.content.size,g).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:f.content.size},t,{parseOptions:r,errorOnInvalidContent:(h=n.errorOnInvalidContent)!==null&&h!==void 0?h:a.options.enableContentCheck})};function rqe(t,s){const r=f_(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 PSt(t,s){const r=new R1e(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function LSt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function nqe(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 n_e(t){return s=>nqe(s.$from,t)}function OSt(t,s){const r={from:0,to:t.content.size};return YUe(t,r,s)}function RSt(t,s){const r=su(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 aqe(t,s){const r=joe(typeof s=="string"?s:s.name,t.schema);return r==="node"?RSt(t,s):r==="mark"?rqe(t,s):{}}function FSt(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 zSt(t){const s=FSt(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 BSt(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 h=s.slice(o).map(i,-1),f=s.slice(o).map(d),g=s.invert().map(h,-1),v=s.invert().map(f);n.push({oldRange:{from:g,to:v},newRange:{from:h,to:f}})})}),zSt(n)}function a_e(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=s_e(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 Mse(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 vge(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?f_(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(g=>o?o.name===g.type.name:!0).find(g=>ane(g.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:g,$to:v})=>{const _=g.pos,j=v.pos;t.doc.nodesBetween(_,j,(w,k)=>{if(!w.isText&&!w.marks.length)return;const M=Math.max(_,k),S=Math.min(j,k+w.nodeSize),E=S-M;l+=E,i.push(...w.marks.map(D=>({mark:D,from:M,to:S})))})}),l===0)return!1;const d=i.filter(g=>o?o.name===g.mark.type.name:!0).filter(g=>ane(g.mark.attrs,r,{strict:!1})).reduce((g,v)=>g+v.to-v.from,0),h=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+h:d)>=l}function $St(t,s,r={}){if(!s)return yP(t,null,r)||vge(t,null,r);const n=joe(s,t.schema);return n==="node"?yP(t,s,r):n==="mark"?vge(t,s,r):!1}function C3e(t,s){const{nodeExtensions:r}=_oe(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=Li(Kn(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function i_e(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&&(i_e(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function USt(t){return t instanceof ja}function qSt(t,s,r){var n;const{selection:a}=s;let o=null;if(JUe(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 h=i.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(i.pos,d.pos,(f,g,v)=>{if(h)return!1;if(f.isInline){const _=!v||v.type.allowsMarkType(r),j=!!r.isInSet(f.marks)||!f.marks.some(w=>w.type.excludes(r));h=_&&j}return!h}),h})}const VSt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,d=f_(t,n.schema);if(a)if(l){const h=rqe(n,d);r.addStoredMark(d.create({...h,...s}))}else i.forEach(h=>{const f=h.$from.pos,g=h.$to.pos;n.doc.nodesBetween(f,g,(v,_)=>{const j=Math.max(_,f),w=Math.min(_+v.nodeSize,g);v.marks.find(M=>M.type===d)?v.marks.forEach(M=>{d===M.type&&r.addMark(j,w,d.create({...M.attrs,...s}))}):r.addMark(j,w,d.create(s))})});return qSt(n,r,d)},HSt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),WSt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=su(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})=>b3e(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>b3e(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},GSt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=Xj(t,0,n.content.size),o=ja.create(n,a);s.setSelection(o)}return!0},KSt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=Ea.atStart(n).from,i=Ea.atEnd(n).to,d=Xj(a,l,i),h=Xj(o,l,i),f=Ea.create(n,d,h);s.setSelection(f)}return!0},ZSt=t=>({state:s,dispatch:r})=>{const n=su(t,s.schema);return SNt(n)(s,r)};function M3e(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 YSt=({keepMarks:t=!0}={})=>({tr:s,state:r,dispatch:n,editor:a})=>{const{selection:o,doc:l}=s,{$from:i,$to:d}=o,h=a.extensionManager.attributes,f=Mse(h,i.node().type.name,i.node().attrs);if(o instanceof ja&&o.node.isBlock)return!i.parentOffset||!i0(l,i.pos)?!1:(n&&(t&&M3e(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:LSt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=g&&v?[{type:v,attrs:f}]:void 0,j=i0(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!j&&i0(s.doc,s.mapping.map(i.pos),1,v?[{type:v}]:void 0)&&(j=!0,_=v?[{type:v,attrs:f}]:void 0),n){if(j&&(o instanceof Ea&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),v&&!g&&!i.parentOffset&&i.parent.type!==v)){const w=s.mapping.map(i.before()),k=s.doc.resolve(w);i.node(-1).canReplaceWith(k.index(),k.index()+1,v)&&s.setNodeMarkup(s.mapping.map(i.before()),v)}t&&M3e(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return j},XSt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=su(t,n.schema),{$from:d,$to:h}=n.selection,f=n.selection.node;if(f&&f.isBlock||d.depth<2||!d.sameParent(h))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 M=jr.empty;const S=d.index(-1)?1:d.index(-2)?2:3;for(let V=d.depth-S;V>=d.depth-3;V-=1)M=jr.from(d.node(V).copy(M));const E=d.indexAfter(-1){if($>-1)return!1;V.isTextblock&&V.content.size===0&&($=W+1)}),$>-1&&r.setSelection(Ea.near(r.doc.resolve($))),r.scrollIntoView()}return!0}const _=h.pos===d.end()?g.contentMatchAt(0).defaultType:null,j={...Mse(v,g.type.name,g.attrs),...s},w={...Mse(v,d.node().type.name,d.node().attrs),...s};r.delete(d.pos,h.pos);const k=_?[{type:i,attrs:j},{type:_,attrs:w}]:[{type:i,attrs:j}];if(!i0(r.doc,d.pos,2))return!1;if(a){const{selection:M,storedMarks:S}=n,{splittableMarks:E}=o.extensionManager,D=S||M.$to.parentOffset&&M.$from.marks();if(r.split(d.pos,2,k).scrollIntoView(),!D||!a)return!0;const L=D.filter(B=>E.includes(B.type.name));r.ensureMarks(L)}return!0},xhe=(t,s)=>{const r=n_e(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)&&m_(t.doc,r.pos)&&t.join(r.pos),!0},yhe=(t,s)=>{const r=n_e(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)&&m_(t.doc,n)&&t.join(n),!0},QSt=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:h,can:f})=>{const{extensions:g,splittableMarks:v}=a.extensionManager,_=su(t,l.schema),j=su(s,l.schema),{selection:w,storedMarks:k}=l,{$from:M,$to:S}=w,E=M.blockRange(S),D=k||w.$to.parentOffset&&w.$from.marks();if(!E)return!1;const L=n_e(B=>C3e(B.type.name,g))(w);if(E.depth>=1&&L&&E.depth-L.depth<=1){if(L.node.type===_)return h.liftListItem(j);if(C3e(L.node.type.name,g)&&_.validContent(L.node.content)&&i)return d().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>xhe(o,_)).command(()=>yhe(o,_)).run()}return!r||!D||!i?d().command(()=>f().wrapInList(_,n)?!0:h.clearNodes()).wrapInList(_,n).command(()=>xhe(o,_)).command(()=>yhe(o,_)).run():d().command(()=>{const B=f().wrapInList(_,n),$=D.filter(V=>v.includes(V.type.name));return o.ensureMarks($),B?!0:h.clearNodes()}).wrapInList(_,n).command(()=>xhe(o,_)).command(()=>yhe(o,_)).run()},JSt=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=f_(t,n.schema);return vge(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},eCt=(t,s,r={})=>({state:n,commands:a})=>{const o=su(t,n.schema),l=su(s,n.schema),i=yP(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})},tCt=(t,s={})=>({state:r,commands:n})=>{const a=su(t,r.schema);return yP(r,a,s)?n.lift(a):n.wrapIn(a,s)},sCt=()=>({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},rCt=()=>({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},nCt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,d=f_(t,n.schema),{$from:h,empty:f,ranges:g}=i;if(!a)return!0;if(f&&l){let{from:v,to:_}=i;const j=(o=h.marks().find(k=>k.type===d))===null||o===void 0?void 0:o.attrs,w=s_e(h,d,j);w&&(v=w.from,_=w.to),r.removeMark(v,_,d)}else g.forEach(v=>{r.removeMark(v.$from.pos,v.$to.pos,d)});return r.removeStoredMark(d),!0},aCt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=joe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=su(t,n.schema)),i==="mark"&&(l=f_(t,n.schema)),a&&r.selection.ranges.forEach(d=>{const h=d.$from.pos,f=d.$to.pos;let g,v,_,j;r.selection.empty?n.doc.nodesBetween(h,f,(w,k)=>{o&&o===w.type&&(_=Math.max(k,h),j=Math.min(k+w.nodeSize,f),g=k,v=w)}):n.doc.nodesBetween(h,f,(w,k)=>{k=h&&k<=f&&(o&&o===w.type&&r.setNodeMarkup(k,void 0,{...w.attrs,...s}),l&&w.marks.length&&w.marks.forEach(M=>{if(l===M.type){const S=Math.max(k,h),E=Math.min(k+w.nodeSize,f);r.addMark(S,E,l.create({...M.attrs,...s}))}}))}),v&&(g!==void 0&&r.setNodeMarkup(g,void 0,{...v.attrs,...s}),l&&v.marks.length&&v.marks.forEach(w=>{l===w.type&&r.addMark(_,j,l.create({...w.attrs,...s}))}))}),!0):!1},iCt=(t,s={})=>({state:r,dispatch:n})=>{const a=su(t,r.schema);return vNt(a,s)(r,n)},oCt=(t,s={})=>({state:r,dispatch:n})=>{const a=su(t,r.schema);return _Nt(a,s)(r,n)};var lCt=Object.freeze({__proto__:null,blur:qNt,clearContent:VNt,clearNodes:HNt,command:WNt,createParagraphNear:GNt,cut:KNt,deleteCurrentNode:ZNt,deleteNode:YNt,deleteRange:XNt,deleteSelection:QNt,enter:JNt,exitCode:eSt,extendMarkRange:tSt,first:sSt,focus:nSt,forEach:aSt,insertContent:iSt,insertContentAt:cSt,joinBackward:hSt,joinDown:uSt,joinForward:mSt,joinItemBackward:pSt,joinItemForward:fSt,joinTextblockBackward:gSt,joinTextblockForward:xSt,joinUp:dSt,keyboardShortcut:vSt,lift:_St,liftEmptyBlock:bSt,liftListItem:wSt,newlineInCode:jSt,resetAttributes:kSt,scrollIntoView:NSt,selectAll:SSt,selectNodeBackward:CSt,selectNodeForward:MSt,selectParentNode:TSt,selectTextblockEnd:ASt,selectTextblockStart:ESt,setContent:ISt,setMark:VSt,setMeta:HSt,setNode:WSt,setNodeSelection:GSt,setTextSelection:KSt,sinkListItem:ZSt,splitBlock:YSt,splitListItem:XSt,toggleList:QSt,toggleMark:JSt,toggleNode:eCt,toggleWrap:tCt,undoInputRule:sCt,unsetAllMarks:rCt,unsetMark:nCt,updateAttributes:aCt,wrapIn:iCt,wrapInList:oCt});const cCt=wu.create({name:"commands",addCommands(){return{...lCt}}}),dCt=wu.create({name:"drop",addProseMirrorPlugins(){return[new Pd({key:new Ku("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),uCt=wu.create({name:"editable",addProseMirrorPlugins(){return[new Pd({key:new Ku("editable"),props:{editable:()=>this.editor.options.editable}})]}}),hCt=new Ku("focusEvents"),mCt=wu.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Pd({key:hCt,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}}}})]}}),pCt=wu.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:d,doc:h}=i,{empty:f,$anchor:g}=d,{pos:v,parent:_}=g,j=g.parent.isTextblock&&v>0?i.doc.resolve(v-1):g,w=j.parent.type.spec.isolating,k=g.pos-g.parentOffset,M=w&&j.parent.childCount===1?k===g.pos:Za.atStart(h).from===v;return!f||!_.type.isTextblock||_.textContent.length||!M||M&&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 r_e()||sqe()?o:a},addProseMirrorPlugins(){return[new Pd({key:new Ku("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(w=>w.getMeta("composition")))return;const n=t.some(w=>w.docChanged)&&!s.doc.eq(r.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,d=Za.atStart(s.doc).from,h=Za.atEnd(s.doc).to;if(o||!(l===d&&i===h)||!i_e(r.doc))return;const v=r.tr,_=yoe({state:r,transaction:v}),{commands:j}=new voe({editor:this.editor,state:_});if(j.clearNodes(),!!v.steps.length)return v}})]}}),fCt=wu.create({name:"paste",addProseMirrorPlugins(){return[new Pd({key:new Ku("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),gCt=wu.create({name:"tabindex",addProseMirrorPlugins(){return[new Pd({key:new Ku("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class $j{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 $j(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 $j(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 $j(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 $j(i,this.editor,a,a?r:null);a&&(d.actualDepth=this.depth+1),s.push(new $j(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 xCt=`.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 yCt(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 vCt extends CNt{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=yCt(xCt,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=ZUe(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?[uCt,UNt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),cCt,mCt,pCt,gCt,dCt,fCt].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 n4(a,this)}createCommandManager(){this.commandManager=new voe({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=yge(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=yge(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=eqe(r,this.options.autofocus);this.view=new DUe(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:r4.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 aqe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return $St(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return e_e(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return OSt(this.state.doc,{blockSeparator:r,textSerializers:{...XUe(this.schema),...n}})}get isEmpty(){return i_e(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 $j(r,this)}get $doc(){return this.$pos(0)}}function Z5(t){return new boe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Li(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/),h=r.from+i.indexOf(l),f=h+l.length;if(a_e(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(w=>w===t.type&&w!==_.mark.type)).filter(_=>_.to>h).length)return null;fr.from&&o.delete(r.from+d,h);const v=r.from+d+l.length;o.addMark(r.from+d,v,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function iqe(t){return new boe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Li(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 h=n[0].lastIndexOf(n[1]);let f=l+h;f>i?f=i:i=f+n[1].length;const g=n[0][n[0].length-1];o.insertText(g,l+n[0].length-1),o.replaceWith(f,i,d)}else if(n[0]){const h=t.type.isInline?l:l-1;o.insert(h,t.type.create(a)).delete(o.mapping.map(l),o.mapping.map(i))}o.scrollIntoView()}})}function _ge(t){return new boe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=Li(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 vP(t){return new boe({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=Li(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),d=l.doc.resolve(r.from).blockRange(),h=d&&O1e(d,t.type,o);if(!h)return null;if(l.wrap(d,h),t.keepMarks&&t.editor){const{selection:g,storedMarks:v}=s,{splittableMarks:_}=t.editor.extensionManager,j=v||g.$to.parentOffset&&g.$from.marks();if(j){const w=j.filter(k=>_.includes(k.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const g=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(g,o).run()}const f=l.doc.resolve(r.from-1).nodeBefore;f&&f.type===t.type&&m_(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,f))&&l.join(r.from-1)}})}let Zu=class bge{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=Li(Kn(this,"addOptions",{name:this.name}))),this.storage=Li(Kn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new bge(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>woe(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new bge(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=Li(Kn(r,"addOptions",{name:r.name})),r.storage=Li(Kn(r,"addStorage",{name:r.name,options:r.options})),r}};function dN(t){return new ONt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=Li(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 h=r.to;if(i){const f=d.search(/\S/),g=r.from+d.indexOf(i),v=g+i.length;if(a_e(r.from,r.to,s.doc).filter(j=>j.mark.type.excluded.find(k=>k===t.type&&k!==j.mark.type)).filter(j=>j.to>g).length)return null;vr.from&&l.delete(r.from+f,g),h=r.from+f+i.length,l.addMark(r.from+f,h,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function _Ct(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof ja){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 bCt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var oqe={exports:{}},vhe={};/** * @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 T3e;function wCt(){if(T3e)return vhe;T3e=1;var t=lt;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(),j=n({inst:{value:_,getSnapshot:v}}),w=j[0].inst,k=j[1];return o(function(){w.value=_,w.getSnapshot=v,d(w)&&k({inst:w})},[g,_,v]),a(function(){return d(w)&&k({inst:w}),g(function(){d(w)&&k({inst:w})})},[g]),l(_),_}function d(g){var v=g.getSnapshot;g=g.value;try{var _=v();return!r(g,_)}catch{return!0}}function h(g,v){return v()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:i;return vhe.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,vhe}oqe.exports=wCt();var o_e=oqe.exports;const jCt=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},kCt=({contentComponent:t})=>{const s=o_e.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return lt.createElement(lt.Fragment,null,Object.values(s))};function NCt(){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]:G0e.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 SCt extends lt.Component{constructor(s){var r;super(s),this.editorContentRef=lt.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=NCt(),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 lt.createElement(lt.Fragment,null,lt.createElement("div",{ref:jCt(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&<.createElement(kCt,{contentComponent:s.contentComponent}))}}const CCt=T.forwardRef((t,s)=>{const r=lt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return lt.createElement(SCt,{key:r,innerRef:s,...t})}),lqe=lt.memo(CCt);var MCt=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},TCt=bCt(MCt),cqe={exports:{}},_he={};/** * @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 A3e;function ACt(){if(A3e)return _he;A3e=1;var t=lt,s=o_e;function r(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}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 _he.useSyncExternalStoreWithSelector=function(h,f,g,v,_){var j=o(null);if(j.current===null){var w={hasValue:!1,value:null};j.current=w}else w=j.current;j=i(function(){function M(B){if(!S){if(S=!0,E=B,B=v(B),_!==void 0&&w.hasValue){var $=w.value;if(_($,B))return D=$}return D=B}if($=D,n(E,B))return $;var V=v(B);return _!==void 0&&_($,V)?$:(E=B,D=V)}var S=!1,E,D,L=g===void 0?null:g;return[function(){return M(f())},L===null?void 0:function(){return M(L())}]},[f,g,v,_]);var k=a(h,j[0],j[1]);return l(function(){w.hasValue=!0,w.value=k},[k]),d(k),k},_he}cqe.exports=ACt();var ECt=cqe.exports;const ICt=typeof window<"u"?T.useLayoutEffect:T.useEffect;class PCt{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 LCt(t){var s;const[r]=T.useState(()=>new PCt(t.editor)),n=ECt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:TCt);return ICt(()=>r.watch(t.editor),[t.editor,r]),T.useDebugValue(n),n}const DCt=!1,wge=typeof window>"u",OCt=wge||!!(typeof window<"u"&&window.next);class l_e{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?wge||OCt?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 vCt(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?l_e.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 dqe(t={},s=[]){const r=T.useRef(t);r.current=t;const[n]=T.useState(()=>new l_e(r)),a=o_e.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return T.useDebugValue(a),T.useEffect(n.onRender(s)),LCt({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const RCt=T.createContext({editor:null});RCt.Consumer;const FCt=T.createContext({onDragStart:void 0}),zCt=()=>T.useContext(FCt);lt.forwardRef((t,s)=>{const{onDragStart:r}=zCt(),n=t.as||"div";return lt.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const BCt=/^\s*>\s$/,$Ct=Zu.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",fc(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[vP({find:BCt,type:this.type})]}}),UCt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,qCt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,VCt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,HCt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,WCt=$x.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",fc(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[Z5({find:UCt,type:this.type}),Z5({find:VCt,type:this.type})]},addPasteRules(){return[dN({find:qCt,type:this.type}),dN({find:HCt,type:this.type})]}}),GCt="listItem",E3e="textStyle",I3e=/^\s*([-+*])\s$/,KCt=Zu.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",fc(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(GCt,this.editor.getAttributes(E3e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=vP({find:I3e,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=vP({find:I3e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(E3e),editor:this.editor})),[t]}}),ZCt=/(^|[^`])`([^`]+)`(?!`)/,YCt=/(^|[^`])`([^`]+)`(?!`)/g,XCt=$x.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",fc(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[Z5({find:ZCt,type:this.type})]},addPasteRules(){return[dN({find:YCt,type:this.type})]}}),QCt=/^```([a-z]+)?[\s\n]$/,JCt=/^~~~([a-z]+)?[\s\n]$/,e4t=Zu.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",fc(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:h})=>(h.setSelection(Za.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[_ge({find:QCt,type:this.type,getAttributes:t=>({language:t[1]})}),_ge({find:JCt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Pd({key:new Ku("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(Ea.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),t4t=Zu.create({name:"doc",topNode:!0,content:"block+"});function s4t(t={}){return new Pd({view(s){return new r4t(s,t)}})}class r4t{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 j=_.getBoundingClientRect(),w=g?j.bottom:j.top;g&&v&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*i;n={left:j.left,right:j.right,top:w-k,bottom:w+k}}}}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 h,f;if(!d||d==document.body&&getComputedStyle(d).position=="static")h=-pageXOffset,f=-pageYOffset;else{let g=d.getBoundingClientRect(),v=g.width/d.offsetWidth,_=g.height/d.offsetHeight;h=g.left-d.scrollLeft*v,f=g.top-d.scrollTop*_}this.element.style.left=(n.left-h)/l+"px",this.element.style.top=(n.top-f)/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=G$e(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 n4t=wu.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[s4t(this.options)]}});class Nc extends Za{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return Nc.valid(n)?new Nc(n):Za.near(n)}content(){return cn.empty}eq(s){return s instanceof Nc&&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 Nc(s.resolve(r.pos))}getBookmark(){return new c_e(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!a4t(s)||!i4t(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&&Nc.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(Nc.valid(d))return d}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!ja.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(Nc.valid(i))return i}return null}}}Nc.prototype.visible=!1;Nc.findFrom=Nc.findGapCursorFrom;Za.jsonID("gapcursor",Nc);class c_e{constructor(s){this.pos=s}map(s){return new c_e(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return Nc.valid(r)?new Nc(r):Za.near(r)}}function uqe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function a4t(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||uqe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function i4t(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||uqe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function o4t(){return new Pd({props:{decorations:u4t,createSelectionBetween(t,s,r){return s.pos==r.pos&&Nc.valid(r)?new Nc(r):null},handleClick:c4t,handleKeyDown:l4t,handleDOMEvents:{beforeinput:d4t}}})}const l4t=K1e({ArrowLeft:e8("horiz",-1),ArrowRight:e8("horiz",1),ArrowUp:e8("vert",-1),ArrowDown:e8("vert",1)});function e8(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 Ea){if(!o.endOfTextblock(r)||i.depth==0)return!1;d=!1,i=n.doc.resolve(s>0?i.after():i.before())}let h=Nc.findGapCursorFrom(i,s,d);return h?(a&&a(n.tr.setSelection(new Nc(h))),!0):!1}}function c4t(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!Nc.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&ja.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Nc(n))),!0)}function d4t(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof Nc))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=jr.empty;for(let l=n.length-1;l>=0;l--)a=jr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new cn(a,0,0));return o.setSelection(Ea.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function u4t(t){if(!(t.selection instanceof Nc))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",kc.create(t.doc,[xh.widget(t.selection.head,s,{key:"gapcursor"})])}const h4t=wu.create({name:"gapCursor",addProseMirrorPlugins(){return[o4t()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=Li(Kn(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),m4t=Zu.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",fc(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:h,dispatch:f})=>{if(f&&d&&l){const g=d.filter(v=>i.includes(v.type.name));h.ensureMarks(g)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),p4t=Zu.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]}`,fc(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=>_ge({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var ine=200,tu=function(){};tu.prototype.append=function(s){return s.length?(s=tu.from(s),!this.length&&s||s.length=r?tu.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};tu.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};tu.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)};tu.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};tu.from=function(s){return s instanceof tu?s:s&&s.length?new hqe(s):tu.empty};var hqe=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<=ine)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=ine)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}(tu);tu.empty=new hqe([]);var f4t=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}(tu);const g4t=500;class sg{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,h=[],f=[];return this.items.forEach((g,v)=>{if(!g.step){a||(a=this.remapping(n,v+1),o=a.maps.length),o--,f.push(g);return}if(a){f.push(new nx(g.map));let _=g.step.map(a.slice(o)),j;_&&l.maybeStep(_).doc&&(j=l.mapping.maps[l.mapping.maps.length-1],h.push(new nx(j,void 0,void 0,h.length+f.length))),o--,j&&a.appendMap(j,o)}else l.maybeStep(g.step);if(g.selection)return i=a?g.selection.map(a.slice(o)):g.selection,d=new sg(this.items.slice(0,n).append(f.reverse().concat(h)),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 f=0;fy4t&&(i=x4t(i,h),l-=h),new sg(i.append(o),l)}remapping(s,r){let n=new hP;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 sg(this.items.append(s.map(r=>new nx(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 j=o.maps[_];if(v.step){let w=s.steps[_].invert(s.docs[_]),k=v.selection&&v.selection.map(o.slice(d+1,_));k&&i++,n.push(new nx(j,w,k))}else n.push(new nx(j))},a);let h=[];for(let v=r;vg4t&&(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)),h=d&&d.getMap();if(n--,h&&r.appendMap(h,n),d){let f=l.selection&&l.selection.map(r.slice(n));f&&o++;let g=new nx(h.invert(),d,f),v,_=a.length-1;(v=a.length&&a[_].merge(g))?a[_]=v:a.push(g)}}else l.map&&n--},this.items.length,0),new sg(tu.from(a.reverse()),o)}}sg.empty=new sg(tu.empty,0);function x4t(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class nx{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 nx(r.getMap().invert(),r,this.selection)}}}class Ov{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const y4t=20;function v4t(t,s,r,n){let a=r.getMeta(Uk),o;if(a)return a.historyState;r.getMeta(w4t)&&(t=new Ov(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(Uk))return l.getMeta(Uk).redo?new Ov(t.done.addTransform(r,void 0,n,Tse(s)),t.undone,P3e(r.mapping.maps),t.prevTime,t.prevComposition):new Ov(t.done,t.undone.addTransform(r,void 0,n,Tse(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||!_4t(r,t.prevRanges)),h=l?bhe(t.prevRanges,r.mapping):P3e(r.mapping.maps);return new Ov(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,Tse(s)),sg.empty,h,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new Ov(t.done.rebased(r,o),t.undone.rebased(r,o),bhe(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new Ov(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),bhe(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function _4t(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 P3e(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 bhe(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=Uk.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=b4t(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const pqe=mqe(!1,!0),fqe=mqe(!0,!0),k4t=wu.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>pqe(t,s),redo:()=>({state:t,dispatch:s})=>fqe(t,s)}},addProseMirrorPlugins(){return[j4t(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()}}}),N4t=Zu.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",fc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!_Ct(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}):USt(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:h}=l.selection,f=h.end();if(h.nodeAfter)h.nodeAfter.isTextblock?l.setSelection(Ea.create(l.doc,h.pos+1)):h.nodeAfter.isBlock?l.setSelection(ja.create(l.doc,h.pos)):l.setSelection(Ea.create(l.doc,h.pos));else{const g=(d=h.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();g&&(l.insert(f,g),l.setSelection(Ea.create(l.doc,f+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[iqe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),S4t=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,C4t=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,M4t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,T4t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,A4t=$x.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",fc(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[Z5({find:S4t,type:this.type}),Z5({find:M4t,type:this.type})]},addPasteRules(){return[dN({find:C4t,type:this.type}),dN({find:T4t,type:this.type})]}}),E4t=Zu.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",fc(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)}}}),I4t="listItem",D3e="textStyle",O3e=/^(\d+)\.\s$/,P4t=Zu.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",fc(this.options.HTMLAttributes,r),0]:["ol",fc(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(I4t,this.editor.getAttributes(D3e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=vP({find:O3e,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=vP({find:O3e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(D3e)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),L4t=Zu.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",fc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),D4t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,O4t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,R4t=$x.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",fc(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[Z5({find:D4t,type:this.type})]},addPasteRules(){return[dN({find:O4t,type:this.type})]}}),F4t=Zu.create({name:"text",group:"inline"}),gqe=wu.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(WCt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push($Ct.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(KCt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(XCt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(e4t.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(t4t.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(n4t.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(h4t.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(m4t.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(p4t.configure(this.options.heading)),this.options.history!==!1&&t.push(k4t.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(N4t.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(A4t.configure(this.options.italic)),this.options.listItem!==!1&&t.push(E4t.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(P4t.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(L4t.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(R4t.configure(this.options.strike)),this.options.text!==!1&&t.push(F4t.configure(this.options.text)),t}}),z4t="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",B4t="ελ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",jge="numeric",kge="ascii",Nge="alpha",hI="asciinumeric",nE="alphanumeric",Sge="domain",xqe="emoji",$4t="scheme",U4t="slashscheme",jhe="whitespace";function q4t(t,s){return t in s||(s[t]=[]),s[t]}function Qj(t,s,r){s[jge]&&(s[hI]=!0,s[nE]=!0),s[kge]&&(s[hI]=!0,s[Nge]=!0),s[hI]&&(s[nE]=!0),s[Nge]&&(s[nE]=!0),s[nE]&&(s[Sge]=!0),s[xqe]&&(s[Sge]=!0);for(const n in s){const a=q4t(n,r);a.indexOf(t)<0&&a.push(t)}}function V4t(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function Yh(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Yh.groups={};Yh.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),xc=(t,s,r,n,a)=>t.tr(s,r,n,a),R3e=(t,s,r,n,a)=>t.ts(s,r,n,a),$r=(t,s,r,n,a)=>t.tt(s,r,n,a),My="WORD",Cge="UWORD",yqe="ASCIINUMERICAL",vqe="ALPHANUMERICAL",_P="LOCALHOST",Mge="TLD",Tge="UTLD",Ase="SCHEME",qC="SLASH_SCHEME",d_e="NUM",Age="WS",u_e="NL",mI="OPENBRACE",pI="CLOSEBRACE",one="OPENBRACKET",lne="CLOSEBRACKET",cne="OPENPAREN",dne="CLOSEPAREN",une="OPENANGLEBRACKET",hne="CLOSEANGLEBRACKET",mne="FULLWIDTHLEFTPAREN",pne="FULLWIDTHRIGHTPAREN",fne="LEFTCORNERBRACKET",gne="RIGHTCORNERBRACKET",xne="LEFTWHITECORNERBRACKET",yne="RIGHTWHITECORNERBRACKET",vne="FULLWIDTHLESSTHAN",_ne="FULLWIDTHGREATERTHAN",bne="AMPERSAND",wne="APOSTROPHE",jne="ASTERISK",Rv="AT",kne="BACKSLASH",Nne="BACKTICK",Sne="CARET",Wv="COLON",h_e="COMMA",Cne="DOLLAR",ax="DOT",Mne="EQUALS",m_e="EXCLAMATION",Tp="HYPHEN",fI="PERCENT",Tne="PIPE",Ane="PLUS",Ene="POUND",gI="QUERY",p_e="QUOTE",_qe="FULLWIDTHMIDDLEDOT",f_e="SEMI",ix="SLASH",xI="TILDE",Ine="UNDERSCORE",bqe="EMOJI",Pne="SYM";var wqe=Object.freeze({__proto__:null,ALPHANUMERICAL:vqe,AMPERSAND:bne,APOSTROPHE:wne,ASCIINUMERICAL:yqe,ASTERISK:jne,AT:Rv,BACKSLASH:kne,BACKTICK:Nne,CARET:Sne,CLOSEANGLEBRACKET:hne,CLOSEBRACE:pI,CLOSEBRACKET:lne,CLOSEPAREN:dne,COLON:Wv,COMMA:h_e,DOLLAR:Cne,DOT:ax,EMOJI:bqe,EQUALS:Mne,EXCLAMATION:m_e,FULLWIDTHGREATERTHAN:_ne,FULLWIDTHLEFTPAREN:mne,FULLWIDTHLESSTHAN:vne,FULLWIDTHMIDDLEDOT:_qe,FULLWIDTHRIGHTPAREN:pne,HYPHEN:Tp,LEFTCORNERBRACKET:fne,LEFTWHITECORNERBRACKET:xne,LOCALHOST:_P,NL:u_e,NUM:d_e,OPENANGLEBRACKET:une,OPENBRACE:mI,OPENBRACKET:one,OPENPAREN:cne,PERCENT:fI,PIPE:Tne,PLUS:Ane,POUND:Ene,QUERY:gI,QUOTE:p_e,RIGHTCORNERBRACKET:gne,RIGHTWHITECORNERBRACKET:yne,SCHEME:Ase,SEMI:f_e,SLASH:ix,SLASH_SCHEME:qC,SYM:Pne,TILDE:xI,TLD:Mge,UNDERSCORE:Ine,UTLD:Tge,UWORD:Cge,WORD:My,WS:Age});const jy=/[a-z]/,TA=new RegExp("\\p{L}","u"),khe=new RegExp("\\p{Emoji}","u"),ky=/\d/,Nhe=/\s/,F3e="\r",She=` `,H4t="️",W4t="‍",Che="";let t8=null,s8=null;function G4t(t=[]){const s={};Yh.groups=s;const r=new Yh;t8==null&&(t8=z3e(z4t)),s8==null&&(s8=z3e(B4t)),$r(r,"'",wne),$r(r,"{",mI),$r(r,"}",pI),$r(r,"[",one),$r(r,"]",lne),$r(r,"(",cne),$r(r,")",dne),$r(r,"<",une),$r(r,">",hne),$r(r,"(",mne),$r(r,")",pne),$r(r,"「",fne),$r(r,"」",gne),$r(r,"『",xne),$r(r,"』",yne),$r(r,"<",vne),$r(r,">",_ne),$r(r,"&",bne),$r(r,"*",jne),$r(r,"@",Rv),$r(r,"`",Nne),$r(r,"^",Sne),$r(r,":",Wv),$r(r,",",h_e),$r(r,"$",Cne),$r(r,".",ax),$r(r,"=",Mne),$r(r,"!",m_e),$r(r,"-",Tp),$r(r,"%",fI),$r(r,"|",Tne),$r(r,"+",Ane),$r(r,"#",Ene),$r(r,"?",gI),$r(r,'"',p_e),$r(r,"/",ix),$r(r,";",f_e),$r(r,"~",xI),$r(r,"_",Ine),$r(r,"\\",kne),$r(r,"・",_qe);const n=xc(r,ky,d_e,{[jge]:!0});xc(n,ky,n);const a=xc(n,jy,yqe,{[hI]:!0}),o=xc(n,TA,vqe,{[nE]:!0}),l=xc(r,jy,My,{[kge]:!0});xc(l,ky,a),xc(l,jy,l),xc(a,ky,a),xc(a,jy,a);const i=xc(r,TA,Cge,{[Nge]:!0});xc(i,jy),xc(i,ky,o),xc(i,TA,i),xc(o,ky,o),xc(o,jy),xc(o,TA,o);const d=$r(r,She,u_e,{[jhe]:!0}),h=$r(r,F3e,Age,{[jhe]:!0}),f=xc(r,Nhe,Age,{[jhe]:!0});$r(r,Che,f),$r(h,She,d),$r(h,Che,f),xc(h,Nhe,f),$r(f,F3e),$r(f,She),xc(f,Nhe,f),$r(f,Che,f);const g=xc(r,khe,bqe,{[xqe]:!0});$r(g,"#"),xc(g,khe,g),$r(g,H4t,g);const v=$r(g,W4t);$r(v,"#"),xc(v,khe,g);const _=[[jy,l],[ky,a]],j=[[jy,null],[TA,i],[ky,o]];for(let w=0;ww[0]>k[0]?1:-1);for(let w=0;w=0?S[Sge]=!0:jy.test(k)?ky.test(k)?S[hI]=!0:S[kge]=!0:S[jge]=!0,R3e(r,k,k,S)}return R3e(r,"localhost",_P,{ascii:!0}),r.jd=new Yh(Pne),{start:r,tokens:Object.assign({groups:s},wqe)}}function jqe(t,s){const r=K4t(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++),h+=r[l].length,o+=r[l].length,l++;o-=g,l-=v,h-=g,a.push({t:f.t,v:s.slice(o-h,o),s:o-h,e:o})}return a}function K4t(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 bv(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 bP={defaultProtocol:"http",events:null,format:B3e,formatHref:B3e,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function g_e(t,s=null){let r=Object.assign({},bP);t&&(r=Object.assign(r,t instanceof g_e?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=bP.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),h=t.get("rel",r,s),f=t.getObj("attributes",r,s),g=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),d&&(l.target=d),h&&(l.rel=h),f&&Object.assign(l,f),{tagName:a,attributes:l,content:o,eventListeners:g}}};function koe(t,s){class r extends kqe{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 $3e=koe("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),U3e=koe("text"),Z4t=koe("nl"),r8=koe("url",{isLink:!0,toHref(t=bP.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==_P&&t[1].t===Wv}}),Np=t=>new Yh(t);function Y4t({groups:t}){const s=t.domain.concat([bne,jne,Rv,kne,Nne,Sne,Cne,Mne,Tp,d_e,fI,Tne,Ane,Ene,ix,Pne,xI,Ine]),r=[wne,Wv,h_e,ax,m_e,fI,gI,p_e,f_e,une,hne,mI,pI,lne,one,cne,dne,mne,pne,fne,gne,xne,yne,vne,_ne],n=[bne,wne,jne,kne,Nne,Sne,Cne,Mne,Tp,mI,pI,fI,Tne,Ane,Ene,gI,ix,Pne,xI,Ine],a=Np(),o=$r(a,xI);Pi(o,n,o),Pi(o,t.domain,o);const l=Np(),i=Np(),d=Np();Pi(a,t.domain,l),Pi(a,t.scheme,i),Pi(a,t.slashscheme,d),Pi(l,n,o),Pi(l,t.domain,l);const h=$r(l,Rv);$r(o,Rv,h),$r(i,Rv,h),$r(d,Rv,h);const f=$r(o,ax);Pi(f,n,o),Pi(f,t.domain,o);const g=Np();Pi(h,t.domain,g),Pi(g,t.domain,g);const v=$r(g,ax);Pi(v,t.domain,g);const _=Np($3e);Pi(v,t.tld,_),Pi(v,t.utld,_),$r(h,_P,_);const j=$r(g,Tp);$r(j,Tp,j),Pi(j,t.domain,g),Pi(_,t.domain,g),$r(_,ax,v),$r(_,Tp,j);const w=$r(_,Wv);Pi(w,t.numeric,$3e);const k=$r(l,Tp),M=$r(l,ax);$r(k,Tp,k),Pi(k,t.domain,l),Pi(M,n,o),Pi(M,t.domain,l);const S=Np(r8);Pi(M,t.tld,S),Pi(M,t.utld,S),Pi(S,t.domain,l),Pi(S,n,o),$r(S,ax,M),$r(S,Tp,k),$r(S,Rv,h);const E=$r(S,Wv),D=Np(r8);Pi(E,t.numeric,D);const L=Np(r8),B=Np();Pi(L,s,L),Pi(L,r,B),Pi(B,s,L),Pi(B,r,B),$r(S,ix,L),$r(D,ix,L);const $=$r(i,Wv),V=$r(d,Wv),W=$r(V,ix),G=$r(W,ix);Pi(i,t.domain,l),$r(i,ax,M),$r(i,Tp,k),Pi(d,t.domain,l),$r(d,ax,M),$r(d,Tp,k),Pi($,t.domain,L),$r($,ix,L),$r($,gI,L),Pi(G,t.domain,L),Pi(G,s,L),$r(G,ix,L);const J=[[mI,pI],[one,lne],[cne,dne],[une,hne],[mne,pne],[fne,gne],[xne,yne],[vne,_ne]];for(let ne=0;ne=0&&v++,a++,f++;if(v<0)a-=f,a0&&(o.push(Mhe(U3e,s,l)),l=[]),a-=v,f-=v;const _=g.t,j=r.slice(a-f,a);o.push(Mhe(_,s,j))}}return l.length>0&&o.push(Mhe(U3e,s,l)),o}function Mhe(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 Q4t=typeof console<"u"&&console&&console.warn||(()=>{}),J4t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",El={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function e5t(){return Yh.groups={},El.scanner=null,El.parser=null,El.tokenQueue=[],El.pluginQueue=[],El.customSchemes=[],El.initialized=!1,El}function q3e(t,s=!1){if(El.initialized&&Q4t(`linkifyjs: already initialized - will not register custom scheme "${t}" ${J4t}`),!/^[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`);El.customSchemes.push([t,s])}function t5t(){El.scanner=G4t(El.customSchemes);for(let t=0;t{const a=s.some(h=>h.docChanged)&&!r.doc.eq(n.doc),o=s.some(h=>h.getMeta("preventAutolink"));if(!a||o)return;const{tr:l}=n,i=PSt(r.doc,[...s]);if(BSt(i).forEach(({newRange:h})=>{const f=DSt(n.doc,h,_=>_.isTextblock);let g,v;if(f.length>1)g=f[0],v=n.doc.textBetween(g.pos,g.pos+g.node.nodeSize,void 0," ");else if(f.length){const _=n.doc.textBetween(h.from,h.to," "," ");if(!r5t.test(_))return;g=f[0],v=n.doc.textBetween(g.pos,h.to,void 0," ")}if(g&&v){const _=v.split(s5t).filter(Boolean);if(_.length<=0)return!1;const j=_[_.length-1],w=g.pos+v.lastIndexOf(j);if(!j)return!1;const k=x_e(j).map(M=>M.toObject(t.defaultProtocol));if(!a5t(k))return!1;k.filter(M=>M.isLink).map(M=>({...M,from:w+M.start+1,to:w+M.end+1})).filter(M=>n.schema.marks.code?!n.doc.rangeHasMark(M.from,M.to,n.schema.marks.code):!0).filter(M=>t.validate(M.value)).filter(M=>t.shouldAutoLink(M.value)).forEach(M=>{a_e(M.from,M.to,n.doc).some(S=>S.mark.type===t.type)||l.addMark(M.from,M.to,t.type.create({href:M.href}))})}}),!!l.steps.length)return l}})}function o5t(t){return new Pd({key:new Ku("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=aqe(s.state,t.type.name),h=n.target,f=(a=h==null?void 0:h.href)!==null&&a!==void 0?a:d.href,g=(o=h==null?void 0:h.target)!==null&&o!==void 0?o:d.target;return h&&f?(window.open(f,g),!0):!1}}})}function l5t(t){return new Pd({key:new Ku("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(h=>{i+=h.textContent});const d=Nqe(i,{defaultProtocol:t.defaultProtocol}).find(h=>h.isLink&&h.value===i);return!i||!d?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function mb(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(n5t,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Sqe=$x.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"){q3e(t);return}q3e(t.scheme,t.optionalSlashes)})},onDestroy(){e5t()},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)=>!!mb(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=>!!mb(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=>!!mb(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",fc(this.options.HTMLAttributes,t),0]:["a",fc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!mb(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=>!!mb(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[dN({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=Nqe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!mb(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(i5t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!mb(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(o5t({type:this.type})),this.options.linkOnPaste&&t.push(l5t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Cqe=wu.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")}}}),c5t=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}`)})},Mqe=$x.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&c5t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",fc(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}}}}),d5t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,u5t=Zu.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",fc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[iqe({find:d5t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let Ege,Ige;if(typeof WeakMap<"u"){let t=new WeakMap;Ege=s=>t.get(s),Ige=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;Ege=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var Tc=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:f,n:M-E});break}const D=a+E*s;for(let L=0;Ln&&(o+=h.attrs.colspan)}}for(let l=0;l1&&(r=!0)}s==-1?s=o:s!=o&&(s=Math.max(s,o))}return s}function p5t(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 g5t(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 Eg(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 Noe(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=H3(s.$head)||x5t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function x5t(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 Pge(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function y5t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function v_e(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function Tqe(t,s,r){const n=t.node(-1),a=Tc.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 uN(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 Aqe(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;af!=r.pos-o);d.unshift(r.pos-o);const h=d.map(f=>{const g=n.nodeAt(f);if(!g)throw new RangeError(`No cell with offset ${f} found`);const v=o+f+1;return new Q$e(i.resolve(v),i.resolve(v+g.content.size))});super(h[0].$from,h[0].$to,h),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(Pge(n)&&Pge(a)&&v_e(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Ty.rowSelection(n,a):o&&this.isColSelection()?Ty.colSelection(n,a):new Ty(n,a)}return Ea.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=Tc.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||k>0){let M=j.attrs;if(w>0&&(M=uN(M,0,w)),k>0&&(M=uN(M,M.colspan-k,k)),_.lefta.bottom){const M={...j.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=Tc.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 Ty&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=Tc.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(xh.node(n,n+r.nodeSize,{class:"selectedCell"}))}),kc.create(t.doc,s)}function w5t({$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 j5t({$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 k5t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof ja&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=vl.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=vl.rowSelection(i,i)}else if(!r){const i=Tc.get(n.node),d=n.from+1,h=d+i.map[i.width*i.height-1];o=vl.create(a,d+1,h)}}else n instanceof Ea&&w5t(n)?o=Ea.create(a,n.from):n instanceof Ea&&j5t(n)&&(o=Ea.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const N5t=new Ku("fix-tables");function Iqe(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=S5t(t,a,o,r))};return s?s.doc!=t.doc&&Iqe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function S5t(t,s,r,n){const a=Tc.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let d=0;d0){let _="cell";f.firstChild&&(_=f.firstChild.type.spec.tableRole);const j=[];for(let k=0;k0?-1:0;v5t(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;E5t(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let h=0,f=s.width*a;h0&&a0&&g==s.map[f-s.width]){const v=r.nodeAt(g).attrs;t.setNodeMarkup(t.mapping.slice(i).map(g+n),null,{...v,rowspan:v.rowspan-1}),h+=v.colspan-1}else if(a0&&r[o]==r[o-1]||n.right0&&r[a]==r[a-t]||n.bottom0){const f=d+1+h.content.size,g=V3e(h)?d+1:f;o.replaceWith(g+n.tableStart,f+n.tableStart,i)}o.setSelection(new vl(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function W3e(t,s){const r=Vu(t.schema);return R5t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function R5t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof vl){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=g5t(n.$from),!a)return!1;o=(l=H3(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=[],h=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const f=Zx(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 z5t(t){return function(s,r){if(!Eg(s))return!1;if(r){const n=Vu(s.schema),a=Zx(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,j=l.doc.nodeAt(_);j&&l.setNodeMarkup(_,g,j.attrs)}),n(l)}return!0}}wP("row",{useDeprecatedLogic:!0});wP("column",{useDeprecatedLogic:!0});const B5t=wP("cell",{useDeprecatedLogic:!0});function $5t(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 n8(t,s){const r=t.selection;if(!(r instanceof vl))return!1;if(s){const n=t.tr,a=Vu(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 cn(a,0,0))}),n.docChanged&&s(n)}return!0}function q5t(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 h=a;h=s.length&&s.push(jr.empty),r[a]n&&(v=v.type.createChecked(uN(v.attrs,v.attrs.colspan,f+v.attrs.colspan-n),v.content)),h.push(v),f+=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(jr.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function W5t(t,s,r,n,a,o,l){const i=t.doc.type.schema,d=Vu(i);let h,f;if(a>s.width)for(let g=0,v=0;gs.height){const g=[];for(let j=0,w=(s.height-1)*s.width;j=s.width?!1:r.nodeAt(s.map[w+j]).type==d.header_cell;g.push(k?f||(f=d.header_cell.createAndFill()):h||(h=d.cell.createAndFill()))}const v=d.row.create(null,jr.from(g)),_=[];for(let j=s.height;j{if(!a)return!1;const o=r.selection;if(o instanceof vl)return Ese(r,n,Za.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=Oqe(a,t,s);if(l==null)return!1;if(t=="horiz")return Ese(r,n,Za.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=Tqe(i,t,s);let h;return d?h=Za.near(d,1):s<0?h=Za.near(r.doc.resolve(i.before(-1)),-1):h=Za.near(r.doc.resolve(i.after(-1)),1),Ese(r,n,h)}}}function i8(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof vl)l=o;else{const d=Oqe(a,t,s);if(d==null)return!1;l=new vl(r.doc.resolve(d))}const i=Tqe(l.$headCell,t,s);return i?Ese(r,n,new vl(l.$anchorCell,i)):!1}}function K5t(t,s){const r=t.state.doc,n=H3(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new vl(n))),!0):!1}function Z5t(t,s,r){if(!Eg(t.state))return!1;let n=q5t(r);const a=t.state.selection;if(a instanceof vl){n||(n={width:1,height:1,rows:[jr.from(Lge(Vu(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=Tc.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=H5t(n,i.right-i.left,i.bottom-i.top),X3e(t.state,t.dispatch,l,i,n),!0}else if(n){const o=Noe(t.state),l=o.start(-1);return X3e(t.state,t.dispatch,l,Tc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function Y5t(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=Q3e(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof vl)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=H3(t.state.selection.$anchor))!=null&&((r=The(t,s))===null||r===void 0?void 0:r.pos)!=a.pos)o(a,s),s.preventDefault();else if(!n)return;function o(d,h){let f=The(t,h);const g=Gv.getState(t.state)==null;if(!f||!v_e(d,f))if(g)f=d;else return;const v=new vl(d,f);if(g||!t.state.selection.eq(v)){const _=t.state.tr.setSelection(v);g&&_.setMeta(Gv,d.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),Gv.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Gv,-1))}function i(d){const h=d,f=Gv.getState(t.state);let g;if(f!=null)g=t.state.doc.resolve(f);else if(Q3e(t,h.target)!=n&&(g=The(t,s),!g))return l();g&&o(g,h)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",i)}function Oqe(t,s,r){if(!(t.state.selection instanceof Ea))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 Q3e(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function The(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 H3(t.state.doc.resolve(n))}var X5t=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")),Dge(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,Dge(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function Dge(t,s,r,n,a,o){let l=0,i=!0,d=s.firstChild;const h=t.firstChild;if(h){for(let g=0,v=0;gnew n(g,r,v)),new J5t(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=$m.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{e3t(l,i,t,a)},mouseleave:l=>{t3t(l)},mousedown:(l,i)=>{s3t(l,i,s,r)}},decorations:l=>{const i=$m.getState(l);if(i&&i.activeHandle>-1)return o3t(l,i.activeHandle)},nodeViews:{}}});return o}var J5t=class Ise{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta($m);if(n&&n.setHandle!=null)return new Ise(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new Ise(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return Pge(s.doc.resolve(a))||(a=-1),new Ise(a,r.dragging)}return r}};function e3t(t,s,r,n){if(!t.editable)return;const a=$m.getState(t.state);if(a&&!a.dragging){const o=n3t(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=J3e(t,s,"left",r):d-s.clientX<=r&&(l=J3e(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),d=i.node(-1),h=Tc.get(d),f=i.start(-1);if(h.colCount(i.pos-f)+i.nodeAfter.attrs.colspan-1==h.width-1)return}Rqe(t,l)}}}function t3t(t){if(!t.editable)return;const s=$m.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&Rqe(t,-1)}function s3t(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=$m.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),d=r3t(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta($m,{setDragging:{startX:s.clientX,startWidth:d}}));function h(g){o.removeEventListener("mouseup",h),o.removeEventListener("mousemove",f);const v=$m.getState(t.state);v!=null&&v.dragging&&(a3t(t,v.activeHandle,eMe(v.dragging,g,r)),t.dispatch(t.state.tr.setMeta($m,{setDragging:null})))}function f(g){if(!g.which)return h(g);const v=$m.getState(t.state);if(v&&v.dragging){const _=eMe(v.dragging,g,r);tMe(t,v.activeHandle,_,n)}}return tMe(t,l.activeHandle,d,n),o.addEventListener("mouseup",h),o.addEventListener("mousemove",f),s.preventDefault(),!0}function r3t(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 h3t(t,s,r,n,a){const o=u3t(t),l=[],i=[];for(let h=0;h{const{selection:s}=t.state;if(!m3t(s))return!1;let r=0;const n=nqe(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},p3t=Zu.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:c3t,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}=d3t(t,this.options.cellMinWidth),o=["table",fc(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=h3t(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Ea.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>C5t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>M5t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>A5t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>I5t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>P5t(t,s),deleteRow:()=>({state:t,dispatch:s})=>D5t(t,s),deleteTable:()=>({state:t,dispatch:s})=>U5t(t,s),mergeCells:()=>({state:t,dispatch:s})=>H3e(t,s),splitCell:()=>({state:t,dispatch:s})=>W3e(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>wP("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>wP("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>B5t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>H3e(t,s)?!0:W3e(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>F5t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>K3e(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>K3e(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&Pqe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=vl.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:o8,"Mod-Backspace":o8,Delete:o8,"Mod-Delete":o8}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Q5t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],l3t({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:Li(Kn(t,"tableRole",s))}}}),f3t=Zu.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",fc(this.options.HTMLAttributes,t),0]}}),g3t=Zu.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",fc(this.options.HTMLAttributes,t),0]}}),x3t=Zu.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",fc(this.options.HTMLAttributes,t),0]}});function Ig({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=T.useState(!1),[i,d]=T.useState(""),[h,f]=T.useState(!0),g=dqe({extensions:[gqe,Sqe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Cqe.configure({types:["heading","paragraph"]}),Mqe,u5t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),p3t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),f3t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null}}}}),g3t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),x3t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:w})=>{s(w.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(w,k)=>{var S;const M=(S=k.clipboardData)==null?void 0:S.items;if(!M)return!1;for(const E of Array.from(M))if(E.type.startsWith("image/")){k.preventDefault();const D=E.getAsFile();if(!D)continue;const L=new FileReader;return L.onload=B=>{var V;const $=(V=B.target)==null?void 0:V.result;w.dispatch(w.state.tr.replaceSelectionWith(w.state.schema.nodes.image.create({src:$})))},L.readAsDataURL(D),!0}return!1}}});T.useEffect(()=>{g&&t!==g.getHTML()&&g.commands.setContent(t)},[t,g]);const v=()=>{if(!g)return;const w=g.getAttributes("link").href||"",k=g.getAttributes("link").target;d(w),f(k==="_blank"),l(!0)},_=()=>{g&&(i===""?g.chain().focus().extendMarkRange("link").unsetLink().run():g.chain().focus().extendMarkRange("link").setLink({href:i,target:h?"_blank":null,rel:h?"noopener noreferrer nofollow":null}).run(),l(!1),d(""))},j=()=>{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(Y,{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(CE,{className:"h-4 w-4"})}),e.jsx(Y,{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(ME,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleBold().run(),className:g.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(S4,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleItalic().run(),className:g.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(P4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleBulletList().run(),className:g.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(dm,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleOrderedList().run(),className:g.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(O4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{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(j4,{className:"h-4 w-4"})}),e.jsx(Y,{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(w4,{className:"h-4 w-4"})}),e.jsx(Y,{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(k4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:v,className:g.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Ro,{className:"h-4 w-4"})}),g.isActive("link")&&e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:j,title:"Remove Link",children:e.jsx(Ro,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().undo().run(),disabled:!g.can().undo(),title:"Undo",children:e.jsx(H4,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().redo().run(),disabled:!g.can().redo(),title:"Redo",children:e.jsx(q4,{className:"h-4 w-4"})})]}),e.jsx(lqe,{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(js,{open:o,onOpenChange:l,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"link-url",children:"URL"}),e.jsx(Be,{id:"link-url",value:i,onChange:w=>d(w.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ln,{id:"link-new-tab",checked:h,onCheckedChange:f}),e.jsx(je,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Y,{type:"button",onClick:_,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var y3t=Object.defineProperty,v3t=(t,s,r)=>s in t?y3t(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Fl=(t,s,r)=>v3t(t,typeof s!="symbol"?s+"":s,r);const Lne={x:0,y:0,width:0,height:0,unit:"px"},AC=(t,s,r)=>Math.min(Math.max(t,s),r),_3t=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),nMe=(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 b3t(t,s,r,n){const a=ox(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==="%"?Fv(a,r,n):a}function w3t(t,s,r){const n=ox(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?Fv(n,s,r):n}function Fv(t,s,r){return t.unit==="%"?{...Lne,...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 ox(t,s,r){return t.unit?t.unit==="px"?{...Lne,...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}:{...Lne,...t,unit:"px"}}function aMe(t,s,r,n,a,o=0,l=0,i=n,d=a){const h={...t};let f=Math.min(o,n),g=Math.min(l,a),v=Math.min(i,n),_=Math.min(d,a);s&&(s>1?(f=l?l*s:f,g=f/s,v=i*s):(g=o?o/s:g,f=g*s,_=d/s)),h.y<0&&(h.height=Math.max(h.height+h.y,g),h.y=0),h.x<0&&(h.width=Math.max(h.width+h.x,f),h.x=0);const j=n-(h.x+h.width);j<0&&(h.x=Math.min(h.x,n-f),h.width+=j);const w=a-(h.y+h.height);if(w<0&&(h.y=Math.min(h.y,a-g),h.height+=w),h.widthv&&((r==="sw"||r=="nw")&&(h.x-=v-h.width),h.width=v),h.height>_&&((r==="nw"||r=="ne")&&(h.y-=_-h.height),h.height=_),s){const k=h.width/h.height;if(ks){const M=Math.max(h.height*s,f);(r==="sw"||r=="nw")&&(h.x-=M-h.width),h.width=M}}return h}function j3t(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 EC={capture:!0,passive:!1};let k3t=0;const Nv=class Uf extends T.PureComponent{constructor(){super(...arguments),Fl(this,"docMoveBound",!1),Fl(this,"mouseDownOnCrop",!1),Fl(this,"dragStarted",!1),Fl(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),Fl(this,"componentRef",T.createRef()),Fl(this,"mediaRef",T.createRef()),Fl(this,"resizeObserver"),Fl(this,"initChangeCalled",!1),Fl(this,"instanceId",`rc-${k3t++}`),Fl(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),Fl(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=ox(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,h=s.clientY,f=o.x,g=o.y;if(l){const v=s.clientX-a.x,_=s.clientY-a.y;let j=0,w=0;l==="ne"||l=="e"?(j=v-(o.x+o.width),w=_-o.y,f=o.x,g=o.y+o.height):l==="se"||l==="s"?(j=v-(o.x+o.width),w=_-(o.y+o.height),f=o.x,g=o.y):l==="sw"||l=="w"?(j=v-o.x,w=_-(o.y+o.height),f=o.x+o.width,g=o.y):(l==="nw"||l=="n")&&(j=v-o.x,w=_-o.y,f=o.x+o.width,g=o.y+o.height),d=f+a.x+j,h=g+a.y+w}this.evData={startClientX:d,startClientY:h,startCropX:f,startCropY:g,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),Fl(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,h=s.clientY-i.y,f={unit:"px",x:d,y:h,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:d,startCropY:h,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(ox(f,i.width,i.height),Fv(f,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),Fl(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(),nMe(r,d)||a(ox(d,l.width,l.height),Fv(d,l.width,l.height))}),Fl(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(),h=this.makePixelCrop(d),f=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Uf.nudgeStepLarge:s.shiftKey?Uf.nudgeStepMedium:Uf.nudgeStep;if(l==="ArrowLeft"?(h.x-=f,i=!0):l==="ArrowRight"?(h.x+=f,i=!0):l==="ArrowUp"?(h.y-=f,i=!0):l==="ArrowDown"&&(h.y+=f,i=!0),i){s.cancelable&&s.preventDefault(),h.x=AC(h.x,0,d.width-h.width),h.y=AC(h.y,0,d.height-h.height);const g=ox(h,d.width,d.height),v=Fv(h,d.width,d.height);a(g,v),o&&o(g,v)}}),Fl(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:d,maxHeight:h,onChange:f,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)?Uf.nudgeStepLarge:s.shiftKey?Uf.nudgeStepMedium:Uf.nudgeStep,j=ox(a,v.width,v.height),w=j3t(j,s.key,_,r),k=aMe(w,n,r,v.width,v.height,l,i,d,h);if(!nMe(a,k)){const M=Fv(k,v.width,v.height);f(k,M),g&&g(k,M)}}),Fl(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(ox(r,l.width,l.height),Fv(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),Fl(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(ox(r,a,o),Fv(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,EC),this.document.addEventListener("pointerup",this.onDocPointerDone,EC),this.document.addEventListener("pointercancel",this.onDocPointerDone,EC),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,EC),this.document.removeEventListener("pointerup",this.onDocPointerDone,EC),this.document.removeEventListener("pointercancel",this.onDocPointerDone,EC),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=AC(s.startCropX+a,0,r.width-n.width),n.y=AC(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 h=this.getPointRegion(o,s.ord,l,i),f=s.ord||h;let g=s.clientX-s.startClientX,v=s.clientY-s.startClientY;(l&&f==="nw"||f==="w"||f==="sw")&&(g=Math.min(g,-l)),(i&&f==="nw"||f==="n"||f==="ne")&&(v=Math.min(v,-i));const _={unit:"px",x:0,y:0,width:0,height:0};h==="ne"?(_.x=s.startCropX,_.width=g,r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(v),_.y=s.startCropY-_.height)):h==="se"?(_.x=s.startCropX,_.y=s.startCropY,_.width=g,r?_.height=_.width/r:_.height=v):h==="sw"?(_.x=s.startCropX+g,_.y=s.startCropY,_.width=Math.abs(g),r?_.height=_.width/r:_.height=v):h==="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 j=aMe(_,r,h,o.width,o.height,l,i,n,a);return r||Uf.xyOrds.indexOf(f)>-1?d=j:Uf.xOrds.indexOf(f)>-1?(d.x=j.x,d.width=j.width):Uf.yOrds.indexOf(f)>-1&&(d.y=j.y,d.height=j.height),d.x=AC(d.x,0,o.width-d.width),d.y=AC(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:s=Uf.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return lt.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&<.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},lt.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),lt.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),lt.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),lt.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),lt.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"}),lt.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"}),lt.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"}),lt.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"}),lt.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"}),lt.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"}),lt.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"}),lt.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&<.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:d=>d.stopPropagation()},a(this.state)),o&<.createElement(lt.Fragment,null,lt.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),lt.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...Lne,...this.props.crop||{}};return ox(r,s.width,s.height)}render(){const{aspect:s,children:r,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:d,ruleOfThirds:h}=this.props,{cropIsActive:f,newCropIsBeingDrawn:g}=this.state,v=o?this.renderCropSelection():null,_=_3t("ReactCrop",a,f&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",g&&"ReactCrop--new-crop",o&&s&&"ReactCrop--fixed-aspect",o&&n&&"ReactCrop--circular-crop",o&&h&&"ReactCrop--rule-of-thirds",!this.dragStarted&&o&&!o.width&&!o.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return lt.createElement("div",{ref:this.componentRef,className:_,style:d},lt.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?lt.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},lt.createElement("defs",null,lt.createElement("mask",{id:`hole-${this.instanceId}`},lt.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?lt.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"}):lt.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),lt.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,v)}};Fl(Nv,"xOrds",["e","w"]),Fl(Nv,"yOrds",["n","s"]),Fl(Nv,"xyOrds",["nw","ne","se","sw"]),Fl(Nv,"nudgeStep",1),Fl(Nv,"nudgeStepMedium",10),Fl(Nv,"nudgeStepLarge",100),Fl(Nv,"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 N3t=Nv;var Fqe=["PageUp","PageDown"],zqe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Bqe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},W3="Slider",[Rge,S3t,C3t]=b6(W3),[$qe]=Dc(W3,[C3t]),[M3t,Soe]=$qe(W3),Uqe=T.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:h=[n],value:f,onValueChange:g=()=>{},onValueCommit:v=()=>{},inverted:_=!1,form:j,...w}=t,k=T.useRef(new Set),M=T.useRef(0),E=l==="horizontal"?T3t:A3t,[D=[],L]=Sh({prop:f,defaultProp:h,onChange:J=>{var ie;(ie=[...k.current][M.current])==null||ie.focus(),g(J)}}),B=T.useRef(D);function $(J){const ne=D3t(D,J);G(J,ne)}function V(J){G(J,M.current)}function W(){const J=B.current[M.current];D[M.current]!==J&&v(D)}function G(J,ne,{commit:ie}={commit:!1}){const ee=z3t(o),de=B3t(Math.round((J-n)/o)*o+n,ee),oe=iP(de,[n,a]);L((ue=[])=>{const ce=P3t(ue,oe,ne);if(F3t(ce,d*o)){M.current=ce.indexOf(oe);const ge=String(ce)!==String(ue);return ge&&ie&&v(ce),ge?ce:ue}else return ue})}return e.jsx(M3t,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:M,thumbs:k.current,values:D,orientation:l,form:j,children:e.jsx(Rge.Provider,{scope:t.__scopeSlider,children:e.jsx(Rge.Slot,{scope:t.__scopeSlider,children:e.jsx(E,{"aria-disabled":i,"data-disabled":i?"":void 0,...w,ref:s,onPointerDown:kr(w.onPointerDown,()=>{i||(B.current=D)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:$,onSlideMove:i?void 0:V,onSlideEnd:i?void 0:W,onHomeKeyDown:()=>!i&&G(n,0,{commit:!0}),onEndKeyDown:()=>!i&&G(a,D.length-1,{commit:!0}),onStepKeyDown:({event:J,direction:ne})=>{if(!i){const de=Fqe.includes(J.key)||J.shiftKey&&zqe.includes(J.key)?10:1,oe=M.current,ue=D[oe],ce=o*de*ne;G(ue+ce,oe,{commit:!0})}}})})})})});Uqe.displayName=W3;var[qqe,Vqe]=$qe(W3,{startEdge:"left",endEdge:"right",size:"width",direction:1}),T3t=T.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:h,...f}=t,[g,v]=T.useState(null),_=ba(s,E=>v(E)),j=T.useRef(void 0),w=jN(a),k=w==="ltr",M=k&&!o||!k&&o;function S(E){const D=j.current||g.getBoundingClientRect(),L=[0,D.width],$=__e(L,M?[r,n]:[n,r]);return j.current=D,$(E-D.left)}return e.jsx(qqe,{scope:t.__scopeSlider,startEdge:M?"left":"right",endEdge:M?"right":"left",direction:M?1:-1,size:"width",children:e.jsx(Hqe,{dir:w,"data-orientation":"horizontal",...f,ref:_,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const D=S(E.clientX);l==null||l(D)},onSlideMove:E=>{const D=S(E.clientX);i==null||i(D)},onSlideEnd:()=>{j.current=void 0,d==null||d()},onStepKeyDown:E=>{const L=Bqe[M?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:L?-1:1})}})})}),A3t=T.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...h}=t,f=T.useRef(null),g=ba(s,f),v=T.useRef(void 0),_=!a;function j(w){const k=v.current||f.current.getBoundingClientRect(),M=[0,k.height],E=__e(M,_?[n,r]:[r,n]);return v.current=k,E(w-k.top)}return e.jsx(qqe,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(Hqe,{"data-orientation":"vertical",...h,ref:g,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const k=j(w.clientY);o==null||o(k)},onSlideMove:w=>{const k=j(w.clientY);l==null||l(k)},onSlideEnd:()=>{v.current=void 0,i==null||i()},onStepKeyDown:w=>{const M=Bqe[_?"from-bottom":"from-top"].includes(w.key);d==null||d({event:w,direction:M?-1:1})}})})}),Hqe=T.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...h}=t,f=Soe(W3,r);return e.jsx(Qr.span,{...h,ref:s,onKeyDown:kr(t.onKeyDown,g=>{g.key==="Home"?(l(g),g.preventDefault()):g.key==="End"?(i(g),g.preventDefault()):Fqe.concat(zqe).includes(g.key)&&(d(g),g.preventDefault())}),onPointerDown:kr(t.onPointerDown,g=>{const v=g.target;v.setPointerCapture(g.pointerId),g.preventDefault(),f.thumbs.has(v)?v.focus():n(g)}),onPointerMove:kr(t.onPointerMove,g=>{g.target.hasPointerCapture(g.pointerId)&&a(g)}),onPointerUp:kr(t.onPointerUp,g=>{const v=g.target;v.hasPointerCapture(g.pointerId)&&(v.releasePointerCapture(g.pointerId),o(g))})})}),Wqe="SliderTrack",Gqe=T.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Soe(Wqe,r);return e.jsx(Qr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});Gqe.displayName=Wqe;var Fge="SliderRange",Kqe=T.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Soe(Fge,r),o=Vqe(Fge,r),l=T.useRef(null),i=ba(s,l),d=a.values.length,h=a.values.map(v=>Xqe(v,a.min,a.max)),f=d>1?Math.min(...h):0,g=100-Math.max(...h);return e.jsx(Qr.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:f+"%",[o.endEdge]:g+"%"}})});Kqe.displayName=Fge;var zge="SliderThumb",Zqe=T.forwardRef((t,s)=>{const r=S3t(t.__scopeSlider),[n,a]=T.useState(null),o=ba(s,i=>a(i)),l=T.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(E3t,{...t,ref:o,index:l})}),E3t=T.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=Soe(zge,r),i=Vqe(zge,r),[d,h]=T.useState(null),f=ba(s,S=>h(S)),g=d?l.form||!!d.closest("form"):!0,v=k6(d),_=l.values[n],j=_===void 0?0:Xqe(_,l.min,l.max),w=L3t(n,l.values.length),k=v==null?void 0:v[i.size],M=k?O3t(k,j,i.direction):0;return T.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(${j}% + ${M}px)`},children:[e.jsx(Rge.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(Qr.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":l.min,"aria-valuenow":_,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...o,ref:f,style:_===void 0?{display:"none"}:t.style,onFocus:kr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),g&&e.jsx(Yqe,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});Zqe.displayName=zge;var I3t="RadioBubbleInput",Yqe=T.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=T.useRef(null),o=ba(a,n),l=O6(s);return T.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&f){const g=new Event("input",{bubbles:!0});f.call(i,s),i.dispatchEvent(g)}},[l,s]),e.jsx(Qr.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});Yqe.displayName=I3t;function P3t(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function Xqe(t,s,r){const o=100/(r-s)*(t-s);return iP(o,[0,100])}function L3t(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function D3t(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 O3t(t,s,r){const n=t/2,o=__e([0,50],[0,n]);return(n-o(s)*r)*r}function R3t(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function F3t(t,s){if(s>0){const r=R3t(t);return Math.min(...r)>=s}return!0}function __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 z3t(t){return(String(t).split(".")[1]||"").length}function B3t(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var Qqe=Uqe,$3t=Gqe,U3t=Kqe,q3t=Zqe;const og=T.forwardRef(({className:t,...s},r)=>e.jsxs(Qqe,{ref:r,className:$t("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx($3t,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(U3t,{className:"absolute h-full bg-primary"})}),e.jsx(q3t,{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"})]}));og.displayName=Qqe.displayName;function V3t(t,s,r){return w3t(b3t({unit:"%",width:90},r,t,s),t,s)}const b_e=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=T.useRef(null),[l,i]=T.useState(),[d,h]=T.useState(),[f,g]=T.useState(1),[v,_]=T.useState(0),j=T.useCallback(M=>{const{width:S,height:E}=M.currentTarget;i(V3t(S,E,a))},[a]),w=T.useCallback(async()=>{const M=o.current;if(!M||!d)return;const S=document.createElement("canvas"),E=S.getContext("2d");if(!E)return;const D=M.naturalWidth/M.width,L=M.naturalHeight/M.height,B=400;S.width=B,S.height=B,E.imageSmoothingQuality="high";const $=d.x*D,V=d.y*L,W=d.width*D,G=d.height*L,J=v*Math.PI/180,ne=S.width/2,ie=S.height/2;return E.save(),E.translate(ne,ie),E.rotate(J),E.scale(f,f),E.translate(-ne,-ie),E.drawImage(M,$,V,W,G,0,0,B,B),E.restore(),new Promise((ee,de)=>{S.toBlob(oe=>{oe?ee(oe):de(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,f,v]),k=async()=>{try{const M=await w();M&&(n(M),s())}catch(M){console.error("Error cropping image:",M)}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsx(Ls,{children:e.jsx(Ps,{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(N3t,{crop:l,onChange:(M,S)=>i(S),onComplete:M=>h(M),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${f}) rotate(${v}deg)`,maxHeight:"400px",width:"auto"},onLoad:j})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(G4,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(og,{value:[f],min:.5,max:3,step:.1,onValueChange:([M])=>g(M),className:"flex-1"}),e.jsx(W4,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(UE,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(og,{value:[v],min:-180,max:180,step:1,onValueChange:([M])=>_(M),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[v,"°"]})]})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(Y,{onClick:k,children:"Save Photo"})]})]})})},H3t=()=>{const{user:t}=Ys(),{toast:s}=Sa(),[r,n]=T.useState(!1),[a,o]=T.useState(!1),[l,i]=T.useState(null);T.useEffect(()=>{t&&d()},[t]);const d=async()=>{n(!0);try{const{data:g}=await Z.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)}},h=async()=>{o(!0);try{const{data:{session:g}}=await Z.auth.getSession();if(!g)throw new Error("Not authenticated");const{data:v,error:_}=await Z.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)}},f=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(ct,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(ct,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(ct,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(ct,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(ct,{variant:"secondary",children:"Canceled"});default:return e.jsx(ct,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Zm,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx($e,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Zm,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(Tr,{children:"Manage your subscription and billing"})]}),e.jsxs($e,{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:f()})]}),(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(Y,{onClick:h,variant:"outline",disabled:a,children:[a?e.jsx(Us,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(bn,{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."})]})]})},W3t=()=>{const{user:t}=Ys(),s=Yr(),{toast:r}=Sa(),[n]=Oc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:h,unsubscribe:f}=k9e(),[g,v]=T.useState(!1),[_,j]=T.useState(""),[w,k]=T.useState(!1),[M,S]=T.useState(!1),[E,D]=T.useState(""),[L,B]=T.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[$,V]=T.useState(!1),[W,G]=T.useState(!1),[J,ne]=T.useState({newPassword:"",confirmPassword:""});T.useEffect(()=>{t&&ie()},[t]),T.useEffect(()=>{o&&t&&setTimeout(()=>{var ce;(ce=document.getElementById("change-password-section"))==null||ce.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const ie=async()=>{var ce,ge,Te;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:ve,error:ye}=await Z.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(ye)throw console.error("Profile query error:",ye),ye;ve?(console.log("Profile loaded successfully:",ve),B({name:ve.name||"",email:ve.email||"",title:ve.title||"",bio:ve.bio||"",areas_served:ve.areas_served||"",years_experience:((ce=ve.years_experience)==null?void 0:ce.toString())||"",instagram_url:ve.instagram_url||"",facebook_url:ve.facebook_url||"",linkedin_url:ve.linkedin_url||"",email_signature:ve.email_signature||"",use_email_signature:ve.use_email_signature||!1}),V(ve.digest_opt_out||!1)):(console.warn("No profile found for user"),B({name:((ge=t.user_metadata)==null?void 0:ge.name)||((Te=t.email)==null?void 0:Te.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:Se}=await Z.storage.from("avatars").list(`${t.id}`);if(Se&&Se.length>0){const{data:Ke}=Z.storage.from("avatars").getPublicUrl(`${t.id}/${Se[0].name}`);j(Ke.publicUrl)}}catch(ve){console.error("Error loading profile:",ve),r({title:"Error",description:ve.message||"Failed to load profile",variant:"destructive"})}},ee=ce=>{var ve;const ge=(ve=ce.target.files)==null?void 0:ve[0];if(!ge)return;const Te=new FileReader;Te.onloadend=()=>{D(Te.result),S(!0)},Te.readAsDataURL(ge),ce.target.value=""},de=async ce=>{if(t){k(!0);try{const{data:ge}=await Z.storage.from("avatars").list(`${t.id}`);ge&&ge.length>0&&await Z.storage.from("avatars").remove(ge.map(Ke=>`${t.id}/${Ke.name}`));const ve=`${t.id}/avatar.jpg`,{error:ye}=await Z.storage.from("avatars").upload(ve,ce,{upsert:!0,contentType:"image/jpeg"});if(ye)throw ye;const{data:Se}=Z.storage.from("avatars").getPublicUrl(ve);j(`${Se.publicUrl}?t=${Date.now()}`),r({title:"Success",description:"Profile photo updated successfully"})}catch(ge){console.error("Error uploading avatar:",ge),r({title:"Error",description:ge.message||"Failed to upload photo",variant:"destructive"})}finally{k(!1)}}},oe=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:ce}=await Z.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(ce)throw ce;r({title:"Success",description:"Profile updated successfully"})}catch(ce){console.error("Error updating profile:",ce),r({title:"Error",description:ce.message||"Failed to update profile",variant:"destructive"})}finally{v(!1)}},ue=async()=>{if(!J.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(J.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(J.newPassword!==J.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}v(!0);try{const{error:ce}=await Z.auth.updateUser({password:J.newPassword});if(ce)throw ce;r({title:"Success",description:"Password updated successfully"}),ne({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(ce){console.error("Error updating password:",ce),r({title:"Error",description:ce.message||"Failed to update password",variant:"destructive"})}finally{v(!1)}};return e.jsx(Vs,{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(Y,{variant:"outline",onClick:()=>{var ce;(ce=document.getElementById("change-password-section"))==null||ce.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(kk,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Profile Photo"}),e.jsx(Tr,{children:"Upload a professional photo for your profile"})]}),e.jsxs($e,{className:"flex items-center gap-6",children:[e.jsxs(fn,{className:"h-24 w-24",children:[e.jsx(_a,{src:_}),e.jsx(gn,{className:"text-2xl",children:L.name.split(" ").map(ce=>ce[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:ee,disabled:w}),e.jsxs(Y,{variant:"outline",onClick:()=>{var ce;return(ce=document.getElementById("avatar-upload"))==null?void 0:ce.click()},disabled:w,children:[e.jsx(ji,{className:"mr-2 h-4 w-4"}),w?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Personal Information"}),e.jsx(Tr,{children:"Update your profile details"})]}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"name",children:"Name"}),e.jsx(Be,{id:"name",value:L.name,onChange:ce=>B({...L,name:ce.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"email",children:"Email"}),e.jsx(Be,{id:"email",type:"email",value:L.email,onChange:ce=>B({...L,email:ce.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"title",children:"Job Title"}),e.jsx(Be,{id:"title",value:L.title,onChange:ce=>B({...L,title:ce.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"bio",children:"Bio"}),e.jsx(Rr,{id:"bio",value:L.bio,onChange:ce=>B({...L,bio:ce.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(je,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(Be,{id:"areas_served",value:L.areas_served,onChange:ce=>B({...L,areas_served:ce.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(Be,{id:"years_experience",type:"number",min:"0",value:L.years_experience,onChange:ce=>B({...L,years_experience:ce.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(Be,{value:L.linkedin_url,onChange:ce=>B({...L,linkedin_url:ce.target.value}),placeholder:"LinkedIn URL"}),e.jsx(Be,{value:L.instagram_url,onChange:ce=>B({...L,instagram_url:ce.target.value}),placeholder:"Instagram URL"}),e.jsx(Be,{value:L.facebook_url,onChange:ce=>B({...L,facebook_url:ce.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(Y,{onClick:oe,disabled:g,children:[e.jsx(um,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Ev,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(Tr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs($e,{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(ln,{checked:L.use_email_signature,onCheckedChange:ce=>B({...L,use_email_signature:ce})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Signature"}),e.jsx(Ig,{content:L.email_signature,onChange:ce=>B({...L,email_signature:ce}),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(Y,{onClick:oe,disabled:g,children:[e.jsx(um,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Oe,{id:"change-password-section",children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:a?"Set Your Password":"Change Password"}),e.jsx(Tr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"newPassword",children:"New Password"}),e.jsx(Be,{id:"newPassword",type:"password",value:J.newPassword,onChange:ce=>ne({...J,newPassword:ce.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(Be,{id:"confirmPassword",type:"password",value:J.confirmPassword,onChange:ce=>ne({...J,confirmPassword:ce.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(Y,{onClick:ue,disabled:g,children:[e.jsx(um,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(Y,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[i?e.jsx(dg,{className:"h-5 w-5"}):e.jsx(xk,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(Tr,{children:"Receive browser notifications when new content is added"})]}),e.jsx($e,{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(ln,{checked:i,onCheckedChange:ce=>{ce?h():f()},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(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[$?e.jsx(AE,{className:"h-5 w-5"}):e.jsx(zr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(Tr,{children:"Manage your email subscription settings"})]}),e.jsx($e,{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(ln,{checked:!$,onCheckedChange:async ce=>{G(!0);try{const{error:ge}=await Z.from("profiles").update({digest_opt_out:!ce}).eq("id",t==null?void 0:t.id);if(ge)throw ge;V(!ce),r({title:ce?"Subscribed":"Unsubscribed",description:ce?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(ge){r({title:"Error",description:ge.message||"Failed to update preference",variant:"destructive"})}finally{G(!1)}},disabled:W})]})})]}),e.jsx(j2t,{}),e.jsx(H3t,{})]}),e.jsx(b_e,{open:M,onClose:()=>S(!1),imageSrc:E,onCropComplete:de,aspectRatio:1})]})})};var G3t="AspectRatio",Jqe=T.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}})})});Jqe.displayName=G3t;var K3t=Jqe;const Z3t=K3t;function Y3t(){const{user:t}=Ys(),s=vs(),[r,n]=T.useState(!1),[a,o]=T.useState(!1),{data:l,isLoading:i}=zt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:w}=await Z.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(w)throw w;return j},enabled:!!t&&a}),d=Wt({mutationFn:async()=>{const j=new Uint8Array(12);crypto.getRandomValues(j);const w=btoa(String.fromCharCode(...j)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:k}=await Z.from("profiles").update({calendar_token:w}).eq("id",t==null?void 0:t.id);if(k)throw k;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),be.success("Calendar subscription URL generated!")},onError:j=>{be.error("Failed to generate calendar URL: "+j.message)}}),h=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,f=async()=>{h&&(await navigator.clipboard.writeText(h),n(!0),be.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},g=()=>{h&&(window.location.href=h.replace("https://","webcal://"))},v=()=>{if(h){const j=h.replace("https://","webcal://"),w=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(j)}`;window.open(w,"_blank")}},_=()=>{if(h){const j=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(h)}&name=Level%20Up%20Events`;window.open(j,"_blank")}};return e.jsxs(js,{open:a,onOpenChange:o,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:"gap-2",children:[e.jsx(xn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(en,{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(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):h?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(Be,{value:h,readOnly:!0,className:"text-xs font-mono"}),e.jsx(Y,{variant:"outline",size:"icon",onClick:f,children:r?e.jsx(ma,{className:"h-4 w-4 text-green-500"}):e.jsx(Di,{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(Y,{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(bn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(Y,{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(bn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(Y,{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(bn,{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(Y,{onClick:()=>d.mutate(),disabled:d.isPending,className:"w-full",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var Coe="Tabs",[X3t]=Dc(Coe,[z3]),eVe=z3(),[Q3t,w_e]=X3t(Coe),tVe=T.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...h}=t,f=jN(i),[g,v]=Sh({prop:n,onChange:a,defaultProp:o??"",caller:Coe});return e.jsx(Q3t,{scope:r,baseId:Id(),value:g,onValueChange:v,orientation:l,dir:f,activationMode:d,children:e.jsx(Qr.div,{dir:f,"data-orientation":l,...h,ref:s})})});tVe.displayName=Coe;var sVe="TabsList",rVe=T.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=w_e(sVe,r),l=eVe(r);return e.jsx(Ive,{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})})});rVe.displayName=sVe;var nVe="TabsTrigger",aVe=T.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=w_e(nVe,r),i=eVe(r),d=lVe(l.baseId,n),h=cVe(l.baseId,n),f=n===l.value;return e.jsx(Pve,{asChild:!0,...i,focusable:!a,active:f,children:e.jsx(Qr.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:s,onMouseDown:kr(t.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?l.onValueChange(n):g.preventDefault()}),onKeyDown:kr(t.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&l.onValueChange(n)}),onFocus:kr(t.onFocus,()=>{const g=l.activationMode!=="manual";!f&&!a&&g&&l.onValueChange(n)})})})});aVe.displayName=nVe;var iVe="TabsContent",oVe=T.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=w_e(iVe,r),d=lVe(i.baseId,n),h=cVe(i.baseId,n),f=n===i.value,g=T.useRef(f);return T.useEffect(()=>{const v=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(v)},[]),e.jsx(Qc,{present:a||f,children:({present:v})=>e.jsx(Qr.div,{"data-state":f?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":d,hidden:!v,id:h,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:g.current?"0s":void 0},children:v&&o})})});oVe.displayName=iVe;function lVe(t,s){return`${t}-trigger-${s}`}function cVe(t,s){return`${t}-content-${s}`}var J3t=tVe,dVe=rVe,uVe=aVe,hVe=oVe;const Qa=J3t,Ga=T.forwardRef(({className:t,...s},r)=>e.jsx(dVe,{ref:r,className:$t("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));Ga.displayName=dVe.displayName;const Fs=T.forwardRef(({className:t,...s},r)=>e.jsx(uVe,{ref:r,className:$t("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}));Fs.displayName=uVe.displayName;const Zs=T.forwardRef(({className:t,...s},r)=>e.jsx(hVe,{ref:r,className:$t("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=hVe.displayName;const eMt={first_timer:qn,regular:s0,dedicated:nc,veteran:vo,streak_master:Ym,century:vo},tMt={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 iMe(t){return t===1?e.jsx(vo,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(s0,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(nc,{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 mVe({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Ys(),{data:o,isLoading:l}=G9e(s?5:10,r),{data:i}=K9e(a==null?void 0:a.id),{data:d}=Y9e(a==null?void 0:a.id),{data:h}=Z9e(a==null?void 0:a.id);return l?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx($e,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((f,g)=>e.jsx(ys,{className:"h-12 w-full"},g))})})]}):e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs($e,{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(ct,{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(Ym,{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"})]})]}),h&&h.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1",children:[h.slice(0,4).map(f=>{const g=eMt[f.badge_type]||qn;return e.jsxs(ct,{variant:"outline",className:`text-xs ${tMt[f.badge_type]||""}`,title:f.badge_description||"",children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),f.badge_name]},f.id)}),h.length>4&&e.jsxs(ct,{variant:"outline",className:"text-xs",children:["+",h.length-4," more"]})]})]}),e.jsxs(Qa,{defaultValue:"points",className:"w-full",children:[e.jsxs(Ga,{className:"w-full mb-3",children:[e.jsx(Fs,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(Fs,{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((f,g)=>{var v,_,j;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${f.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:iMe(g+1)}),e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{className:"text-xs",children:((_=(v=f.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:[((j=f.profile)==null?void 0:j.name)||"Unknown",f.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:[f.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:f.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},f.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((f,g)=>g.total_events_attended-f.total_events_attended).map((f,g)=>{var v,_,j;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${f.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:iMe(g+1)}),e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{className:"text-xs",children:((_=(v=f.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:[((j=f.profile)==null?void 0:j.name)||"Unknown",f.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:[f.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:f.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},f.user_id)})})})]})]})]})}function sMt(){const t=Yr(),{user:s,isAdmin:r}=Ys(),n=vs(),{data:a,isLoading:o}=zt({queryKey:["public-events"],queryFn:async()=>{const{data:w,error:k}=await Z.from("events").select("*").order("event_date",{ascending:!0});if(k)throw k;return w}}),{data:l}=zt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:w,error:k}=await Z.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(k)throw k;return w},enabled:!!s}),{data:i}=zt({queryKey:["event-registration-counts"],queryFn:async()=>{const{data:w,error:k}=await Z.from("event_registrations").select("event_id");if(k)throw k;const M={};return w.forEach(S=>{M[S.event_id]=(M[S.event_id]||0)+1}),M}}),d=Wt({mutationFn:async w=>{const{data:k,error:M}=await Z.functions.invoke("zoom-register",{body:{event_id:w}});if(M)throw M;if(k!=null&&k.error)throw new Error(k.error);return k},onSuccess:w=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),w!=null&&w.join_url?be.success("Successfully registered! You'll receive a Zoom confirmation email."):be.success("Successfully registered for the event!")},onError:w=>{be.error("Failed to register: "+w.message)}}),h=Wt({mutationFn:async w=>{const{data:k,error:M}=await Z.functions.invoke("zoom-unregister",{body:{event_id:w}});if(M)throw M;if(k!=null&&k.error)throw new Error(k.error);return k},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),be.success("Registration cancelled and removed from Zoom")},onError:w=>{be.error("Failed to cancel: "+w.message)}}),f=w=>l==null?void 0:l.some(k=>k.event_id===w),g=w=>{const k=l==null?void 0:l.find(M=>M.event_id===w);return k==null?void 0:k.zoom_join_url},v=w=>w.capacity?((i==null?void 0:i[w.id])||0)>=w.capacity:!1,_=(a==null?void 0:a.filter(w=>t5(w.event_date)!=="ended"))||[],j=(a==null?void 0:a.filter(w=>t5(w.event_date)==="ended"))||[];return e.jsx(Vs,{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(Y3t,{}),r&&e.jsx(Y,{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(Oe,{className:"text-center py-12",children:e.jsx($e,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:_.map(w=>{const k=t5(w.event_date),M=N1e(w.event_date),S=k==="live",E=k==="starting_soon";return e.jsxs(Oe,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${S?"border-red-500 ring-2 ring-red-500/20":E?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${w.id}`),children:[M&&e.jsxs("div",{className:`${S?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),S?e.jsxs(e.Fragment,{children:[e.jsx(Ek,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(ca,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),w.image_url&&e.jsx(Z3t,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:w.image_url,alt:w.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Ht,{children:[e.jsx(Gt,{className:"line-clamp-2",children:w.title}),w.description&&e.jsx(Tr,{className:"line-clamp-2",children:w.description.replace(/<[^>]*>/g,"")})]}),e.jsxs($e,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(xn,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ca,{className:"h-4 w-4"}),cP(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(br,{className:"h-4 w-4"}),(i==null?void 0:i[w.id])||0," registered",w.capacity&&` / ${w.capacity} spots`]})]}),e.jsx(rI,{className:"flex gap-2",onClick:D=>D.stopPropagation(),children:f(w.id)?e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"outline",className:"flex-1",onClick:()=>h.mutate(w.id),disabled:h.isPending,children:[e.jsx(Xr,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(Y,{className:"flex-1",onClick:()=>window.open(g(w.id)||w.zoom_link,"_blank"),children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(Y,{className:"w-full",onClick:()=>d.mutate(w.id),disabled:d.isPending||v(w),children:v(w)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},w.id)})}),j.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:j.map(w=>e.jsx(Oe,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${w.id}`),children:e.jsxs(Ht,{children:[e.jsx(Gt,{className:"text-base line-clamp-1",children:w.title}),e.jsx(Tr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))})]})},w.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(mVe,{showUserStats:!0})})]})]})})}const Ahe=[{value:"all",label:"All Roles",icon:br},{value:"brokerage_manager",label:"Brokerage Managers",icon:XE},{value:"admin",label:"Admins",icon:Bu}];function rMt({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Ge,wt;const{user:o,isAdmin:l,isBrokerageManager:i}=Ys(),[d,h]=T.useState([]),[f,g]=T.useState([]),[v,_]=T.useState([]),[j,w]=T.useState([]),[k,M]=T.useState(""),[S,E]=T.useState(""),[D,L]=T.useState(""),[B,$]=T.useState(!1),[V,W]=T.useState(!1),[G,J]=T.useState("agents"),[ne,ie]=T.useState("all"),[ee,de]=T.useState({}),oe=l||i;T.useEffect(()=>{t&&o&&(l?ue():ce())},[t,o,l]),T.useEffect(()=>{t||(_([]),w([]),M(""),E(""),L(""),J("agents"),ie("all"))},[t]);const ue=async()=>{if(o){$(!0);try{const{data:Ie,error:st}=await Z.from("brokerages").select("id, name").order("name");if(st)throw st;const he=1e3,We={};let et=0,Ye=!0;for(;Ye;){const{data:Fe,error:it}=await Z.from("profiles").select("brokerage_id").range(et*he,(et+1)*he-1);if(it)throw it;Fe==null||Fe.forEach(dt=>{dt.brokerage_id&&(We[dt.brokerage_id]=(We[dt.brokerage_id]||0)+1)}),Ye=(Fe==null?void 0:Fe.length)===he,et++}g((Ie==null?void 0:Ie.map(Fe=>({...Fe,agent_count:We[Fe.id]||0})))||[]);const ke=[];for(et=0,Ye=!0;Ye;){const{data:Fe,error:it}=await Z.from("profiles").select("id, name, email, brokerage_id, brokerages(name)").neq("id",o.id).order("name").range(et*he,(et+1)*he-1);if(it)throw it;Fe&&ke.push(...Fe),Ye=(Fe==null?void 0:Fe.length)===he,et++}const at={};for(et=0,Ye=!0;Ye;){const{data:Fe,error:it}=await Z.from("user_roles").select("user_id, role").range(et*he,(et+1)*he-1);if(it)throw it;Fe==null||Fe.forEach(dt=>{at[dt.user_id]||(at[dt.user_id]=[]),at[dt.user_id].push(dt.role)}),Ye=(Fe==null?void 0:Fe.length)===he,et++}de(at),h(ke.map(Fe=>{var it;return{id:Fe.id,name:Fe.name,email:Fe.email,brokerage_name:((it=Fe.brokerages)==null?void 0:it.name)||"No Brokerage",roles:at[Fe.id]||[]}}))}catch(Ie){console.error("Error loading data:",Ie),be.error("Failed to load agents and brokerages")}finally{$(!1)}}},ce=async()=>{if(o){$(!0);try{const{data:Ie}=await Z.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(Ie!=null&&Ie.brokerage_id)){be.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:st,error:he}=await Z.from("profiles").select("id, name, email").eq("brokerage_id",Ie.brokerage_id).neq("id",o.id).order("name");if(he)throw he;h(st||[])}catch(Ie){console.error("Error loading agents:",Ie),be.error("Failed to load agents")}finally{$(!1)}}},ge=d.filter(Ie=>{var he;const st=Ie.name.toLowerCase().includes(k.toLowerCase())||Ie.email.toLowerCase().includes(k.toLowerCase())||((he=Ie.brokerage_name)==null?void 0:he.toLowerCase().includes(k.toLowerCase()));if(l&&ne!=="all"){const We=ee[Ie.id]||[];return st&&We.includes(ne)}return st}),Te=f.filter(Ie=>Ie.name.toLowerCase().includes(S.toLowerCase())),ve=()=>{v.length===ge.length?_([]):_(ge.map(Ie=>Ie.id))},ye=()=>{j.length===Te.length?w([]):w(Te.map(Ie=>Ie.id))},Se=Ie=>{if(!oe){_([Ie]);return}_(st=>st.includes(Ie)?st.filter(he=>he!==Ie):[...st,Ie])},Ke=Ie=>{w(st=>st.includes(Ie)?st.filter(he=>he!==Ie):[...st,Ie])},Ae=async()=>{if(!(v.length>0||j.length>0)){be.error("Please select at least one agent or brokerage to share with");return}W(!0);try{const{data:st,error:he}=await Z.functions.invoke("send-share-notification",{body:{recipientIds:v,brokerageIds:j,resourceType:r,resourceId:n,resourceTitle:a,message:D.trim()||void 0}});if(he)throw he;const We=(st==null?void 0:st.sharesCreated)||v.length;be.success(`Shared with ${We} agent${We!==1?"s":""}`),s(!1)}catch(st){console.error("Error sharing resource:",st),be.error("Failed to share resource")}finally{W(!1)}},Ee=Ie=>Ie.split(" ").map(st=>st[0]).join("").toUpperCase().slice(0,2),He=Ie=>{const st=ee[Ie]||[];return st.includes("admin")?e.jsx(ct,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):st.includes("brokerage_manager")?e.jsx(ct,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Ue=v.length+j.length,De=ne!=="all"?ge.length:null;return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(Ls,{className:"flex-shrink-0",children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(Wa,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(en,{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(Qa,{value:G,onValueChange:J,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(Fs,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),v.length>0&&e.jsx(ct,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:v.length})]}),e.jsxs(Fs,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(Ya,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),j.length>0&&e.jsx(ct,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:j.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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name, email, or brokerage...",value:k,onChange:Ie=>M(Ie.target.value),className:"pl-9"})]}),e.jsxs(er,{value:ne,onValueChange:ie,children:[e.jsxs(Qs,{className:"w-[180px]",children:[e.jsx(Jy,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(tr,{placeholder:"Filter by role"})]}),e.jsx(Js,{children:Ahe.map(Ie=>e.jsx(Et,{value:Ie.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie.icon,{className:"h-4 w-4"}),e.jsx("span",{children:Ie.label})]})},Ie.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(Y,{variant:"ghost",size:"sm",onClick:ve,className:"text-xs h-8",disabled:ge.length===0,children:[e.jsx(br,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[De!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[De," ",(Ge=Ahe.find(Ie=>Ie.value===ne))==null?void 0:Ge.label]}),e.jsxs("span",{className:"font-medium",children:[v.length," selected"]})]})]}),e.jsx(po,{className:"h-[300px] border rounded-lg",children:B?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ge.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(br,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:ne!=="all"?`No ${(wt=Ahe.find(Ie=>Ie.value===ne))==null?void 0:wt.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:ge.map(Ie=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(Ie.id)?"bg-accent":""}`,onClick:()=>Se(Ie.id),children:[e.jsx(Do,{checked:v.includes(Ie.id),onCheckedChange:()=>Se(Ie.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:Ee(Ie.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:Ie.name}),He(Ie.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[Ie.email,Ie.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",Ie.brokerage_name]})]})]})]},Ie.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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search brokerages...",value:S,onChange:Ie=>E(Ie.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(Y,{variant:"ghost",size:"sm",onClick:ye,className:"text-xs h-8",disabled:Te.length===0,children:[e.jsx(Ya,{className:"h-3.5 w-3.5 mr-1.5"}),j.length===Te.length&&Te.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[j.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(po,{className:"h-[250px] border rounded-lg",children:B?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):Te.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(Ya,{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:Te.map(Ie=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${j.includes(Ie.id)?"bg-accent":""}`,onClick:()=>Ke(Ie.id),children:[e.jsx(Do,{checked:j.includes(Ie.id),onCheckedChange:()=>Ke(Ie.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(Ya,{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:Ie.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ie.agent_count," agent",Ie.agent_count!==1?"s":""]})]})]},Ie.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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search agents...",value:k,onChange:Ie=>M(Ie.target.value),className:"pl-9"})]}),oe&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(Y,{variant:"ghost",size:"sm",onClick:ve,className:"text-xs h-8",disabled:ge.length===0,children:[e.jsx(br,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[v.length," selected"]})]}),e.jsx(po,{className:"h-[300px] border rounded-lg",children:B?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ge.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(br,{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:ge.map(Ie=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(Ie.id)?"bg-accent":""}`,onClick:()=>Se(Ie.id),children:[e.jsx(Do,{checked:v.includes(Ie.id),onCheckedChange:()=>Se(Ie.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:Ee(Ie.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Ie.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ie.email})]})]},Ie.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(je,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Rr,{id:"message",placeholder:"I thought you might find this useful...",value:D,onChange:Ie=>L(Ie.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Y,{onClick:Ae,disabled:Ue===0||V,children:V?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function G3({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=T.useState(!1),{user:d}=Ys();return d?e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(Kc,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(rMt,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function nMt(){const{eventId:t}=wl(),s=Yr(),{user:r}=Ys(),[n,a]=T.useState(null),[o,l]=T.useState(null),[i,d]=T.useState(0),[h,f]=T.useState(!0),[g,v]=T.useState(!1);T.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:E,error:D}=await Z.from("events").select("*").eq("id",t).single();if(D)throw D;a(E);const{count:L}=await Z.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(d(L||0),r){const{data:B}=await Z.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(B)}}catch(E){console.error("Error loading event:",E),be.error("Failed to load event"),s("/events")}finally{f(!1)}},j=async()=>{if(!(!r||!n)){v(!0);try{if(o){const{error:E}=await Z.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(E)throw E;be.success("Successfully cancelled registration"),l(null),d(D=>D-1)}else{const{data:E,error:D}=await Z.functions.invoke("zoom-register",{body:{event_id:n.id}});if(D)throw D;be.success("Successfully registered for event!"),l({id:E.registration_id,zoom_join_url:E.zoom_join_url}),d(L=>L+1)}}catch(E){console.error("Registration error:",E),be.error(o?"Failed to cancel registration":"Failed to register for event")}finally{v(!1)}}},w=E=>{var D,L,B;if(E.includes("iframe.mediadelivery.net")||E.includes("video.bunnycdn.com")){const $=E.match(/embed\/(\d+)\/([a-f0-9-]+)/);if($)return`https://iframe.mediadelivery.net/embed/${$[1]}/${$[2]}?autoplay=false&preload=true`}if(E.includes("youtube.com")||E.includes("youtu.be")){const $=E.includes("youtu.be")?(D=E.split("youtu.be/")[1])==null?void 0:D.split("?")[0]:(L=E.split("v=")[1])==null?void 0:L.split("&")[0];if($)return`https://www.youtube.com/embed/${$}`}if(E.includes("vimeo.com")){const $=(B=E.split("vimeo.com/")[1])==null?void 0:B.split("?")[0];if($)return`https://player.vimeo.com/video/${$}`}return E};if(h)return e.jsx(Vs,{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(Vs,{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(Y,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const k=Ix(new Date(n.event_date)),M=n.capacity&&i>=n.capacity,S=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Vs,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(Y,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(bi,{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"}),k&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(ct,{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(G3,{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(Om,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src:w(n.video_url),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Event Preview Video"})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(Oe,{children:e.jsxs($e,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(xn,{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:cP(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(br,{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(yi,{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:[!k&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(Y,{className:"w-full gap-2",onClick:()=>window.open(S,"_blank"),children:[e.jsx(bn,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(Y,{variant:"outline",className:"w-full",onClick:j,disabled:g,children:[g?e.jsx(Us,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(Y,{className:"w-full gap-2",onClick:j,disabled:g||(M??!1),children:g?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):M?"Event Full":"Register Now"})}),k&&o&&e.jsxs(Y,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(bn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const aMt=()=>{const{user:t,isAdmin:s}=Ys(),r=Yr(),[n,a]=T.useState([]),[o,l]=T.useState(!0),[i,d]=T.useState(""),[h,f]=T.useState("all"),[g,v]=T.useState(new Set);T.useEffect(()=>{_()},[t]);const _=async()=>{try{const{data:S}=await Z.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),E=(S==null?void 0:S.map(G=>G.tag))||[],{data:D,error:L}=await Z.from("app_tiles").select("*").order("name");if(L)throw L;const{data:B}=await Z.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),$=new Set((B==null?void 0:B.map(G=>G.app_id))||[]);v($);const W=((D==null?void 0:D.filter(G=>!G.required_tags||G.required_tags.length===0?!0:G.required_tags.some(J=>E.includes(J))))||[]).sort((G,J)=>G.name==="LevelUp Members Portal"?-1:J.name==="LevelUp Members Portal"?1:0);a(W)}catch(S){console.error("Error loading apps:",S),be.error("Failed to load apps")}finally{l(!1)}},j=async S=>{var D;const E=window.open("about:blank","_blank");try{const{data:L,error:B}=await Z.auth.getSession();if(B||!L.session){E==null||E.close(),be.error("Session expired. Please refresh the page and try again.");return}const $=L.session.access_token;await Z.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:S.app_id,app_name:S.name,user_agent:navigator.userAgent});const{data:V,error:W}=await Z.functions.invoke("sso-launch",{body:{app_id:S.app_id},headers:{Authorization:`Bearer ${$}`}});if(W)throw W;V!=null&&V.redirect_url?E&&!E.closed?(E.location.href=V.redirect_url,(D=E.focus)==null||D.call(E)):window.location.assign(V.redirect_url):(E==null||E.close(),be.error("Launch link unavailable"))}catch(L){E==null||E.close(),console.error("Error launching app:",L),be.error("Failed to launch app. Please try again.")}},w=async(S,E)=>{S.stopPropagation();const D=g.has(E);try{if(D){const{error:L}=await Z.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",E);if(L)throw L;v(B=>{const $=new Set(B);return $.delete(E),$}),be.success("Removed from favorites")}else{const{error:L}=await Z.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:E});if(L)throw L;v(B=>new Set(B).add(E)),be.success("Added to favorites")}}catch(L){console.error("Error toggling favorite:",L),be.error("Failed to update favorites")}},k=n.filter(S=>{var D;const E=S.name.toLowerCase().includes(i.toLowerCase())||((D=S.description)==null?void 0:D.toLowerCase().includes(i.toLowerCase()));return h==="favorites"?E&&g.has(S.id):E}),M=[{id:"all",label:"All"},{id:"favorites",label:"Favorites"}];return o?e.jsx(Vs,{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(Vs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search apps...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:S=>d(S.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:M.map(S=>e.jsxs("button",{onClick:()=>f(S.id),className:$t("pb-3 text-sm font-medium transition-colors relative",h===S.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[S.label,h===S.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},S.id))}),k.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:h==="favorites"?e.jsxs(e.Fragment,{children:[e.jsx(ug,{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(zu,{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(Y,{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:k.map(S=>{const E=g.has(S.id),D=S.name.toLowerCase().includes("agent review")||S.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:()=>j(S),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:S.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:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:S.description})]}),e.jsx("button",{className:$t("flex-shrink-0 p-1 transition-colors",E?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:L=>w(L,S.id),children:e.jsx(ug,{className:$t("h-5 w-5",E&&"fill-current")})})]}),D&&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 →"})]},S.id)})})]})},iMt=()=>{const t=Yr(),[s,r]=T.useState(""),[n,a]=T.useState("all"),[o,l]=T.useState("all"),[i,d]=T.useState("grid"),{data:h=[]}=zt({queryKey:["template-categories"],queryFn:async()=>{const{data:M,error:S}=await Z.from("template_categories").select("*").order("name");if(S)throw S;return M}}),{data:f=[]}=zt({queryKey:["template-types"],queryFn:async()=>{const{data:M,error:S}=await Z.from("template_types").select("*").order("name");if(S)throw S;return M}}),{data:g=[],isLoading:v}=zt({queryKey:["canva-templates"],queryFn:async()=>{const{data:M,error:S}=await Z.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(S)throw S;const{data:E,error:D}=await Z.from("template_links").select("*").order("sort_order");if(D)throw D;const{data:L}=await Z.from("template_likes").select("template_id"),{data:B}=await Z.from("template_comments").select("template_id"),$=new Map;L==null||L.forEach(G=>{$.set(G.template_id,($.get(G.template_id)||0)+1)});const V=new Map;return B==null||B.forEach(G=>{V.set(G.template_id,(V.get(G.template_id)||0)+1)}),(M||[]).map(G=>({...G,links:(E||[]).filter(J=>J.template_id===G.id)||[],likesCount:$.get(G.id)||0,commentsCount:V.get(G.id)||0}))}}),_=g.filter(M=>{var L;const S=M.name.toLowerCase().includes(s.toLowerCase())||((L=M.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),E=n==="all"||M.category_id===n,D=o==="all"||M.type_id===o;return S&&E&&D}),j=()=>{r(""),a("all"),l("all")},w=s||n!=="all"||o!=="all",k=M=>{t(`/templates/${M}`)};return e.jsx(Vs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search templates...",value:s,onChange:M=>r(M.target.value),className:"pl-9"})]}),e.jsxs(er,{value:n,onValueChange:a,children:[e.jsx(Qs,{className:"w-full sm:w-48",children:e.jsx(tr,{placeholder:"All Categories"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Categories"}),h.map(M=>e.jsx(Et,{value:M.id,children:M.name},M.id))]})]}),e.jsxs(er,{value:o,onValueChange:l,children:[e.jsx(Qs,{className:"w-full sm:w-48",children:e.jsx(tr,{placeholder:"All Types"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Types"}),f.map(M=>e.jsx(Et,{value:M.id,children:M.name},M.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[w&&e.jsx(Y,{variant:"outline",size:"sm",onClick:j,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>d("grid"),className:"rounded-full",children:e.jsx(Qm,{className:"h-4 w-4"})}),e.jsx(Y,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:e.jsx(dm,{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((M,S)=>e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ys,{className:"h-5 w-16"}),e.jsx(ys,{className:"h-5 w-20"})]})]})},S))}),!v&&_.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:w?"No templates match your filters":"No templates available yet"}),w&&e.jsx(Y,{variant:"outline",onClick:j,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(M=>e.jsxs(Oe,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>k(M.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[M.preview_image_url?e.jsx("img",{src:M.preview_image_url,alt:M.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"}),M.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(ct,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Ro,{className:"h-3 w-3"}),M.links.length]})})]}),e.jsxs($e,{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:M.name}),M.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:pie(M.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[M.category&&e.jsx(ct,{variant:"secondary",className:"text-xs",children:M.category.name}),M.type&&e.jsx(ct,{variant:"outline",className:"text-xs",children:M.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(Ed,{className:"h-3.5 w-3.5"}),M.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gl,{className:"h-3.5 w-3.5"}),M.commentsCount]})]}),e.jsxs(Y,{size:"sm",className:"w-full gap-2",onClick:S=>{S.stopPropagation(),k(M.id)},children:[e.jsx(bn,{className:"h-4 w-4"}),"View Template"]})]})]},M.id))})]})})};var oMt="Separator",oMe="horizontal",lMt=["horizontal","vertical"],pVe=T.forwardRef((t,s)=>{const{decorative:r,orientation:n=oMe,...a}=t,o=cMt(n)?n:oMe,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})});pVe.displayName=oMt;function cMt(t){return lMt.includes(t)}var fVe=pVe;const ud=T.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(fVe,{ref:a,decorative:r,orientation:s,className:$t("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));ud.displayName=fVe.displayName;const G6=()=>({trackEngagement:T.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await Z.auth.getUser();if(!o)return;await Z.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)}},[])}),dMt=()=>{const{templateId:t}=wl(),{user:s,isAdmin:r}=Ys(),{toast:n}=Sa(),a=vs(),{trackEngagement:o}=G6(),[l,i]=T.useState(""),{data:d,isLoading:h}=zt({queryKey:["template-detail",t],queryFn:async()=>{const{data:S,error:E}=await Z.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(E)throw E;const{data:D}=await Z.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:L}=await Z.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...S,links:D||[],guides:L||[]}},enabled:!!t});T.useEffect(()=>{d&&o("template",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:f=[]}=zt({queryKey:["template-likes",t],queryFn:async()=>{const{data:S,error:E}=await Z.from("template_likes").select("*").eq("template_id",t);if(E)throw E;return S},enabled:!!t}),{data:g=[]}=zt({queryKey:["template-comments",t],queryFn:async()=>{const{data:S,error:E}=await Z.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(E)throw E;const D=[...new Set(S.map($=>$.user_id))],{data:L}=await Z.from("profiles").select("id, name").in("id",D),B=new Map((L==null?void 0:L.map($=>[$.id,$.name]))||[]);return S.map($=>({...$,user_name:B.get($.user_id)||"Unknown User"}))},enabled:!!t}),v=Wt({mutationFn:async S=>{const{error:E}=await Z.from("template_comments").insert({template_id:t,user_id:s.id,content:S});if(E)throw E},onSuccess:()=>{a.invalidateQueries({queryKey:["template-comments",t]}),i(""),n({title:"Comment added!"})},onError:S=>{n({title:"Error adding comment",description:S.message,variant:"destructive"})}}),_=Wt({mutationFn:async S=>{const{error:E}=await Z.from("template_comments").delete().eq("id",S);if(E)throw E},onSuccess:()=>{a.invalidateQueries({queryKey:["template-comments",t]}),n({title:"Comment deleted"})}}),j=Wt({mutationFn:async()=>{const S=f.find(E=>E.user_id===(s==null?void 0:s.id));if(S){const{error:E}=await Z.from("template_likes").delete().eq("id",S.id);if(E)throw E}else{const{error:E}=await Z.from("template_likes").insert({template_id:t,user_id:s.id});if(E)throw E}},onSuccess:()=>{a.invalidateQueries({queryKey:["template-likes",t]})}}),w=f.some(S=>S.user_id===(s==null?void 0:s.id)),k=S=>S.split(" ").map(E=>E[0]).join("").toUpperCase().slice(0,2),M=S=>{S.preventDefault(),!(!l.trim()||!s)&&v.mutate(l.trim())};return h?e.jsx(Vs,{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"})})}):d?e.jsx(Vs,{title:d.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Y,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(bo,{to:"/templates",children:[e.jsx(bi,{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:d.name}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.category&&e.jsx(ct,{variant:"secondary",children:d.category.name}),d.type&&e.jsx(ct,{variant:"outline",children:d.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(Y,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(bo,{to:`/admin/templates?edit=${d.id}`,children:[e.jsx(Xa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(G3,{resourceType:"template",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),e.jsxs(Y,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>j.mutate(),disabled:!s||j.isPending,children:[e.jsx(Ed,{className:`h-4 w-4 ${w?"fill-current":""}`}),f.length," ",f.length===1?"Like":"Likes"]})]})]}),d.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:d.description}})]}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Ro,{className:"h-4 w-4"}),d.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:d.links.map(S=>e.jsxs(Y,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{o("template",d.id,d.name,"click_canva"),window.open(S.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:S.title}),e.jsx(bn,{className:"h-4 w-4 text-muted-foreground"})]},S.id))})]})}),d.video_url&&e.jsx(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:e.jsx("iframe",{src:d.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})}),d.guides&&d.guides.length>0&&e.jsx(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Yn,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:d.guides.map(S=>e.jsxs(Y,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{o("template",d.id,d.name,"click_pdf"),window.open(S.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:S.name}),S.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(S.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(Vi,{className:"h-4 w-4 text-muted-foreground"})]},S.id))})]})}),e.jsx(ud,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Gl,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),s?e.jsxs("form",{onSubmit:M,className:"flex gap-2",children:[e.jsx(Rr,{placeholder:"Add a comment...",value:l,onChange:S=>i(S.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(Y,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:e.jsx(Wa,{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(Oe,{children:e.jsx($e,{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(S=>e.jsx(Oe,{children:e.jsx($e,{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:k(S.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:S.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_u(new Date(S.created_at),{addSuffix:!0})}),S.user_id===(s==null?void 0:s.id)&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(S.id),children:e.jsx(Ir,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:S.content})]})]})})},S.id))})]})]})}):e.jsx(Vs,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ro,{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(Y,{asChild:!0,className:"mt-4",children:e.jsx(bo,{to:"/templates",children:"Back to Templates"})})]})})},uMt=()=>{const{user:t}=Ys(),[s,r]=T.useState(""),[n,a]=T.useState("all"),{data:o=[]}=zt({queryKey:["academy-categories"],queryFn:async()=>{const{data:v,error:_}=await Z.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(_)throw _;return v}}),{data:l=[],isLoading:i}=zt({queryKey:["academy-videos"],queryFn:async()=>{const{data:v,error:_}=await Z.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;const{data:j,error:w}=await Z.from("academy_resources").select("*").order("sort_order");if(w)throw w;return v.map(M=>({...M,resources:(j==null?void 0:j.filter(S=>S.video_id===M.id))||[]}))}}),{data:d=[]}=zt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:v,error:_}=await Z.from("academy_video_likes").select("video_id, user_id");if(_)throw _;return v}}),h=l.filter(v=>{var w;const _=s===""||v.title.toLowerCase().includes(s.toLowerCase())||((w=v.description)==null?void 0:w.toLowerCase().includes(s.toLowerCase())),j=n==="all"||v.category_id===n;return _&&j}),f=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(Vs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search videos...",value:s,onChange:v=>r(v.target.value),className:"pl-10"})]})}),e.jsx(Qa,{value:n,onValueChange:a,children:e.jsxs(Ga,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(Fs,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(v=>e.jsx(Fs,{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"})}):h.length===0?e.jsx(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Wn,{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:h.map(v=>e.jsx(bo,{to:`/academy/${v.id}`,children:e.jsxs(Oe,{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(Wn,{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(Kl,{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(ca,{className:"h-3 w-3"}),v.duration]})]}),e.jsxs(Ht,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Gt,{className:"text-lg line-clamp-2",children:v.title})}),v.category&&e.jsx(ct,{variant:"secondary",className:"w-fit",children:v.category.name})]}),e.jsxs($e,{className:"pt-0",children:[v.description&&e.jsx(Tr,{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(Ed,{className:`h-4 w-4 ${g(v.id)?"fill-primary text-primary":""}`}),f(v.id)]}),v.resources&&v.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Yn,{className:"h-4 w-4"}),v.resources.length]})]})]})]})},v.id))})]})})};function gVe({resourceType:t,resourceId:s}){const{data:r=[]}=zt({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await Z.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 Z.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(hd,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(bo,{to:`/templates/${n.id}`,children:e.jsxs(ct,{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(hd,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const hMt=(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},mMt=()=>{const{videoId:t}=wl();Yr();const{user:s,isAdmin:r}=Ys(),{toast:n}=Sa(),a=vs(),{trackEngagement:o}=G6(),[l,i]=T.useState(""),{data:d,isLoading:h}=zt({queryKey:["academy-video",t],queryFn:async()=>{const{data:E,error:D}=await Z.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(D)throw D;const{data:L}=await Z.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...E,resources:L||[]}},enabled:!!t});T.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:f=[]}=zt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:E,error:D}=await Z.from("academy_video_likes").select("*").eq("video_id",t);if(D)throw D;return E},enabled:!!t}),{data:g=[]}=zt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:E,error:D}=await Z.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(D)throw D;const L=[...new Set(E.map(V=>V.user_id))],{data:B}=await Z.from("profiles").select("id, name").in("id",L),$=new Map((B==null?void 0:B.map(V=>[V.id,V.name]))||[]);return E.map(V=>({...V,user_name:$.get(V.user_id)||"Unknown User"}))},enabled:!!t}),v=Wt({mutationFn:async E=>{const{error:D}=await Z.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:E});if(D)throw D},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:E=>{n({title:"Error adding comment",description:E.message,variant:"destructive"})}}),_=Wt({mutationFn:async E=>{const{error:D}=await Z.from("academy_video_comments").delete().eq("id",E);if(D)throw D},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),j=Wt({mutationFn:async()=>{const E=f.find(D=>D.user_id===(s==null?void 0:s.id));if(E){const{error:D}=await Z.from("academy_video_likes").delete().eq("id",E.id);if(D)throw D}else{const{error:D}=await Z.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(D)throw D}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),w=f.some(E=>E.user_id===(s==null?void 0:s.id)),k=E=>{switch(E==null?void 0:E.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},M=E=>E.split(" ").map(D=>D[0]).join("").toUpperCase().slice(0,2),S=E=>{E.preventDefault(),!(!l.trim()||!s)&&v.mutate(l.trim())};return h?e.jsx(Vs,{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(Vs,{title:d.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Y,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(bo,{to:"/academy",children:[e.jsx(bi,{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:hMt(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(Wn,{className:"h-16 w-16 opacity-50"}),e.jsx(Y,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:d.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(bn,{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(ct,{variant:"secondary",children:d.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(Y,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(bo,{to:`/admin/academy?edit=${d.id}`,children:[e.jsx(Xa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(G3,{resourceType:"academy_video",resourceId:d.id,resourceTitle:d.title}),e.jsxs(Y,{variant:w?"default":"outline",className:"gap-2 w-fit",onClick:()=>j.mutate(),disabled:!s||j.isPending,children:[e.jsx(Ed,{className:`h-4 w-4 ${w?"fill-current":""}`}),f.length," ",f.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(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Yn,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:d.resources.map(E=>e.jsxs("a",{href:E.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:k(E.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:E.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:E.file_type})]}),e.jsx(Vi,{className:"h-4 w-4 text-muted-foreground"})]},E.id))})]})}),e.jsx(gVe,{resourceType:"academy_video",resourceId:d.id}),e.jsx(ud,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Gl,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Rr,{placeholder:"Add a comment...",value:l,onChange:E=>i(E.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(Y,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:e.jsx(Wa,{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(Oe,{children:e.jsx($e,{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(E=>e.jsx(Oe,{children:e.jsx($e,{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:M(E.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:E.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_u(new Date(E.created_at),{addSuffix:!0})}),E.user_id===(s==null?void 0:s.id)&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(E.id),children:e.jsx(Ir,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:E.content})]})]})})},E.id))})]})]})}):e.jsx(Vs,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Wn,{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(Y,{asChild:!0,className:"mt-4",children:e.jsx(bo,{to:"/academy",children:"Back to Academy"})})]})})};function pMt(){const t=Yr(),[s,r]=T.useState(""),{data:n,isLoading:a}=zt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:_,error:j}=await Z.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(j)throw j;return _}}),{data:o}=zt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:_,error:j}=await Z.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(j)throw j;return _}}),{data:l}=zt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:_,error:j}=await Z.from("resource_kit_likes").select("kit_id");if(j)throw j;return _}}),{data:i}=zt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:_,error:j}=await Z.from("resource_kit_comments").select("kit_id");if(j)throw j;return _}}),d=n==null?void 0:n.filter(_=>{var j;return _.name.toLowerCase().includes(s.toLowerCase())||((j=_.description)==null?void 0:j.toLowerCase().includes(s.toLowerCase()))}),h=_=>(o==null?void 0:o.filter(j=>j.kit_id===_))||[],f=_=>(l==null?void 0:l.filter(j=>j.kit_id===_).length)||0,g=_=>(i==null?void 0:i.filter(j=>j.kit_id===_).length)||0,v=_=>{t(`/toolbox/${_}`)};return e.jsx(Vs,{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(On,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{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((_,j)=>e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsx(ys,{className:"h-4 w-2/3"})]})},j))}):(d==null?void 0:d.length)===0?e.jsxs(Oe,{className:"p-12 text-center",children:[e.jsx(mc,{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 j=h(_.id).length,w=f(_.id),k=g(_.id);return e.jsxs(Oe,{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(mc,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs($e,{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:pie(_.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(Yn,{className:"h-4 w-4"}),j," file",j!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ed,{className:"h-3.5 w-3.5"}),w]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gl,{className:"h-3.5 w-3.5"}),k]})]})]})]})]},_.id)})})]})})}const fMt=()=>{const{kitId:t}=wl(),{user:s,isAdmin:r}=Ys(),{toast:n}=Sa(),a=vs(),{trackEngagement:o}=G6(),[l,i]=T.useState(""),{data:d,isLoading:h}=zt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:E,error:D}=await Z.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(D)throw D;const{data:L}=await Z.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:B}=await Z.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...E,files:L||[],links:B||[]}},enabled:!!t});T.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:f=[]}=zt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:E,error:D}=await Z.from("resource_kit_likes").select("*").eq("kit_id",t);if(D)throw D;return E},enabled:!!t}),{data:g=[]}=zt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:E,error:D}=await Z.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(D)throw D;const L=[...new Set(E.map(V=>V.user_id))],{data:B}=await Z.from("profiles").select("id, name").in("id",L),$=new Map((B==null?void 0:B.map(V=>[V.id,V.name]))||[]);return E.map(V=>({...V,user_name:$.get(V.user_id)||"Unknown User"}))},enabled:!!t}),v=Wt({mutationFn:async E=>{const{error:D}=await Z.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:E});if(D)throw D},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:E=>{n({title:"Error adding comment",description:E.message,variant:"destructive"})}}),_=Wt({mutationFn:async E=>{const{error:D}=await Z.from("resource_kit_comments").delete().eq("id",E);if(D)throw D},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),j=Wt({mutationFn:async()=>{const E=f.find(D=>D.user_id===(s==null?void 0:s.id));if(E){const{error:D}=await Z.from("resource_kit_likes").delete().eq("id",E.id);if(D)throw D}else{const{error:D}=await Z.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(D)throw D}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),w=f.some(E=>E.user_id===(s==null?void 0:s.id)),k=E=>E.split(" ").map(D=>D[0]).join("").toUpperCase().slice(0,2),M=E=>E?E<1024?E+" B":E<1024*1024?(E/1024).toFixed(1)+" KB":(E/(1024*1024)).toFixed(1)+" MB":"",S=E=>{E.preventDefault(),!(!l.trim()||!s)&&v.mutate(l.trim())};return h?e.jsx(Vs,{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(Vs,{title:d.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Y,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(bo,{to:"/toolbox",children:[e.jsx(bi,{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(Y,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(bo,{to:`/admin/toolbox?edit=${d.id}`,children:[e.jsx(Xa,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(G3,{resourceType:"resource_kit",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),e.jsxs(Y,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>j.mutate(),disabled:!s||j.isPending,children:[e.jsx(Ed,{className:`h-4 w-4 ${w?"fill-current":""}`}),f.length," ",f.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(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Yn,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.files.map(E=>e.jsxs("a",{href:E.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(Yn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:E.name}),E.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:M(E.file_size)})]})]}),e.jsx(Vi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},E.id))})]})}),d.links&&d.links.length>0&&e.jsx(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(bn,{className:"h-4 w-4"}),"Canva Templates (",d.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.links.map(E=>e.jsxs("a",{href:E.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(bn,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:E.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},E.id))})]})}),e.jsx(gVe,{resourceType:"resource_kit",resourceId:d.id}),e.jsx(ud,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Gl,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Rr,{placeholder:"Add a comment...",value:l,onChange:E=>i(E.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(Y,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:e.jsx(Wa,{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(Oe,{children:e.jsx($e,{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(E=>e.jsx(Oe,{children:e.jsx($e,{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:k(E.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:E.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_u(new Date(E.created_at),{addSuffix:!0})}),E.user_id===(s==null?void 0:s.id)&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(E.id),children:e.jsx(Ir,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:E.content})]})]})})},E.id))})]})]})}):e.jsx(Vs,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mc,{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(Y,{asChild:!0,className:"mt-4",children:e.jsx(bo,{to:"/toolbox",children:"Back to Toolbox"})})]})})},gMt=()=>{const t=Yr(),[s,r]=T.useState(""),[n,a]=T.useState("grid"),{data:o=[],isLoading:l}=zt({queryKey:["social-swag"],queryFn:async()=>{const{data:h,error:f}=await Z.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(f)throw f;const{data:g,error:v}=await Z.from("social_swag_links").select("*").order("sort_order");if(v)throw v;const{data:_}=await Z.from("social_swag_likes").select("swag_id"),{data:j}=await Z.from("social_swag_comments").select("swag_id"),w=new Map;_==null||_.forEach(S=>{w.set(S.swag_id,(w.get(S.swag_id)||0)+1)});const k=new Map;return j==null||j.forEach(S=>{k.set(S.swag_id,(k.get(S.swag_id)||0)+1)}),(h||[]).map(S=>({...S,links:(g||[]).filter(E=>E.swag_id===S.id)||[],likesCount:w.get(S.id)||0,commentsCount:k.get(S.id)||0}))}}),i=o.filter(h=>{var g;return h.title.toLowerCase().includes(s.toLowerCase())||((g=h.description)==null?void 0:g.toLowerCase().includes(s.toLowerCase()))}),d=h=>{t(`/social-swag/${h}`)};return e.jsx(Vs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search social swag...",value:s,onChange:h=>r(h.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Qm,{className:"h-4 w-4"})}),e.jsx(Y,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(dm,{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((h,f)=>e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"})]})},f))}),!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(Y,{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(h=>e.jsxs(Oe,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>d(h.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${n==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[h.preview_image_url?e.jsx("img",{src:h.preview_image_url,alt:h.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"}),h.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(ct,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Ro,{className:"h-3 w-3"}),h.links.length]})})]}),e.jsxs($e,{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:h.title}),h.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:h.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(Ed,{className:"h-3.5 w-3.5"}),h.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gl,{className:"h-3.5 w-3.5"}),h.commentsCount]})]}),e.jsxs(Y,{size:"sm",className:"w-full gap-2",onClick:f=>{f.stopPropagation(),d(h.id)},children:[e.jsx(bn,{className:"h-4 w-4"}),"View Details"]})]})]},h.id))})]})})};var ri=function(){return ri=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(d||!h),g=s>1&&(h||!d),v=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(ZMt,{displayMonth:t.displayMonth,hideNext:f,hidePrevious:g,nextMonth:a,previousMonth:n,onPreviousClick:v,onNextClick:_})}function YMt(t){var s,r=jl(),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:vVe,h;return a?h=e.jsx(d,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?h=e.jsx(lMe,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?h=e.jsxs(e.Fragment,{children:[e.jsx(lMe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(cMe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):h=e.jsxs(e.Fragment,{children:[e.jsx(d,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(cMe,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:h})}function XMt(t){var s=jl(),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 QMt(t,s,r){for(var n=r?y0(new Date):Uu(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=Ul(n,o);a.push(l)}return a}function JMt(){var t=jl(),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,h=QMt(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}),h.map(function(f,g){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":d(f,{locale:a}),children:i(f,{locale:a})},g)})]})}function eTt(){var t,s=jl(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:JMt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function tTt(t){var s=jl(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var j_e=T.createContext(void 0);function sTt(t){if(!K6(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(j_e.Provider,{value:s,children:t.children})}return e.jsx(rTt,{initialProps:t.initialProps,children:t.children})}function rTt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(h,f,g){var v,_;(v=s.onDayClick)===null||v===void 0||v.call(s,h,f,g);var j=!!(f.selected&&a&&(n==null?void 0:n.length)===a);if(!j){var w=!!(!f.selected&&o&&(n==null?void 0:n.length)===o);if(!w){var k=n?xVe([],n):[];if(f.selected){var M=k.findIndex(function(S){return Vl(h,S)});k.splice(M,1)}else k.push(h);(_=s.onSelect)===null||_===void 0||_.call(s,k,h,f,g)}}},i={disabled:[]};n&&i.disabled.push(function(h){var f=o&&n.length>o-1,g=n.some(function(v){return Vl(v,h)});return!!(f&&!g)});var d={selected:n,onDayClick:l,modifiers:i};return e.jsx(j_e.Provider,{value:d,children:r})}function k_e(){var t=T.useContext(j_e);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function nTt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?Vl(a,t)&&Vl(n,t)?void 0:Vl(a,t)?{from:a,to:void 0}:Vl(n,t)?void 0:Are(n,t)?{from:t,to:a}:{from:n,to:t}:a?Are(t,a)?{from:a,to:t}:{from:t,to:a}:n?Hie(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var N_e=T.createContext(void 0);function aTt(t){if(!Z6(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(N_e.Provider,{value:s,children:t.children})}return e.jsx(iTt,{initialProps:t.initialProps,children:t.children})}function iTt(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,h=function(_,j,w){var k,M;(k=s.onDayClick)===null||k===void 0||k.call(s,_,j,w);var S=nTt(_,n);(M=s.onSelect)===null||M===void 0||M.call(s,S,_,j,w)},f={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(f.range_start=[o],l?(f.range_end=[l],Vl(o,l)||(f.range_middle=[{after:o,before:l}])):f.range_end=[o]):l&&(f.range_start=[l],f.range_end=[l]),i&&(o&&!l&&f.disabled.push({after:jse(o,i-1),before:Ul(o,i-1)}),o&&l&&f.disabled.push({after:o,before:Ul(o,i-1)}),!o&&l&&f.disabled.push({after:jse(l,i-1),before:Ul(l,i-1)})),d){if(o&&!l&&(f.disabled.push({before:Ul(o,-d+1)}),f.disabled.push({after:Ul(o,d-1)})),o&&l){var g=ig(l,o)+1,v=d-g;f.disabled.push({before:jse(o,v)}),f.disabled.push({after:Ul(l,v)})}!o&&l&&(f.disabled.push({before:Ul(l,-d+1)}),f.disabled.push({after:Ul(l,d-1)}))}return e.jsx(N_e.Provider,{value:{selected:n,onDayClick:h,modifiers:f},children:r})}function S_e(){var t=T.useContext(N_e);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Pse(t){return Array.isArray(t)?xVe([],t):t!==void 0?[t]:[]}function oTt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=Pse(a)}),s}var Cg;(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"})(Cg||(Cg={}));var lTt=Cg.Selected,Ny=Cg.Disabled,cTt=Cg.Hidden,dTt=Cg.Today,Ehe=Cg.RangeEnd,Ihe=Cg.RangeMiddle,Phe=Cg.RangeStart,uTt=Cg.Outside;function hTt(t,s,r){var n,a=(n={},n[lTt]=Pse(t.selected),n[Ny]=Pse(t.disabled),n[cTt]=Pse(t.hidden),n[dTt]=[t.today],n[Ehe]=[],n[Ihe]=[],n[Phe]=[],n[uTt]=[],n);return t.fromDate&&a[Ny].push({before:t.fromDate}),t.toDate&&a[Ny].push({after:t.toDate}),K6(t)?a[Ny]=a[Ny].concat(s.modifiers[Ny]):Z6(t)&&(a[Ny]=a[Ny].concat(r.modifiers[Ny]),a[Phe]=r.modifiers[Phe],a[Ihe]=r.modifiers[Ihe],a[Ehe]=r.modifiers[Ehe]),a}var wVe=T.createContext(void 0);function mTt(t){var s=jl(),r=k_e(),n=S_e(),a=hTt(s,r,n),o=oTt(s.modifiers),l=ri(ri({},a),o);return e.jsx(wVe.Provider,{value:l,children:t.children})}function jVe(){var t=T.useContext(wVe);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function pTt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function fTt(t){return!!(t&&typeof t=="object"&&"from"in t)}function gTt(t){return!!(t&&typeof t=="object"&&"after"in t)}function xTt(t){return!!(t&&typeof t=="object"&&"before"in t)}function yTt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function vTt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=ig(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=ig(t,n)>=0&&ig(a,t)>=0;return l}return a?Vl(a,t):n?Vl(n,t):!1}function _Tt(t){return Xve(t)}function bTt(t){return Array.isArray(t)&&t.every(Xve)}function wTt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(_Tt(r))return Vl(t,r);if(bTt(r))return r.includes(t);if(fTt(r))return vTt(t,r);if(yTt(r))return r.dayOfWeek.includes(t.getDay());if(pTt(r)){var n=ig(r.before,t),a=ig(r.after,t),o=n>0,l=a<0,i=Are(r.before,r.after);return i?l&&o:o||l}return gTt(r)?ig(t,r.after)>0:xTt(r)?ig(r.before,t)>0:typeof r=="function"?r(t):!1})}function C_e(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return wTt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Wie(t,r)&&(a.outside=!0),a}function jTt(t,s){for(var r=Nh(t[0]),n=F6(t[t.length-1]),a,o,l=r;l<=n;){var i=C_e(l,s),d=!i.disabled&&!i.hidden;if(!d){l=Ul(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=Ul(l,1)}return o||a}var kTt=365;function kVe(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,h=a.fromDate,f=a.toDate,g=a.locale,v={day:Ul,week:Gj,month:Ch,year:Txt,startOfWeek:function(k){return a.ISOWeek?y0(k):Uu(k,{locale:g,weekStartsOn:d})},endOfWeek:function(k){return a.ISOWeek?G7e(k):qie(k,{locale:g,weekStartsOn:d})}},_=v[r](t,n==="after"?1:-1);n==="before"&&h?_=Axt([h,_]):n==="after"&&f&&(_=Ext([f,_]));var j=!0;if(o){var w=C_e(_,o);j=!w.disabled&&!w.hidden}return j?_:i.count>kTt?i.lastFocused:kVe(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:ri(ri({},i),{count:i.count+1})})}var NVe=T.createContext(void 0);function NTt(t){var s=Y6(),r=jVe(),n=T.useState(),a=n[0],o=n[1],l=T.useState(),i=l[0],d=l[1],h=jTt(s.displayMonths,r),f=a??(i&&s.isDateDisplayed(i))?i:h,g=function(){d(a),o(void 0)},v=function(k){o(k)},_=jl(),j=function(k,M){if(a){var S=kVe(a,{moveBy:k,direction:M,context:_,modifiers:r});Vl(a,S)||(s.goToDate(S,a),v(S))}},w={focusedDay:a,focusTarget:f,blur:g,focus:v,focusDayAfter:function(){return j("day","after")},focusDayBefore:function(){return j("day","before")},focusWeekAfter:function(){return j("week","after")},focusWeekBefore:function(){return j("week","before")},focusMonthBefore:function(){return j("month","before")},focusMonthAfter:function(){return j("month","after")},focusYearBefore:function(){return j("year","before")},focusYearAfter:function(){return j("year","after")},focusStartOfWeek:function(){return j("startOfWeek","before")},focusEndOfWeek:function(){return j("endOfWeek","after")}};return e.jsx(NVe.Provider,{value:w,children:t.children})}function M_e(){var t=T.useContext(NVe);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function STt(t,s){var r=jVe(),n=C_e(t,r,s);return n}var T_e=T.createContext(void 0);function CTt(t){if(!Moe(t.initialProps)){var s={selected:void 0};return e.jsx(T_e.Provider,{value:s,children:t.children})}return e.jsx(MTt,{initialProps:t.initialProps,children:t.children})}function MTt(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var d,h,f;if((d=s.onDayClick)===null||d===void 0||d.call(s,o,l,i),l.selected&&!s.required){(h=s.onSelect)===null||h===void 0||h.call(s,void 0,o,l,i);return}(f=s.onSelect)===null||f===void 0||f.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(T_e.Provider,{value:a,children:r})}function SVe(){var t=T.useContext(T_e);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function TTt(t,s){var r=jl(),n=SVe(),a=k_e(),o=S_e(),l=M_e(),i=l.focusDayAfter,d=l.focusDayBefore,h=l.focusWeekAfter,f=l.focusWeekBefore,g=l.blur,v=l.focus,_=l.focusMonthBefore,j=l.focusMonthAfter,w=l.focusYearBefore,k=l.focusYearAfter,M=l.focusStartOfWeek,S=l.focusEndOfWeek,E=function(ue){var ce,ge,Te,ve;Moe(r)?(ce=n.onDayClick)===null||ce===void 0||ce.call(n,t,s,ue):K6(r)?(ge=a.onDayClick)===null||ge===void 0||ge.call(a,t,s,ue):Z6(r)?(Te=o.onDayClick)===null||Te===void 0||Te.call(o,t,s,ue):(ve=r.onDayClick)===null||ve===void 0||ve.call(r,t,s,ue)},D=function(ue){var ce;v(t),(ce=r.onDayFocus)===null||ce===void 0||ce.call(r,t,s,ue)},L=function(ue){var ce;g(),(ce=r.onDayBlur)===null||ce===void 0||ce.call(r,t,s,ue)},B=function(ue){var ce;(ce=r.onDayMouseEnter)===null||ce===void 0||ce.call(r,t,s,ue)},$=function(ue){var ce;(ce=r.onDayMouseLeave)===null||ce===void 0||ce.call(r,t,s,ue)},V=function(ue){var ce;(ce=r.onDayPointerEnter)===null||ce===void 0||ce.call(r,t,s,ue)},W=function(ue){var ce;(ce=r.onDayPointerLeave)===null||ce===void 0||ce.call(r,t,s,ue)},G=function(ue){var ce;(ce=r.onDayTouchCancel)===null||ce===void 0||ce.call(r,t,s,ue)},J=function(ue){var ce;(ce=r.onDayTouchEnd)===null||ce===void 0||ce.call(r,t,s,ue)},ne=function(ue){var ce;(ce=r.onDayTouchMove)===null||ce===void 0||ce.call(r,t,s,ue)},ie=function(ue){var ce;(ce=r.onDayTouchStart)===null||ce===void 0||ce.call(r,t,s,ue)},ee=function(ue){var ce;(ce=r.onDayKeyUp)===null||ce===void 0||ce.call(r,t,s,ue)},de=function(ue){var ce;switch(ue.key){case"ArrowLeft":ue.preventDefault(),ue.stopPropagation(),r.dir==="rtl"?i():d();break;case"ArrowRight":ue.preventDefault(),ue.stopPropagation(),r.dir==="rtl"?d():i();break;case"ArrowDown":ue.preventDefault(),ue.stopPropagation(),h();break;case"ArrowUp":ue.preventDefault(),ue.stopPropagation(),f();break;case"PageUp":ue.preventDefault(),ue.stopPropagation(),ue.shiftKey?w():_();break;case"PageDown":ue.preventDefault(),ue.stopPropagation(),ue.shiftKey?k():j();break;case"Home":ue.preventDefault(),ue.stopPropagation(),M();break;case"End":ue.preventDefault(),ue.stopPropagation(),S();break}(ce=r.onDayKeyDown)===null||ce===void 0||ce.call(r,t,s,ue)},oe={onClick:E,onFocus:D,onBlur:L,onKeyDown:de,onKeyUp:ee,onMouseEnter:B,onMouseLeave:$,onPointerEnter:V,onPointerLeave:W,onTouchCancel:G,onTouchEnd:J,onTouchMove:ne,onTouchStart:ie};return oe}function ATt(){var t=jl(),s=SVe(),r=k_e(),n=S_e(),a=Moe(t)?s.selected:K6(t)?r.selected:Z6(t)?n.selected:void 0;return a}function ETt(t){return Object.values(Cg).includes(t)}function ITt(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(ETt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function PTt(t,s){var r=ri({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ri(ri({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function LTt(t,s,r){var n,a,o,l=jl(),i=M_e(),d=STt(t,s),h=TTt(t,d),f=ATt(),g=!!(l.onDayClick||l.mode!=="default");T.useEffect(function(){var B;d.outside||i.focusedDay&&g&&Vl(i.focusedDay,t)&&((B=r.current)===null||B===void 0||B.focus())},[i.focusedDay,t,r,g,d.outside]);var v=ITt(l,d).join(" "),_=PTt(l,d),j=!!(d.outside&&!l.showOutsideDays||d.hidden),w=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:tTt,k=e.jsx(w,{date:t,displayMonth:s,activeModifiers:d}),M={style:_,className:v,children:k,role:"gridcell"},S=i.focusTarget&&Vl(i.focusTarget,t)&&!d.outside,E=i.focusedDay&&Vl(i.focusedDay,t),D=ri(ri(ri({},M),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=E||S?0:-1,n)),h),L={isButton:g,isHidden:j,activeModifiers:d,selectedDays:f,buttonProps:D,divProps:M};return L}function DTt(t){var s=T.useRef(null),r=LTt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(Dne,ri({name:"day",ref:s},r.buttonProps)):e.jsx("div",ri({},r.divProps))}function OTt(t){var s=t.number,r=t.dates,n=jl(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,d=n.labels.labelWeekNumber,h=n.formatters.formatWeekNumber,f=h(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:f});var g=d(Number(s),{locale:i}),v=function(_){a(s,r,_)};return e.jsx(Dne,{name:"week-number","aria-label":g,className:l.weeknumber,style:o.weeknumber,onClick:v,children:f})}function RTt(t){var s,r,n=jl(),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:DTt,h=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:OTt,f;return l&&(f=e.jsx("td",{className:o.cell,style:a.cell,children:e.jsx(h,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:o.row,style:a.row,children:[f,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})},Lyt(g))})]})}function dMe(t,s,r){for(var n=r!=null&&r.ISOWeek?G7e(s):qie(s,r),a=r!=null&&r.ISOWeek?y0(t):Uu(t,r),o=ig(n,a),l=[],i=0;i<=o;i++)l.push(Ul(a,i));var d=l.reduce(function(h,f){var g=r!=null&&r.ISOWeek?Qve(f):e1e(f,r),v=h.find(function(_){return _.weekNumber===g});return v?(v.dates.push(f),h):(h.push({weekNumber:g,dates:[f]}),h)},[]);return d}function FTt(t,s){var r=dMe(Nh(t),F6(t),s);if(s!=null&&s.useFixedWeeks){var n=Oyt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=Gj(o,6-n),i=dMe(Gj(o,1),l,s);r.push.apply(r,i)}}return r}function zTt(t){var s,r,n,a=jl(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,h=a.fixedWeeks,f=a.components,g=a.weekStartsOn,v=a.firstWeekContainsDate,_=a.ISOWeek,j=FTt(t.displayMonth,{useFixedWeeks:!!h,ISOWeek:_,locale:o,weekStartsOn:g,firstWeekContainsDate:v}),w=(s=f==null?void 0:f.Head)!==null&&s!==void 0?s:eTt,k=(r=f==null?void 0:f.Row)!==null&&r!==void 0?r:RTt,M=(n=f==null?void 0:f.Footer)!==null&&n!==void 0?n:XMt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!d&&e.jsx(w,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:j.map(function(S){return e.jsx(k,{displayMonth:t.displayMonth,dates:S.dates,weekNumber:S.weekNumber},S.weekNumber)})}),e.jsx(M,{displayMonth:t.displayMonth})]})}function BTt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var $Tt=BTt()?T.useLayoutEffect:T.useEffect,Lhe=!1,UTt=0;function uMe(){return"react-day-picker-".concat(++UTt)}function qTt(t){var s,r=t??(Lhe?uMe():null),n=T.useState(r),a=n[0],o=n[1];return $Tt(function(){a===null&&o(uMe())},[]),T.useEffect(function(){Lhe===!1&&(Lhe=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function VTt(t){var s,r,n=jl(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=Y6().displayMonths,h=qTt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),f=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,g=[o.month],v=l.month,_=t.displayIndex===0,j=t.displayIndex===d.length-1,w=!_&&!j;a==="rtl"&&(s=[_,j],j=s[0],_=s[1]),_&&(g.push(o.caption_start),v=ri(ri({},v),l.caption_start)),j&&(g.push(o.caption_end),v=ri(ri({},v),l.caption_end)),w&&(g.push(o.caption_between),v=ri(ri({},v),l.caption_between));var k=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:YMt;return e.jsxs("div",{className:g.join(" "),style:v,children:[e.jsx(k,{id:h,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(zTt,{id:f,"aria-labelledby":h,displayMonth:t.displayMonth})]},t.displayIndex)}function HTt(t){var s=jl(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function WTt(t){var s,r,n=t.initialProps,a=jl(),o=M_e(),l=Y6(),i=T.useState(!1),d=i[0],h=i[1];T.useEffect(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),h(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var f=[a.classNames.root,a.className];a.numberOfMonths>1&&f.push(a.classNames.multiple_months),a.showWeekNumber&&f.push(a.classNames.with_weeknumber);var g=ri(ri({},a.styles.root),a.style),v=Object.keys(n).filter(function(j){return j.startsWith("data-")}).reduce(function(j,w){var k;return ri(ri({},j),(k={},k[w]=n[w],k))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:HTt;return e.jsx("div",ri({className:f.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(j,w){return e.jsx(VTt,{displayIndex:w,displayMonth:j},w)})})}))}function GTt(t){var s=t.children,r=xMt(t,["children"]);return e.jsx(OMt,{initialProps:r,children:e.jsx(WMt,{children:e.jsx(CTt,{initialProps:r,children:e.jsx(sTt,{initialProps:r,children:e.jsx(aTt,{initialProps:r,children:e.jsx(mTt,{children:e.jsx(NTt,{children:s})})})})})})})}function KTt(t){return e.jsx(GTt,ri({},t,{children:e.jsx(WTt,{initialProps:t})}))}function Qp({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(KTt,{showOutsideDays:r,className:$t("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:$t(rP({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:$t(rP({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(hc,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(Ri,{className:"h-4 w-4"})},...n})}Qp.displayName="Calendar";var Toe="Popover",[CVe]=Dc(Toe,[Wx]),X6=Wx(),[ZTt,g_]=CVe(Toe),MVe=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=X6(s),d=T.useRef(null),[h,f]=T.useState(!1),[g,v]=Sh({prop:n,defaultProp:a??!1,onChange:o,caller:Toe});return e.jsx(N6,{...i,children:e.jsx(ZTt,{scope:s,contentId:Id(),triggerRef:d,open:g,onOpenChange:v,onOpenToggle:T.useCallback(()=>v(_=>!_),[v]),hasCustomAnchor:h,onCustomAnchorAdd:T.useCallback(()=>f(!0),[]),onCustomAnchorRemove:T.useCallback(()=>f(!1),[]),modal:l,children:r})})};MVe.displayName=Toe;var TVe="PopoverAnchor",YTt=T.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=g_(TVe,r),o=X6(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return T.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(I3,{...o,...n,ref:s})});YTt.displayName=TVe;var AVe="PopoverTrigger",EVe=T.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=g_(AVe,r),o=X6(r),l=ba(s,a.triggerRef),i=e.jsx(Qr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":OVe(a.open),...n,ref:l,onClick:kr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(I3,{asChild:!0,...o,children:i})});EVe.displayName=AVe;var A_e="PopoverPortal",[XTt,QTt]=CVe(A_e,{forceMount:void 0}),IVe=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=g_(A_e,s);return e.jsx(XTt,{scope:s,forceMount:r,children:e.jsx(Qc,{present:r||o.open,children:e.jsx(C3,{asChild:!0,container:a,children:n})})})};IVe.displayName=A_e;var Y5="PopoverContent",PVe=T.forwardRef((t,s)=>{const r=QTt(Y5,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=g_(Y5,t.__scopePopover);return e.jsx(Qc,{present:n||o.open,children:o.modal?e.jsx(eAt,{...a,ref:s}):e.jsx(tAt,{...a,ref:s})})});PVe.displayName=Y5;var JTt=W1("PopoverContent.RemoveScroll"),eAt=T.forwardRef((t,s)=>{const r=g_(Y5,t.__scopePopover),n=T.useRef(null),a=ba(s,n),o=T.useRef(!1);return T.useEffect(()=>{const l=n.current;if(l)return Nie(l)},[]),e.jsx(E6,{as:JTt,allowPinchZoom:!0,children:e.jsx(LVe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:kr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:kr(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,d=i.button===0&&i.ctrlKey===!0,h=i.button===2||d;o.current=h},{checkForDefaultPrevented:!1}),onFocusOutside:kr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),tAt=T.forwardRef((t,s)=>{const r=g_(Y5,t.__scopePopover),n=T.useRef(!1),a=T.useRef(!1);return e.jsx(LVe,{...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,h;(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;((h=r.triggerRef.current)==null?void 0:h.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),LVe=T.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:f,...g}=t,v=g_(Y5,r),_=X6(r);return kie(),e.jsx(T6,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(n_,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:f,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:h,onDismiss:()=>v.onOpenChange(!1),children:e.jsx(S6,{"data-state":OVe(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)"}})})})}),DVe="PopoverClose",sAt=T.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=g_(DVe,r);return e.jsx(Qr.button,{type:"button",...n,ref:s,onClick:kr(t.onClick,()=>a.onOpenChange(!1))})});sAt.displayName=DVe;var rAt="PopoverArrow",nAt=T.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=X6(r);return e.jsx(C6,{...a,...n,ref:s})});nAt.displayName=rAt;function OVe(t){return t?"open":"closed"}var aAt=MVe,iAt=EVe,oAt=IVe,RVe=PVe;const _l=aAt,bl=iAt,nl=T.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(oAt,{children:e.jsx(RVe,{ref:a,align:s,sideOffset:r,className:$t("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})}));nl.displayName=RVe.displayName;const lAt=M3("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"}}),E_e=T.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:$t(lAt({variant:s}),t),...r}));E_e.displayName="Alert";const cAt=T.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:$t("mb-1 font-medium leading-none tracking-tight",t),...s}));cAt.displayName="AlertTitle";const I_e=T.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:$t("text-sm [&_p]:leading-relaxed",t),...s}));I_e.displayName="AlertDescription";function dAt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=vs(),[d,h]=T.useState(a),[f,g]=T.useState([]),[v,_]=T.useState(null),[j,w]=T.useState("now"),[k,M]=T.useState(k4e(E4e(new Date),1)),[S,E]=T.useState("12"),[D,L]=T.useState("00"),[B,$]=T.useState("PM");T.useEffect(()=>{if(t){h(a),w("now"),g([]);const Se=k4e(E4e(new Date),1);M(Se);const Ke=Se.getHours();E(String(Ke>12?Ke-12:Ke===0?12:Ke)),L("00"),$(Ke>=12?"PM":"AM")}},[t,a]);const V=()=>{if(!k)return null;let Se=parseInt(S);const Ke=parseInt(D);return B==="PM"&&Se!==12&&(Se+=12),B==="AM"&&Se===12&&(Se=0),rBe(sBe(k,Se),Ke)},{data:W,isLoading:G}=zt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:Se}}=await Z.auth.getUser();if(!Se)return[];const{data:Ke,error:Ae}=await Z.from("social_accounts").select("*").eq("user_id",Se.id).eq("is_active",!0).order("platform",{ascending:!0});if(Ae)throw Ae;return console.log("Fetched social accounts for posting:",Ke),Ke},enabled:t,staleTime:0}),J=Wt({mutationFn:async({accountId:Se,platform:Ke})=>{_(Se);const{data:Ae,error:Ee}=await Z.functions.invoke("social-post",{body:{platform:Ke,accountId:Se,imageUrl:r,caption:d}});if(Ee)throw Ee;if(Ae!=null&&Ae.error)throw new Error(Ae.error);return Ae},onSuccess:Se=>{const Ke=Se.platform==="facebook"?"Facebook":Se.platform==="instagram"?"Instagram":Se.platform==="linkedin"?"LinkedIn":"Google Business";be.success(`Posted to ${Ke}!`)},onError:Se=>{be.error(`Failed to post: ${Se.message}`)},onSettled:()=>{_(null)}}),ne=Wt({mutationFn:async({accountId:Se,platform:Ke,scheduledFor:Ae})=>{const{data:{user:Ee}}=await Z.auth.getUser();if(!Ee)throw new Error("Not authenticated");const{error:He}=await Z.from("scheduled_posts").insert({user_id:Ee.id,social_account_id:Se,platform:Ke,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:Ae.toISOString(),status:"scheduled"});if(He)throw He;return{platform:Ke}},onSuccess:Se=>{const Ke=Se.platform==="facebook"?"Facebook":Se.platform==="instagram"?"Instagram":"LinkedIn";be.success(`Post scheduled for ${Ke}!`)},onError:Se=>{be.error(`Failed to schedule: ${Se.message}`)}}),ie=async()=>{if(f.length===0){be.error("Please select at least one account");return}if(j==="schedule"){const Se=V();if(!Se||Se<=new Date){be.error("Please select a future date and time");return}for(const Ke of f){const Ae=W==null?void 0:W.find(Ee=>Ee.id===Ke);Ae&&await ne.mutateAsync({accountId:Ke,platform:Ae.platform,scheduledFor:Se})}i.invalidateQueries({queryKey:["scheduled-posts"]}),be.success(`${f.length} post(s) scheduled for ${Bs(Se,"PPp")}`)}else for(const Se of f){const Ke=W==null?void 0:W.find(Ae=>Ae.id===Se);Ke&&await J.mutateAsync({accountId:Se,platform:Ke.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),h(""),g([]),s(!1)},ee=Se=>{g(Ke=>Ke.includes(Se)?Ke.filter(Ae=>Ae!==Se):[...Ke,Se])},de=(W==null?void 0:W.filter(Se=>Se.platform==="facebook"))||[],oe=(W==null?void 0:W.filter(Se=>Se.platform==="instagram"))||[],ue=(W==null?void 0:W.filter(Se=>Se.platform==="linkedin"))||[],ce=(W==null?void 0:W.filter(Se=>Se.platform==="google_business"))||[],ge=((W==null?void 0:W.length)||0)>0,Te=J.isPending||ne.isPending,ve=Array.from({length:12},(Se,Ke)=>String(Ke+1)),ye=["00","15","30","45"];return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Create Social Post"}),e.jsx(en,{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(je,{htmlFor:"caption",children:"Caption"}),e.jsx(Rr,{id:"caption",placeholder:"Write a caption for your post...",value:d,onChange:Se=>h(Se.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(je,{children:"Publish Time"}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>w("now"),className:$t("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",j==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>w("schedule"),className:$t("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",j==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),j==="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(ca,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("justify-start text-left font-normal flex-1",!k&&"text-muted-foreground"),children:[e.jsx(xn,{className:"mr-2 h-4 w-4"}),k?Bs(k,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{mode:"single",selected:k,onSelect:M,disabled:Se=>See.jsx(Et,{value:Se,children:Se},Se))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(er,{value:D,onValueChange:L,children:[e.jsx(Qs,{className:"w-[70px]",children:e.jsx(tr,{})}),e.jsx(Js,{children:ye.map(Se=>e.jsx(Et,{value:Se,children:Se},Se))})]}),e.jsxs(er,{value:B,onValueChange:Se=>$(Se),children:[e.jsx(Qs,{className:"w-[70px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"AM",children:"AM"}),e.jsx(Et,{value:"PM",children:"PM"})]})]})]})]}),k&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",Bs(V()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{children:"Post to"}),G&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Us,{className:"h-6 w-6 animate-spin"})}),!G&&!ge&&e.jsxs(E_e,{children:[e.jsx(Qo,{className:"h-4 w-4"}),e.jsxs(I_e,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(bo,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(Ic,{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(Qd,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),de.map(Se=>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(Do,{checked:f.includes(Se.id),onCheckedChange:()=>ee(Se.id),disabled:v===Se.id}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(_a,{src:Se.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Qd,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Se.page_name||Se.platform_username}),v===Se.id&&e.jsx(Us,{className:"h-4 w-4 animate-spin"})]},Se.id))]}),oe.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(vu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),oe.map(Se=>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(Do,{checked:f.includes(Se.id),onCheckedChange:()=>ee(Se.id),disabled:v===Se.id}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(_a,{src:Se.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(vu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",Se.platform_username]}),v===Se.id&&e.jsx(Us,{className:"h-4 w-4 animate-spin"})]},Se.id))]}),ue.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(cm,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),ue.map(Se=>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(Do,{checked:f.includes(Se.id),onCheckedChange:()=>ee(Se.id),disabled:v===Se.id}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(_a,{src:Se.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(cm,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Se.platform_username}),v===Se.id&&e.jsx(Us,{className:"h-4 w-4 animate-spin"})]},Se.id))]}),ce.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(Gi,{className:"h-4 w-4 text-red-600"})," Google Business"]}),ce.map(Se=>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(Do,{checked:f.includes(Se.id),onCheckedChange:()=>ee(Se.id),disabled:v===Se.id}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(_a,{src:Se.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Gi,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Se.page_name||Se.platform_username}),v===Se.id&&e.jsx(Us,{className:"h-4 w-4 animate-spin"})]},Se.id))]})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{onClick:ie,disabled:f.length===0||Te,className:"gap-2",children:[Te?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):j==="schedule"?e.jsx(xn,{className:"h-4 w-4"}):e.jsx(Wa,{className:"h-4 w-4"}),j==="schedule"?`Schedule ${f.length} post${f.length!==1?"s":""}`:`Post to ${f.length} account${f.length!==1?"s":""}`]})]})]})})}function uAt(){const t=vs(),[s,r]=T.useState(void 0),[n,a]=T.useState("all"),[o,l]=T.useState(null),[i,d]=T.useState(""),[h,f]=T.useState(void 0),[g,v]=T.useState("12"),[_,j]=T.useState("00"),[w,k]=T.useState("PM"),{data:M=[],isLoading:S}=zt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:ce,error:ge}=await Z.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(ge)throw ge;return ce}}),E=M.filter(ce=>{if(n!=="all"&&ce.status!==n)return!1;if(s&&ce.scheduled_for){const ge=new Date(ce.scheduled_for);if(!Vl(ge,s))return!1}return!0}),D=M.filter(ce=>ce.scheduled_for).map(ce=>ip(new Date(ce.scheduled_for))),L=Wt({mutationFn:async ce=>{const{error:ge}=await Z.from("scheduled_posts").update({caption:ce.caption,scheduled_for:ce.scheduled_for}).eq("id",ce.id);if(ge)throw ge},onSuccess:()=>{be.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:ce=>{be.error(`Failed to update: ${ce.message}`)}}),B=Wt({mutationFn:async ce=>{const{error:ge}=await Z.from("scheduled_posts").update({status:"cancelled"}).eq("id",ce);if(ge)throw ge},onSuccess:()=>{be.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{be.error(`Failed to cancel: ${ce.message}`)}}),$=Wt({mutationFn:async ce=>{const{error:ge}=await Z.from("scheduled_posts").delete().eq("id",ce);if(ge)throw ge},onSuccess:()=>{be.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{be.error(`Failed to delete: ${ce.message}`)}}),V=Wt({mutationFn:async ce=>{const{data:ge,error:Te}=await Z.functions.invoke("social-post",{body:{platform:ce.platform,accountId:ce.social_account_id,imageUrl:ce.image_url,caption:ce.caption}});if(Te)throw Te;if(ge!=null&&ge.error)throw new Error(ge.error);return await Z.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:ge.postId}).eq("id",ce.id),ge},onSuccess:ce=>{const ge=ce.platform==="facebook"?"Facebook":ce.platform==="instagram"?"Instagram":"LinkedIn";be.success(`Posted to ${ge}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{be.error(`Failed to post: ${ce.message}`)}}),W=ce=>{if(l(ce),d(ce.caption||""),ce.scheduled_for){const ge=new Date(ce.scheduled_for);f(ge);const Te=ge.getHours();v(String(Te>12?Te-12:Te===0?12:Te)),j(String(ge.getMinutes()).padStart(2,"0")),k(Te>=12?"PM":"AM")}},G=()=>{if(!o||!h)return;let ce=parseInt(g);const ge=parseInt(_);w==="PM"&&ce!==12&&(ce+=12),w==="AM"&&ce===12&&(ce=0);const Te=rBe(sBe(h,ce),ge);L.mutate({id:o.id,caption:i,scheduled_for:Te.toISOString()})},J=ce=>{switch(ce){case"facebook":return e.jsx(Qd,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(vu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(cm,{className:"h-4 w-4 text-blue-700"});default:return null}},ne=ce=>{switch(ce){case"scheduled":return e.jsxs(ct,{variant:"secondary",className:"gap-1",children:[e.jsx(ca,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(ct,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(yi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(ct,{variant:"destructive",className:"gap-1",children:[e.jsx(Cc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(ct,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Qo,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(ct,{variant:"outline",children:ce})}},ie=Array.from({length:12},(ce,ge)=>String(ge+1)),ee=["00","15","30","45"],de=M.filter(ce=>ce.status==="scheduled").length,oe=M.filter(ce=>ce.status==="posted").length,ue=M.filter(ce=>ce.status==="scheduled"&&ce.scheduled_for&&Ryt(new Date(ce.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(Oe,{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(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ue}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:oe}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:M.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(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Km,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(Qp,{mode:"single",selected:s,onSelect:r,className:$t("pointer-events-auto"),modifiers:{hasPost:D},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(Y,{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(Jy,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(ce=>e.jsx(Y,{variant:n===ce?"default":"outline",size:"sm",onClick:()=>a(ce),className:"capitalize",children:ce},ce))})]}),S&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!S&&E.length===0&&e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(xn,{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 ${Bs(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:E.map(ce=>{var ge,Te;return e.jsx(Oe,{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:ce.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs($e,{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:[J(ce.platform),e.jsx("span",{className:"font-medium",children:((ge=ce.social_accounts)==null?void 0:ge.page_name)||((Te=ce.social_accounts)==null?void 0:Te.platform_username)||"Unknown"}),ne(ce.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[ce.status==="scheduled"&&e.jsxs(bN,{children:[e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>W(ce),children:e.jsx(Xa,{className:"h-4 w-4"})})}),e.jsx(fh,{children:"Edit post"})]}),e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>V.mutate(ce),disabled:V.isPending,children:V.isPending?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(Wa,{className:"h-4 w-4"})})}),e.jsx(fh,{children:"Post now"})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Cancel this scheduled post?"}),e.jsx(cc,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Keep"}),e.jsx(Hl,{onClick:()=>B.mutate(ce.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(Hl,{onClick:()=>$.mutate(ce.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(ce.status==="posted"||ce.status==="cancelled"||ce.status==="failed")&&e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Delete this post?"}),e.jsx(cc,{children:"This will permanently remove this post from your history."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:()=>$.mutate(ce.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),ce.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:ce.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ca,{className:"h-3 w-3"}),ce.status==="posted"&&ce.posted_at?`Posted ${Bs(new Date(ce.posted_at),"PPp")}`:ce.scheduled_for?`Scheduled for ${Bs(new Date(ce.scheduled_for),"PPp")}`:"Not scheduled"]}),ce.status==="failed"&&ce.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",ce.error_message]})]})]})},ce.id)})})]})]}),e.jsx(js,{open:!!o,onOpenChange:ce=>!ce&&l(null),children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Edit Scheduled Post"}),e.jsx(en,{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(je,{children:"Caption"}),e.jsx(Rr,{value:i,onChange:ce=>d(ce.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(je,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("justify-start text-left font-normal flex-1",!h&&"text-muted-foreground"),children:[e.jsx(xn,{className:"mr-2 h-4 w-4"}),h?Bs(h,"PPP"):"Pick a date"]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{mode:"single",selected:h,onSelect:f,disabled:ce=>cee.jsx(Et,{value:ce,children:ce},ce))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(er,{value:_,onValueChange:j,children:[e.jsx(Qs,{className:"w-[70px]",children:e.jsx(tr,{})}),e.jsx(Js,{children:ee.map(ce=>e.jsx(Et,{value:ce,children:ce},ce))})]}),e.jsxs(er,{value:w,onValueChange:ce=>k(ce),children:[e.jsx(Qs,{className:"w-[70px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"AM",children:"AM"}),e.jsx(Et,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(Y,{onClick:G,disabled:L.isPending,children:[L.isPending?e.jsx(Us,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function l8(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 FVe={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(h,f){if(!a[h]){if(!n[h]){var g=typeof l8=="function"&&l8;if(!f&&g)return g(h,!0);if(i)return i(h,!0);var v=new Error("Cannot find module '"+h+"'");throw v.code="MODULE_NOT_FOUND",v}var _=a[h]={exports:{}};n[h][0].call(_.exports,function(j){var w=n[h][1][j];return l(w||j)},_,_.exports,r,n,a,o)}return a[h].exports}for(var i=typeof l8=="function"&&l8,d=0;d>2,_=(3&h)<<4|f>>4,j=1>6:64,w=2>4,f=(15&v)<<4|(_=i.indexOf(d.charAt(w++)))>>2,g=(3&_)<<6|(j=i.indexOf(d.charAt(w++))),S[k++]=h,_!==64&&(S[k++]=f),j!==64&&(S[k++]=g);return S}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),d=r("./stream/DataLengthProbe");function h(f,g,v,_,j){this.compressedSize=f,this.uncompressedSize=g,this.crc32=v,this.compression=_,this.compressedContent=j}h.prototype={getContentWorker:function(){var f=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new d("data_length")),g=this;return f.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),f},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)}},h.createWorkerFrom=function(f,g,v){return f.pipe(new i).pipe(new d("uncompressedSize")).pipe(g.compressWorker(v)).pipe(new d("compressedSize")).withStreamInfo("compression",g)},n.exports=h},{"./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=[],h=0;h<256;h++){i=h;for(var f=0;f<8;f++)i=1&i?3988292384^i>>>1:i>>>1;d[h]=i}return d}();n.exports=function(i,d){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(h,f,g,v){var _=l,j=v+g;h^=-1;for(var w=v;w>>8^_[255&(h^f[w])];return-1^h}(0|d,i,i.length,0):function(h,f,g,v){var _=l,j=v+g;h^=-1;for(var w=v;w>>8^_[255&(h^f.charCodeAt(w))];return-1^h}(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"),h=o?"uint8array":"array";function f(g,v){d.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=v,this.meta={}}a.magic="\b\0",i.inherits(f,d),f.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(h,g.data),!1)},f.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},f.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 f("Deflate",g)},a.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(_,j){var w,k="";for(w=0;w>>=8;return k}function l(_,j,w,k,M,S){var E,D,L=_.file,B=_.compression,$=S!==h.utf8encode,V=i.transformTo("string",S(L.name)),W=i.transformTo("string",h.utf8encode(L.name)),G=L.comment,J=i.transformTo("string",S(G)),ne=i.transformTo("string",h.utf8encode(G)),ie=W.length!==L.name.length,ee=ne.length!==G.length,de="",oe="",ue="",ce=L.dir,ge=L.date,Te={crc32:0,compressedSize:0,uncompressedSize:0};j&&!w||(Te.crc32=_.crc32,Te.compressedSize=_.compressedSize,Te.uncompressedSize=_.uncompressedSize);var ve=0;j&&(ve|=8),$||!ie&&!ee||(ve|=2048);var ye=0,Se=0;ce&&(ye|=16),M==="UNIX"?(Se=798,ye|=function(Ae,Ee){var He=Ae;return Ae||(He=Ee?16893:33204),(65535&He)<<16}(L.unixPermissions,ce)):(Se=20,ye|=function(Ae){return 63&(Ae||0)}(L.dosPermissions)),E=ge.getUTCHours(),E<<=6,E|=ge.getUTCMinutes(),E<<=5,E|=ge.getUTCSeconds()/2,D=ge.getUTCFullYear()-1980,D<<=4,D|=ge.getUTCMonth()+1,D<<=5,D|=ge.getUTCDate(),ie&&(oe=o(1,1)+o(f(V),4)+W,de+="up"+o(oe.length,2)+oe),ee&&(ue=o(1,1)+o(f(J),4)+ne,de+="uc"+o(ue.length,2)+ue);var Ke="";return Ke+=` \0`,Ke+=o(ve,2),Ke+=B.magic,Ke+=o(E,2),Ke+=o(D,2),Ke+=o(Te.crc32,4),Ke+=o(Te.compressedSize,4),Ke+=o(Te.uncompressedSize,4),Ke+=o(V.length,2),Ke+=o(de.length,2),{fileRecord:g.LOCAL_FILE_HEADER+Ke+V+de,dirRecord:g.CENTRAL_FILE_HEADER+o(Se,2)+Ke+o(J.length,2)+"\0\0\0\0"+o(ye,4)+o(k,4)+V+de+J}}var i=r("../utils"),d=r("../stream/GenericWorker"),h=r("../utf8"),f=r("../crc32"),g=r("../signature");function v(_,j,w,k){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=j,this.zipPlatform=w,this.encodeFileName=k,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 j=_.meta.percent||0,w=this.entriesCount,k=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,d.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:w?(j+100*(w-k-1))/w:100}}))},v.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var j=this.streamFiles&&!_.file.dir;if(j){var w=l(_,j,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:w.fileRecord,meta:{percent:0}})}else this.accumulate=!0},v.prototype.closedSource=function(_){this.accumulate=!1;var j=this.streamFiles&&!_.file.dir,w=l(_,j,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(w.dirRecord),j)this.push({data:function(k){return g.DATA_DESCRIPTOR+o(k.crc32,4)+o(k.compressedSize,4)+o(k.uncompressedSize,4)}(_),meta:{percent:100}});else for(this.push({data:w.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},v.prototype.flush=function(){for(var _=this.bytesWritten,j=0;j=this.index;d--)h=(h<<8)+this.byteAt(d);return this.index+=i,h},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"),h=r("./NodeBufferReader"),f=r("./Uint8ArrayReader");n.exports=function(g){var v=o.getTypeOf(g);return o.checkSupport(v),v!=="string"||l.uint8array?v==="nodebuffer"?new h(g):l.uint8array?new f(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 h=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=h+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 h=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,d.then(function(f){h.dataIsReady=!0,h.data=f,h.max=f&&f.length||0,h.type=o.getTypeOf(f),h.isPaused||h._tickAndRepeat()},function(f){h.error(f)})}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,h=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,h);break;case"uint8array":d=this.data.subarray(this.index,h);break;case"array":case"nodebuffer":d=this.data.slice(this.index,h)}return this.index=h,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"),h=r("../support"),f=r("../external"),g=null;if(h.nodestream)try{g=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function v(j,w){return new f.Promise(function(k,M){var S=[],E=j._internalType,D=j._outputType,L=j._mimeType;j.on("data",function(B,$){S.push(B),w&&w($)}).on("error",function(B){S=[],M(B)}).on("end",function(){try{var B=function($,V,W){switch($){case"blob":return o.newBlob(o.transformTo("arraybuffer",V),W);case"base64":return d.encode(V);default:return o.transformTo($,V)}}(D,function($,V){var W,G=0,J=null,ne=0;for(W=0;W"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"),h=new Array(256),f=0;f<256;f++)h[f]=252<=f?6:248<=f?5:240<=f?4:224<=f?3:192<=f?2:1;h[254]=h[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(j){var w,k,M,S,E,D=j.length,L=0;for(S=0;S>>6:(k<65536?w[E++]=224|k>>>12:(w[E++]=240|k>>>18,w[E++]=128|k>>>12&63),w[E++]=128|k>>>6&63),w[E++]=128|63&k);return w}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(j){var w,k,M,S,E=j.length,D=new Array(2*E);for(w=k=0;w>10&1023,D[k++]=56320|1023&M)}return D.length!==k&&(D.subarray?D=D.subarray(0,k):D.length=k),o.applyFromCharCode(D)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(g,d),g.prototype.processChunk=function(_){var j=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var w=j;(j=new Uint8Array(w.length+this.leftOver.length)).set(this.leftOver,0),j.set(w,this.leftOver.length)}else j=this.leftOver.concat(j);this.leftOver=null}var k=function(S,E){var D;for((E=E||S.length)>S.length&&(E=S.length),D=E-1;0<=D&&(192&S[D])==128;)D--;return D<0||D===0?E:D+h[S[D]]>E?D:E}(j),M=j;k!==j.length&&(l.uint8array?(M=j.subarray(0,k),this.leftOver=j.subarray(k,j.length)):(M=j.slice(0,k),this.leftOver=j.slice(k,j.length))),this.push({data:a.utf8decode(M),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 h(w){return w}function f(w,k){for(var M=0;M>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 j,w,k,M=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?v[k++]=224|_>>>12:(v[k++]=240|_>>>18,v[k++]=128|_>>>12&63),v[k++]=128|_>>>6&63),v[k++]=128|63&_);return v},a.buf2binstring=function(g){return f(g,g.length)},a.binstring2buf=function(g){for(var v=new o.Buf8(g.length),_=0,j=v.length;_>10&1023,S[j++]=56320|1023&w)}return f(S,j)},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 h=65535&o|0,f=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,h){var f=o,g=h+d;l^=-1;for(var v=h;v>>8^f[255&(l^i[v])];return-1^l}},{}],46:[function(r,n,a){var o,l=r("../utils/common"),i=r("./trees"),d=r("./adler32"),h=r("./crc32"),f=r("./messages"),g=0,v=4,_=0,j=-2,w=-1,k=4,M=2,S=8,E=9,D=286,L=30,B=19,$=2*D+1,V=15,W=3,G=258,J=G+W+1,ne=42,ie=113,ee=1,de=2,oe=3,ue=4;function ce(he,We){return he.msg=f[We],We}function ge(he){return(he<<1)-(4he.avail_out&&(et=he.avail_out),et!==0&&(l.arraySet(he.output,We.pending_buf,We.pending_out,et,he.next_out),he.next_out+=et,We.pending_out+=et,he.total_out+=et,he.avail_out-=et,We.pending-=et,We.pending===0&&(We.pending_out=0))}function ye(he,We){i._tr_flush_block(he,0<=he.block_start?he.block_start:-1,he.strstart-he.block_start,We),he.block_start=he.strstart,ve(he.strm)}function Se(he,We){he.pending_buf[he.pending++]=We}function Ke(he,We){he.pending_buf[he.pending++]=We>>>8&255,he.pending_buf[he.pending++]=255&We}function Ae(he,We){var et,Ye,ke=he.max_chain_length,at=he.strstart,Fe=he.prev_length,it=he.nice_match,dt=he.strstart>he.w_size-J?he.strstart-(he.w_size-J):0,tt=he.window,ut=he.w_mask,xt=he.prev,_t=he.strstart+G,qe=tt[at+Fe-1],Lt=tt[at+Fe];he.prev_length>=he.good_match&&(ke>>=2),it>he.lookahead&&(it=he.lookahead);do if(tt[(et=We)+Fe]===Lt&&tt[et+Fe-1]===qe&&tt[et]===tt[at]&&tt[++et]===tt[at+1]){at+=2,et++;do;while(tt[++at]===tt[++et]&&tt[++at]===tt[++et]&&tt[++at]===tt[++et]&&tt[++at]===tt[++et]&&tt[++at]===tt[++et]&&tt[++at]===tt[++et]&&tt[++at]===tt[++et]&&tt[++at]===tt[++et]&&at<_t);if(Ye=G-(_t-at),at=_t-G,Fedt&&--ke!=0);return Fe<=he.lookahead?Fe:he.lookahead}function Ee(he){var We,et,Ye,ke,at,Fe,it,dt,tt,ut,xt=he.w_size;do{if(ke=he.window_size-he.lookahead-he.strstart,he.strstart>=xt+(xt-J)){for(l.arraySet(he.window,he.window,xt,xt,0),he.match_start-=xt,he.strstart-=xt,he.block_start-=xt,We=et=he.hash_size;Ye=he.head[--We],he.head[We]=xt<=Ye?Ye-xt:0,--et;);for(We=et=xt;Ye=he.prev[--We],he.prev[We]=xt<=Ye?Ye-xt:0,--et;);ke+=xt}if(he.strm.avail_in===0)break;if(Fe=he.strm,it=he.window,dt=he.strstart+he.lookahead,tt=ke,ut=void 0,ut=Fe.avail_in,tt=W)for(at=he.strstart-he.insert,he.ins_h=he.window[at],he.ins_h=(he.ins_h<=W&&(he.ins_h=(he.ins_h<=W)if(Ye=i._tr_tally(he,he.strstart-he.match_start,he.match_length-W),he.lookahead-=he.match_length,he.match_length<=he.max_lazy_match&&he.lookahead>=W){for(he.match_length--;he.strstart++,he.ins_h=(he.ins_h<=W&&(he.ins_h=(he.ins_h<=W&&he.match_length<=he.prev_length){for(ke=he.strstart+he.lookahead-W,Ye=i._tr_tally(he,he.strstart-1-he.prev_match,he.prev_length-W),he.lookahead-=he.prev_length-1,he.prev_length-=2;++he.strstart<=ke&&(he.ins_h=(he.ins_h<he.pending_buf_size-5&&(et=he.pending_buf_size-5);;){if(he.lookahead<=1){if(Ee(he),he.lookahead===0&&We===g)return ee;if(he.lookahead===0)break}he.strstart+=he.lookahead,he.lookahead=0;var Ye=he.block_start+et;if((he.strstart===0||he.strstart>=Ye)&&(he.lookahead=he.strstart-Ye,he.strstart=Ye,ye(he,!1),he.strm.avail_out===0)||he.strstart-he.block_start>=he.w_size-J&&(ye(he,!1),he.strm.avail_out===0))return ee}return he.insert=0,We===v?(ye(he,!0),he.strm.avail_out===0?oe:ue):(he.strstart>he.block_start&&(ye(he,!1),he.strm.avail_out),ee)}),new De(4,4,8,4,He),new De(4,5,16,8,He),new De(4,6,32,32,He),new De(4,4,16,16,Ue),new De(8,16,32,32,Ue),new De(8,16,128,128,Ue),new De(8,32,128,256,Ue),new De(32,128,258,1024,Ue),new De(32,258,258,4096,Ue)],a.deflateInit=function(he,We){return st(he,We,S,15,8,0)},a.deflateInit2=st,a.deflateReset=Ie,a.deflateResetKeep=wt,a.deflateSetHeader=function(he,We){return he&&he.state?he.state.wrap!==2?j:(he.state.gzhead=We,_):j},a.deflate=function(he,We){var et,Ye,ke,at;if(!he||!he.state||5>8&255),Se(Ye,Ye.gzhead.time>>16&255),Se(Ye,Ye.gzhead.time>>24&255),Se(Ye,Ye.level===9?2:2<=Ye.strategy||Ye.level<2?4:0),Se(Ye,255&Ye.gzhead.os),Ye.gzhead.extra&&Ye.gzhead.extra.length&&(Se(Ye,255&Ye.gzhead.extra.length),Se(Ye,Ye.gzhead.extra.length>>8&255)),Ye.gzhead.hcrc&&(he.adler=h(he.adler,Ye.pending_buf,Ye.pending,0)),Ye.gzindex=0,Ye.status=69):(Se(Ye,0),Se(Ye,0),Se(Ye,0),Se(Ye,0),Se(Ye,0),Se(Ye,Ye.level===9?2:2<=Ye.strategy||Ye.level<2?4:0),Se(Ye,3),Ye.status=ie);else{var Fe=S+(Ye.w_bits-8<<4)<<8;Fe|=(2<=Ye.strategy||Ye.level<2?0:Ye.level<6?1:Ye.level===6?2:3)<<6,Ye.strstart!==0&&(Fe|=32),Fe+=31-Fe%31,Ye.status=ie,Ke(Ye,Fe),Ye.strstart!==0&&(Ke(Ye,he.adler>>>16),Ke(Ye,65535&he.adler)),he.adler=1}if(Ye.status===69)if(Ye.gzhead.extra){for(ke=Ye.pending;Ye.gzindex<(65535&Ye.gzhead.extra.length)&&(Ye.pending!==Ye.pending_buf_size||(Ye.gzhead.hcrc&&Ye.pending>ke&&(he.adler=h(he.adler,Ye.pending_buf,Ye.pending-ke,ke)),ve(he),ke=Ye.pending,Ye.pending!==Ye.pending_buf_size));)Se(Ye,255&Ye.gzhead.extra[Ye.gzindex]),Ye.gzindex++;Ye.gzhead.hcrc&&Ye.pending>ke&&(he.adler=h(he.adler,Ye.pending_buf,Ye.pending-ke,ke)),Ye.gzindex===Ye.gzhead.extra.length&&(Ye.gzindex=0,Ye.status=73)}else Ye.status=73;if(Ye.status===73)if(Ye.gzhead.name){ke=Ye.pending;do{if(Ye.pending===Ye.pending_buf_size&&(Ye.gzhead.hcrc&&Ye.pending>ke&&(he.adler=h(he.adler,Ye.pending_buf,Ye.pending-ke,ke)),ve(he),ke=Ye.pending,Ye.pending===Ye.pending_buf_size)){at=1;break}at=Ye.gzindexke&&(he.adler=h(he.adler,Ye.pending_buf,Ye.pending-ke,ke)),at===0&&(Ye.gzindex=0,Ye.status=91)}else Ye.status=91;if(Ye.status===91)if(Ye.gzhead.comment){ke=Ye.pending;do{if(Ye.pending===Ye.pending_buf_size&&(Ye.gzhead.hcrc&&Ye.pending>ke&&(he.adler=h(he.adler,Ye.pending_buf,Ye.pending-ke,ke)),ve(he),ke=Ye.pending,Ye.pending===Ye.pending_buf_size)){at=1;break}at=Ye.gzindexke&&(he.adler=h(he.adler,Ye.pending_buf,Ye.pending-ke,ke)),at===0&&(Ye.status=103)}else Ye.status=103;if(Ye.status===103&&(Ye.gzhead.hcrc?(Ye.pending+2>Ye.pending_buf_size&&ve(he),Ye.pending+2<=Ye.pending_buf_size&&(Se(Ye,255&he.adler),Se(Ye,he.adler>>8&255),he.adler=0,Ye.status=ie)):Ye.status=ie),Ye.pending!==0){if(ve(he),he.avail_out===0)return Ye.last_flush=-1,_}else if(he.avail_in===0&&ge(We)<=ge(et)&&We!==v)return ce(he,-5);if(Ye.status===666&&he.avail_in!==0)return ce(he,-5);if(he.avail_in!==0||Ye.lookahead!==0||We!==g&&Ye.status!==666){var it=Ye.strategy===2?function(dt,tt){for(var ut;;){if(dt.lookahead===0&&(Ee(dt),dt.lookahead===0)){if(tt===g)return ee;break}if(dt.match_length=0,ut=i._tr_tally(dt,0,dt.window[dt.strstart]),dt.lookahead--,dt.strstart++,ut&&(ye(dt,!1),dt.strm.avail_out===0))return ee}return dt.insert=0,tt===v?(ye(dt,!0),dt.strm.avail_out===0?oe:ue):dt.last_lit&&(ye(dt,!1),dt.strm.avail_out===0)?ee:de}(Ye,We):Ye.strategy===3?function(dt,tt){for(var ut,xt,_t,qe,Lt=dt.window;;){if(dt.lookahead<=G){if(Ee(dt),dt.lookahead<=G&&tt===g)return ee;if(dt.lookahead===0)break}if(dt.match_length=0,dt.lookahead>=W&&0dt.lookahead&&(dt.match_length=dt.lookahead)}if(dt.match_length>=W?(ut=i._tr_tally(dt,1,dt.match_length-W),dt.lookahead-=dt.match_length,dt.strstart+=dt.match_length,dt.match_length=0):(ut=i._tr_tally(dt,0,dt.window[dt.strstart]),dt.lookahead--,dt.strstart++),ut&&(ye(dt,!1),dt.strm.avail_out===0))return ee}return dt.insert=0,tt===v?(ye(dt,!0),dt.strm.avail_out===0?oe:ue):dt.last_lit&&(ye(dt,!1),dt.strm.avail_out===0)?ee:de}(Ye,We):o[Ye.level].func(Ye,We);if(it!==oe&&it!==ue||(Ye.status=666),it===ee||it===oe)return he.avail_out===0&&(Ye.last_flush=-1),_;if(it===de&&(We===1?i._tr_align(Ye):We!==5&&(i._tr_stored_block(Ye,0,0,!1),We===3&&(Te(Ye.head),Ye.lookahead===0&&(Ye.strstart=0,Ye.block_start=0,Ye.insert=0))),ve(he),he.avail_out===0))return Ye.last_flush=-1,_}return We!==v?_:Ye.wrap<=0?1:(Ye.wrap===2?(Se(Ye,255&he.adler),Se(Ye,he.adler>>8&255),Se(Ye,he.adler>>16&255),Se(Ye,he.adler>>24&255),Se(Ye,255&he.total_in),Se(Ye,he.total_in>>8&255),Se(Ye,he.total_in>>16&255),Se(Ye,he.total_in>>24&255)):(Ke(Ye,he.adler>>>16),Ke(Ye,65535&he.adler)),ve(he),0=et.w_size&&(at===0&&(Te(et.head),et.strstart=0,et.block_start=0,et.insert=0),tt=new l.Buf8(et.w_size),l.arraySet(tt,We,ut-et.w_size,et.w_size,0),We=tt,ut=et.w_size),Fe=he.avail_in,it=he.next_in,dt=he.input,he.avail_in=ut,he.next_in=0,he.input=We,Ee(et);et.lookahead>=W;){for(Ye=et.strstart,ke=et.lookahead-(W-1);et.ins_h=(et.ins_h<>>=W=V>>>24,E-=W,(W=V>>>16&255)===0)de[f++]=65535&V;else{if(!(16&W)){if(!(64&W)){V=D[(65535&V)+(S&(1<>>=W,E-=W),E<15&&(S+=ee[d++]<>>=W=V>>>24,E-=W,!(16&(W=V>>>16&255))){if(!(64&W)){V=L[(65535&V)+(S&(1<>>=W,E-=W,(W=f-g)>3,S&=(1<<(E-=G<<3))-1,o.next_in=d,o.next_out=f,o.avail_in=d>>24&255)+(ne>>>8&65280)+((65280&ne)<<8)+((255&ne)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function E(ne){var ie;return ne&&ne.state?(ie=ne.state,ne.total_in=ne.total_out=ie.total=0,ne.msg="",ie.wrap&&(ne.adler=1&ie.wrap),ie.mode=j,ie.last=0,ie.havedict=0,ie.dmax=32768,ie.head=null,ie.hold=0,ie.bits=0,ie.lencode=ie.lendyn=new o.Buf32(w),ie.distcode=ie.distdyn=new o.Buf32(k),ie.sane=1,ie.back=-1,v):_}function D(ne){var ie;return ne&&ne.state?((ie=ne.state).wsize=0,ie.whave=0,ie.wnext=0,E(ne)):_}function L(ne,ie){var ee,de;return ne&&ne.state?(de=ne.state,ie<0?(ee=0,ie=-ie):(ee=1+(ie>>4),ie<48&&(ie&=15)),ie&&(ie<8||15=ue.wsize?(o.arraySet(ue.window,ie,ee-ue.wsize,ue.wsize,0),ue.wnext=0,ue.whave=ue.wsize):(de<(oe=ue.wsize-ue.wnext)&&(oe=de),o.arraySet(ue.window,ie,ee-de,oe,ue.wnext),(de-=oe)?(o.arraySet(ue.window,ie,ee-de,de,0),ue.wnext=de,ue.whave=ue.wsize):(ue.wnext+=oe,ue.wnext===ue.wsize&&(ue.wnext=0),ue.whave>>8&255,ee.check=i(ee.check,at,2,0),ye=ve=0,ee.mode=2;break}if(ee.flags=0,ee.head&&(ee.head.done=!1),!(1&ee.wrap)||(((255&ve)<<8)+(ve>>8))%31){ne.msg="incorrect header check",ee.mode=30;break}if((15&ve)!=8){ne.msg="unknown compression method",ee.mode=30;break}if(ye-=4,he=8+(15&(ve>>>=4)),ee.wbits===0)ee.wbits=he;else if(he>ee.wbits){ne.msg="invalid window size",ee.mode=30;break}ee.dmax=1<>8&1),512&ee.flags&&(at[0]=255&ve,at[1]=ve>>>8&255,ee.check=i(ee.check,at,2,0)),ye=ve=0,ee.mode=3;case 3:for(;ye<32;){if(ge===0)break e;ge--,ve+=de[ue++]<>>8&255,at[2]=ve>>>16&255,at[3]=ve>>>24&255,ee.check=i(ee.check,at,4,0)),ye=ve=0,ee.mode=4;case 4:for(;ye<16;){if(ge===0)break e;ge--,ve+=de[ue++]<>8),512&ee.flags&&(at[0]=255&ve,at[1]=ve>>>8&255,ee.check=i(ee.check,at,2,0)),ye=ve=0,ee.mode=5;case 5:if(1024&ee.flags){for(;ye<16;){if(ge===0)break e;ge--,ve+=de[ue++]<>>8&255,ee.check=i(ee.check,at,2,0)),ye=ve=0}else ee.head&&(ee.head.extra=null);ee.mode=6;case 6:if(1024&ee.flags&&(ge<(Ae=ee.length)&&(Ae=ge),Ae&&(ee.head&&(he=ee.head.extra_len-ee.length,ee.head.extra||(ee.head.extra=new Array(ee.head.extra_len)),o.arraySet(ee.head.extra,de,ue,Ae,he)),512&ee.flags&&(ee.check=i(ee.check,de,Ae,ue)),ge-=Ae,ue+=Ae,ee.length-=Ae),ee.length))break e;ee.length=0,ee.mode=7;case 7:if(2048&ee.flags){if(ge===0)break e;for(Ae=0;he=de[ue+Ae++],ee.head&&he&&ee.length<65536&&(ee.head.name+=String.fromCharCode(he)),he&&Ae>9&1,ee.head.done=!0),ne.adler=ee.check=0,ee.mode=12;break;case 10:for(;ye<32;){if(ge===0)break e;ge--,ve+=de[ue++]<>>=7&ye,ye-=7&ye,ee.mode=27;break}for(;ye<3;){if(ge===0)break e;ge--,ve+=de[ue++]<>>=1)){case 0:ee.mode=14;break;case 1:if(G(ee),ee.mode=20,ie!==6)break;ve>>>=2,ye-=2;break e;case 2:ee.mode=17;break;case 3:ne.msg="invalid block type",ee.mode=30}ve>>>=2,ye-=2;break;case 14:for(ve>>>=7&ye,ye-=7&ye;ye<32;){if(ge===0)break e;ge--,ve+=de[ue++]<>>16^65535)){ne.msg="invalid stored block lengths",ee.mode=30;break}if(ee.length=65535&ve,ye=ve=0,ee.mode=15,ie===6)break e;case 15:ee.mode=16;case 16:if(Ae=ee.length){if(ge>>=5,ye-=5,ee.ndist=1+(31&ve),ve>>>=5,ye-=5,ee.ncode=4+(15&ve),ve>>>=4,ye-=4,286>>=3,ye-=3}for(;ee.have<19;)ee.lens[Fe[ee.have++]]=0;if(ee.lencode=ee.lendyn,ee.lenbits=7,et={bits:ee.lenbits},We=h(0,ee.lens,0,19,ee.lencode,0,ee.work,et),ee.lenbits=et.bits,We){ne.msg="invalid code lengths set",ee.mode=30;break}ee.have=0,ee.mode=19;case 19:for(;ee.have>>16&255,Ge=65535&ke,!((Ue=ke>>>24)<=ye);){if(ge===0)break e;ge--,ve+=de[ue++]<>>=Ue,ye-=Ue,ee.lens[ee.have++]=Ge;else{if(Ge===16){for(Ye=Ue+2;ye>>=Ue,ye-=Ue,ee.have===0){ne.msg="invalid bit length repeat",ee.mode=30;break}he=ee.lens[ee.have-1],Ae=3+(3&ve),ve>>>=2,ye-=2}else if(Ge===17){for(Ye=Ue+3;ye>>=Ue)),ve>>>=3,ye-=3}else{for(Ye=Ue+7;ye>>=Ue)),ve>>>=7,ye-=7}if(ee.have+Ae>ee.nlen+ee.ndist){ne.msg="invalid bit length repeat",ee.mode=30;break}for(;Ae--;)ee.lens[ee.have++]=he}}if(ee.mode===30)break;if(ee.lens[256]===0){ne.msg="invalid code -- missing end-of-block",ee.mode=30;break}if(ee.lenbits=9,et={bits:ee.lenbits},We=h(f,ee.lens,0,ee.nlen,ee.lencode,0,ee.work,et),ee.lenbits=et.bits,We){ne.msg="invalid literal/lengths set",ee.mode=30;break}if(ee.distbits=6,ee.distcode=ee.distdyn,et={bits:ee.distbits},We=h(g,ee.lens,ee.nlen,ee.ndist,ee.distcode,0,ee.work,et),ee.distbits=et.bits,We){ne.msg="invalid distances set",ee.mode=30;break}if(ee.mode=20,ie===6)break e;case 20:ee.mode=21;case 21:if(6<=ge&&258<=Te){ne.next_out=ce,ne.avail_out=Te,ne.next_in=ue,ne.avail_in=ge,ee.hold=ve,ee.bits=ye,d(ne,Ke),ce=ne.next_out,oe=ne.output,Te=ne.avail_out,ue=ne.next_in,de=ne.input,ge=ne.avail_in,ve=ee.hold,ye=ee.bits,ee.mode===12&&(ee.back=-1);break}for(ee.back=0;De=(ke=ee.lencode[ve&(1<>>16&255,Ge=65535&ke,!((Ue=ke>>>24)<=ye);){if(ge===0)break e;ge--,ve+=de[ue++]<>wt)])>>>16&255,Ge=65535&ke,!(wt+(Ue=ke>>>24)<=ye);){if(ge===0)break e;ge--,ve+=de[ue++]<>>=wt,ye-=wt,ee.back+=wt}if(ve>>>=Ue,ye-=Ue,ee.back+=Ue,ee.length=Ge,De===0){ee.mode=26;break}if(32&De){ee.back=-1,ee.mode=12;break}if(64&De){ne.msg="invalid literal/length code",ee.mode=30;break}ee.extra=15&De,ee.mode=22;case 22:if(ee.extra){for(Ye=ee.extra;ye>>=ee.extra,ye-=ee.extra,ee.back+=ee.extra}ee.was=ee.length,ee.mode=23;case 23:for(;De=(ke=ee.distcode[ve&(1<>>16&255,Ge=65535&ke,!((Ue=ke>>>24)<=ye);){if(ge===0)break e;ge--,ve+=de[ue++]<>wt)])>>>16&255,Ge=65535&ke,!(wt+(Ue=ke>>>24)<=ye);){if(ge===0)break e;ge--,ve+=de[ue++]<>>=wt,ye-=wt,ee.back+=wt}if(ve>>>=Ue,ye-=Ue,ee.back+=Ue,64&De){ne.msg="invalid distance code",ee.mode=30;break}ee.offset=Ge,ee.extra=15&De,ee.mode=24;case 24:if(ee.extra){for(Ye=ee.extra;ye>>=ee.extra,ye-=ee.extra,ee.back+=ee.extra}if(ee.offset>ee.dmax){ne.msg="invalid distance too far back",ee.mode=30;break}ee.mode=25;case 25:if(Te===0)break e;if(Ae=Ke-Te,ee.offset>Ae){if((Ae=ee.offset-Ae)>ee.whave&&ee.sane){ne.msg="invalid distance too far back",ee.mode=30;break}Ee=Ae>ee.wnext?(Ae-=ee.wnext,ee.wsize-Ae):ee.wnext-Ae,Ae>ee.length&&(Ae=ee.length),He=ee.window}else He=oe,Ee=ce-ee.offset,Ae=ee.length;for(Te$?(W=Ee[He+k[ie]],ye[Se+k[ie]]):(W=96,0),S=1<>ce)+(E-=S)]=V<<24|W<<16|G|0,E!==0;);for(S=1<>=1;if(S!==0?(ve&=S-1,ve+=S):ve=0,ie++,--Ke[ne]==0){if(ne===de)break;ne=g[v+k[ie]]}if(oe>>7)]}function Se(ke,at){ke.pending_buf[ke.pending++]=255&at,ke.pending_buf[ke.pending++]=at>>>8&255}function Ke(ke,at,Fe){ke.bi_valid>M-Fe?(ke.bi_buf|=at<>M-ke.bi_valid,ke.bi_valid+=Fe-M):(ke.bi_buf|=at<>>=1,Fe<<=1,0<--at;);return Fe>>>1}function He(ke,at,Fe){var it,dt,tt=new Array(k+1),ut=0;for(it=1;it<=k;it++)tt[it]=ut=ut+Fe[it-1]<<1;for(dt=0;dt<=at;dt++){var xt=ke[2*dt+1];xt!==0&&(ke[2*dt]=Ee(tt[xt]++,xt))}}function Ue(ke){var at;for(at=0;at>1;1<=Fe;Fe--)wt(ke,tt,Fe);for(dt=_t;Fe=ke.heap[1],ke.heap[1]=ke.heap[ke.heap_len--],wt(ke,tt,1),it=ke.heap[1],ke.heap[--ke.heap_max]=Fe,ke.heap[--ke.heap_max]=it,tt[2*dt]=tt[2*Fe]+tt[2*it],ke.depth[dt]=(ke.depth[Fe]>=ke.depth[it]?ke.depth[Fe]:ke.depth[it])+1,tt[2*Fe+1]=tt[2*it+1]=dt,ke.heap[1]=dt++,wt(ke,tt,1),2<=ke.heap_len;);ke.heap[--ke.heap_max]=ke.heap[1],function(Lt,Rt){var Kt,Xt,ss,fs,fr,yt,bs=Rt.dyn_tree,gr=Rt.max_code,Br=Rt.stat_desc.static_tree,na=Rt.stat_desc.has_stree,za=Rt.stat_desc.extra_bits,go=Rt.stat_desc.extra_base,Ia=Rt.stat_desc.max_length,nn=0;for(fs=0;fs<=k;fs++)Lt.bl_count[fs]=0;for(bs[2*Lt.heap[Lt.heap_max]+1]=0,Kt=Lt.heap_max+1;Kt>=7;dt<_;dt++)for(ge[dt]=tt<<7,at=0;at<1<>>=1)if(1&qe&&xt.dyn_ltree[2*_t]!==0)return l;if(xt.dyn_ltree[18]!==0||xt.dyn_ltree[20]!==0||xt.dyn_ltree[26]!==0)return i;for(_t=32;_t>>3,(tt=ke.static_len+3+7>>>3)<=dt&&(dt=tt)):dt=tt=Fe+5,Fe+4<=dt&&at!==-1?Ye(ke,at,Fe,it):ke.strategy===4||tt===dt?(Ke(ke,2+(it?1:0),3),Ie(ke,J,ne)):(Ke(ke,4+(it?1:0),3),function(xt,_t,qe,Lt){var Rt;for(Ke(xt,_t-257,5),Ke(xt,qe-1,5),Ke(xt,Lt-4,4),Rt=0;Rt>>8&255,ke.pending_buf[ke.d_buf+2*ke.last_lit+1]=255&at,ke.pending_buf[ke.l_buf+ke.last_lit]=255&Fe,ke.last_lit++,at===0?ke.dyn_ltree[2*Fe]++:(ke.matches++,at--,ke.dyn_ltree[2*(ee[Fe]+g+1)]++,ke.dyn_dtree[2*ye(at)]++),ke.last_lit===ke.lit_bufsize-1},a._tr_align=function(ke){Ke(ke,2,3),Ae(ke,E,J),function(at){at.bi_valid===16?(Se(at,at.bi_buf),at.bi_buf=0,at.bi_valid=0):8<=at.bi_valid&&(at.pending_buf[at.pending++]=255&at.bi_buf,at.bi_buf>>=8,at.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,h,f,g,v=1,_={},j=!1,w=l.document,k=Object.getPrototypeOf&&Object.getPrototypeOf(l);k=k&&k.setTimeout?k:l,d={}.toString.call(l.process)==="[object process]"?function(D){process.nextTick(function(){S(D)})}:function(){if(l.postMessage&&!l.importScripts){var D=!0,L=l.onmessage;return l.onmessage=function(){D=!1},l.postMessage("","*"),l.onmessage=L,D}}()?(g="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",E,!1):l.attachEvent("onmessage",E),function(D){l.postMessage(g+D,"*")}):l.MessageChannel?((f=new MessageChannel).port1.onmessage=function(D){S(D.data)},function(D){f.port2.postMessage(D)}):w&&"onreadystatechange"in w.createElement("script")?(h=w.documentElement,function(D){var L=w.createElement("script");L.onreadystatechange=function(){S(D),L.onreadystatechange=null,h.removeChild(L),L=null},h.appendChild(L)}):function(D){setTimeout(S,0,D)},k.setImmediate=function(D){typeof D!="function"&&(D=new Function(""+D));for(var L=new Array(arguments.length-1),B=0;B"u"?o===void 0?this:o:self)}).call(this,typeof By<"u"?By:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(FVe);var hAt=FVe.exports;const mAt=fo(hAt);function Dhe(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 pAt=()=>{const{isAdmin:t}=Ys(),[s,r]=T.useState(null),[n,a]=T.useState(null),[o,l]=T.useState("all"),[i,d]=T.useState(new Set),[h,f]=T.useState(!1),[g,v]=T.useState(!1),[_,j]=T.useState("images"),[w,k]=T.useState(null),{data:M=[],isLoading:S}=zt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:ge,error:Te}=await Z.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(Te)throw Te;return ge}}),{data:E=[]}=zt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:ge,error:Te}=await Z.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(Te)throw Te;return ge}}),{data:D=[]}=zt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:ge,error:Te}=await Z.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(Te)throw Te;return ge}}),{data:L=[]}=zt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:ge,error:Te}=await Z.from("social_accounts").select("id, platform").eq("is_active",!0);if(Te)throw Te;return ge||[]}}),B=L.length>0,$=T.useMemo(()=>o==="all"?null:D.find(ge=>ge.month===o)||null,[o,D]),V=T.useMemo(()=>[...new Set(M.map(Te=>Te.month))].sort((Te,ve)=>ve.localeCompare(Te)),[M]);T.useEffect(()=>{V.length>0&&o==="all"&&l(V[0])},[V,o]);const W=ge=>{try{const Te=r1e(ge,"yyyy-MM",new Date);return Bs(Te,"MMMM yyyy")}catch{return ge}},G=T.useMemo(()=>o==="all"?M:M.filter(ge=>ge.month===o),[o,M]),J=T.useMemo(()=>{var ge;return o==="all"?null:((ge=E.find(Te=>Te.month===o))==null?void 0:ge.canva_link)||null},[o,E]),ne=async ge=>{try{await navigator.clipboard.writeText(ge),be.success("Caption copied to clipboard!")}catch{be.error("Failed to copy caption")}},ie=async(ge,Te)=>{try{const ye=await(await fetch(ge)).blob(),Se=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ke=navigator.canShare&&navigator.canShare({files:[new File([ye],"test.jpg",{type:"image/jpeg"})]});if(Se&&Ke){const Ae=new File([ye],`social-swag-${Te}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Ae],title:"Social Swag Image"}),be.success("Image ready to save!")}else{const Ae=window.URL.createObjectURL(ye),Ee=document.createElement("a");Ee.href=Ae,Ee.download=`social-swag-${Te}.jpg`,document.body.appendChild(Ee),Ee.click(),document.body.removeChild(Ee),window.URL.revokeObjectURL(Ae),be.success("Image downloaded!")}}catch(ve){ve.name!=="AbortError"&&be.error("Failed to download image")}},ee=ge=>{d(Te=>{const ve=new Set(Te);return ve.has(ge)?ve.delete(ge):ve.add(ge),ve})},de=()=>{d(new Set(G.map(ge=>ge.id)))},oe=()=>{d(new Set),f(!1)},ue=async()=>{const ge=G.filter(Te=>i.has(Te.id));if(ge.length===0){be.error("No images selected");return}v(!0),be.info(`Preparing ${ge.length} images for download...`);try{const Te=new mAt,ve=[...ge].sort((Ee,He)=>Ee.sort_order-He.sort_order);for(let Ee=0;Ee{h?ee(ge.id):r(ge)};return e.jsx(Vs,{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(ct,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Sn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(ct,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(fl,{className:"h-3 w-3 mr-1"}),M.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(Qa,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(Ga,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(Fs,{value:"gallery",className:"gap-2",children:[e.jsx(fl,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(Fs,{value:"scheduled",className:"gap-2",children:[e.jsx(Km,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(Zs,{value:"gallery",className:"space-y-6",children:[t?B?e.jsx(Oe,{className:"border rounded-xl",children:e.jsx($e,{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(Y,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(bo,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Oe,{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($e,{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(Qd,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(vu,{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(Y,{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(bo,{to:"/social-connections",children:[e.jsx(Jm,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Oe,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx($e,{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(ca,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Qd,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(vu,{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(ct,{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:V.map(ge=>e.jsx("button",{onClick:()=>l(ge),className:$t("px-4 py-2 rounded-full text-sm font-medium transition-all",o===ge?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:W(ge)},ge))}),o!=="all"&&(J?e.jsxs("a",{href:J,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 ",W(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 ",W(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:()=>{j("images"),oe()},className:$t("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(fl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{j("reels"),oe()},className:$t("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(Wd,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:h?e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"outline",size:"sm",onClick:de,className:"gap-2",children:["Select All (",G.length,")"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:oe,className:"gap-2",children:[e.jsx(Xr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Y,{size:"sm",onClick:ue,disabled:g,className:"gap-2",children:[e.jsx(Vi,{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(Y,{variant:"outline",size:"sm",onClick:()=>f(!0),className:"gap-2",children:[e.jsx(ma,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:G.map(ge=>{const Te=i.has(ge.id);return e.jsx(Oe,{className:$t("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",h&&Te&&"ring-2 ring-primary ring-offset-2"),onClick:()=>ce(ge),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Dhe(ge.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"}),ge.post_date&&!h&&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:Bs(new Date(ge.post_date+"T00:00:00"),"MMM d")})}),h&&e.jsx("div",{className:$t("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",Te?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:Te&&e.jsx(ma,{className:"h-4 w-4"})}),!h&&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"})})]})},ge.id)})}),G.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(fl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Oe,{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:Dhe($.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(ct,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(Wd,{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(Wd,{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(js,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(_s,{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:Dhe(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(xn,{className:"h-4 w-4"}),Bs(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(xn,{className:"h-3.5 w-3.5"}),"Post on ",Bs(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(Y,{onClick:()=>{k({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(Wa,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Y,{variant:"outline",onClick:()=>ne(s.caption),className:"flex-1 gap-2",children:[e.jsx(Di,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(Y,{variant:"outline",onClick:()=>ie(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Vi,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(js,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(_s,{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(Wd,{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(Y,{onClick:()=>ne(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Di,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(Y,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(bn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(dAt,{open:!!w,onOpenChange:ge=>!ge&&k(null),imageUrl:(w==null?void 0:w.imageUrl)||"",imageId:(w==null?void 0:w.imageId)||"",defaultCaption:(w==null?void 0:w.caption)||"",swagItemId:w==null?void 0:w.imageId})]}),e.jsx(Zs,{value:"scheduled",children:e.jsx(uAt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Oe,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx($e,{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(ca,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Qd,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(vu,{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(ct,{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:V.map(ge=>e.jsx("button",{onClick:()=>l(ge),className:$t("px-4 py-2 rounded-full text-sm font-medium transition-all",o===ge?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:W(ge)},ge))}),o!=="all"&&(J?e.jsxs("a",{href:J,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 ",W(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 ",W(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:()=>{j("images"),oe()},className:$t("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(fl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{j("reels"),oe()},className:$t("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(Wd,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:h?e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"outline",size:"sm",onClick:de,className:"gap-2",children:["Select All (",G.length,")"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:oe,className:"gap-2",children:[e.jsx(Xr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(Y,{size:"sm",onClick:ue,disabled:g,className:"gap-2",children:[e.jsx(Vi,{className:"h-4 w-4"}),g?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>f(!0),className:"gap-2",children:[e.jsx(ma,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:G.map(ge=>{const Te=i.has(ge.id);return e.jsx(Oe,{className:$t("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",h&&Te&&"ring-2 ring-primary ring-offset-2"),onClick:()=>ce(ge),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:ge.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),h&&e.jsx("div",{className:$t("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",Te?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:Te&&e.jsx(ma,{className:"h-4 w-4"})}),!h&&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"})})]})},ge.id)})}),G.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(fl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Oe,{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(ct,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(Wd,{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(Wd,{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(js,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(_s,{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(xn,{className:"h-4 w-4"}),Bs(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(Y,{variant:"outline",onClick:()=>ne(s.caption),className:"flex-1 gap-2",children:[e.jsx(Di,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(Y,{variant:"outline",onClick:()=>ie(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Vi,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(js,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(_s,{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(Wd,{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(Y,{onClick:()=>ne(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Di,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(Y,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(bn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},fAt=()=>{const{swagId:t}=wl(),{user:s}=Ys(),{toast:r}=Sa(),n=vs(),{trackEngagement:a}=G6(),[o,l]=T.useState(""),{data:i,isLoading:d}=zt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:M,error:S}=await Z.from("social_swag").select("*").eq("id",t).single();if(S)throw S;const{data:E}=await Z.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...M,links:E||[]}},enabled:!!t});T.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:h=[]}=zt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:M,error:S}=await Z.from("social_swag_likes").select("*").eq("swag_id",t);if(S)throw S;return M},enabled:!!t}),{data:f=[]}=zt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:M,error:S}=await Z.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(S)throw S;const E=[...new Set(M.map(B=>B.user_id))],{data:D}=await Z.from("profiles").select("id, name").in("id",E),L=new Map((D==null?void 0:D.map(B=>[B.id,B.name]))||[]);return M.map(B=>({...B,user_name:L.get(B.user_id)||"Unknown User"}))},enabled:!!t}),g=Wt({mutationFn:async M=>{const{error:S}=await Z.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:M});if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:M=>{r({title:"Error adding comment",description:M.message,variant:"destructive"})}}),v=Wt({mutationFn:async M=>{const{error:S}=await Z.from("social_swag_comments").delete().eq("id",M);if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Wt({mutationFn:async()=>{const M=h.find(S=>S.user_id===(s==null?void 0:s.id));if(M){const{error:S}=await Z.from("social_swag_likes").delete().eq("id",M.id);if(S)throw S}else{const{error:S}=await Z.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(S)throw S}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),j=h.some(M=>M.user_id===(s==null?void 0:s.id)),w=M=>M.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),k=M=>{M.preventDefault(),!(!o.trim()||!s)&&g.mutate(o.trim())};return d?e.jsx(Vs,{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(Vs,{title:i.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Y,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(bo,{to:"/social-swag",children:[e.jsx(bi,{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(G3,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(Y,{variant:j?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(Ed,{className:`h-4 w-4 ${j?"fill-current":""}`}),h.length," ",h.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(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Ro,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(M=>e.jsxs(Y,{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(M.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:M.title}),e.jsx(bn,{className:"h-4 w-4 text-muted-foreground"})]},M.id))})]})}),e.jsx(ud,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Gl,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:k,className:"flex gap-2",children:[e.jsx(Rr,{placeholder:"Add a comment...",value:o,onChange:M=>l(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(Y,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||g.isPending,children:e.jsx(Wa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Oe,{children:e.jsx($e,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(M=>e.jsx(Oe,{children:e.jsx($e,{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(M.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:M.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_u(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>v.mutate(M.id),children:e.jsx(Ir,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:M.content})]})]})})},M.id))})]})]})}):e.jsx(Vs,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ro,{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(Y,{asChild:!0,className:"mt-4",children:e.jsx(bo,{to:"/social-swag",children:"Back to Social Swag"})})]})})},gAt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=T.useState(!0),[i,d]=T.useState(!0),[h,f]=T.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(Y,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(E4,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(Dk,{open:o,onOpenChange:l,children:[e.jsx(Ok,{asChild:!0,children:e.jsxs(Y,{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(Gc,{className:"h-4 w-4"}):e.jsx(Ri,{className:"h-4 w-4"})]})}),e.jsx(Rk,{className:"space-y-1 pl-2",children:t.map(v=>e.jsxs(Y,{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(Dk,{open:i,onOpenChange:d,children:[e.jsx(Ok,{asChild:!0,children:e.jsxs(Y,{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(zu,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Gc,{className:"h-4 w-4"}):e.jsx(Ri,{className:"h-4 w-4"})]})}),e.jsx(Rk,{className:"space-y-1 pl-2",children:s.map(v=>e.jsxs(Y,{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(Dk,{open:h,onOpenChange:f,children:[e.jsx(Ok,{asChild:!0,children:e.jsxs(Y,{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(br,{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})]}),h?e.jsx(Gc,{className:"h-4 w-4"}):e.jsx(Ri,{className:"h-4 w-4"})]})}),e.jsx(Rk,{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(_a,{src:v.avatarUrl}),e.jsx(gn,{className:"text-xs",children:g(v.name)})]}),e.jsx(Td,{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))})]})]})})})},xAt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=T.useState(!1),i=h=>h.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),d=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const f=r.replace("group:",""),g=s.find(v=>v.id===f);return g?`🔒 ${g.name}`:"Private Group"}const h=t.find(f=>f.id===r);return h?`${h.icon||"📂"} ${h.name}`:"Category"};return e.jsxs("div",{className:"lg:hidden flex items-center gap-2 mb-4",children:[e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:d()}),e.jsx(Gc,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(ju,{className:"w-56 bg-background border",children:[e.jsxs(Va,{onClick:()=>n("all"),children:[e.jsx(E4,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(eN,{}),e.jsx(Afe,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(h=>e.jsxs(Va,{onClick:()=>n(h.id),children:[e.jsx("span",{className:"mr-2",children:h.icon||"📂"}),h.name]},h.id)),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(eN,{}),e.jsxs(Afe,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Your Groups"]}),s.map(h=>e.jsxs(Va,{onClick:()=>n(`group:${h.id}`),children:[e.jsx("span",{className:"mr-2",children:h.icon||"🔒"}),h.name]},h.id))]})]})]}),e.jsxs(z6,{open:o,onOpenChange:l,children:[e.jsx(a1e,{asChild:!0,children:e.jsxs(Y,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(br,{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(q3,{children:[e.jsx(B6,{children:e.jsxs($6,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(po,{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(h=>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(_a,{src:h.avatarUrl}),e.jsx(gn,{children:i(h.name)})]}),e.jsx(Td,{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:h.name})]},h.id))})})]})]})]})};var Ohe,Aoe="HoverCard",[zVe]=Dc(Aoe,[Wx]),Eoe=Wx(),[yAt,P_e]=zVe(Aoe),BVe=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=Eoe(s),h=T.useRef(0),f=T.useRef(0),g=T.useRef(!1),v=T.useRef(!1),[_,j]=Sh({prop:n,defaultProp:a??!1,onChange:o,caller:Aoe}),w=T.useCallback(()=>{clearTimeout(f.current),h.current=window.setTimeout(()=>j(!0),l)},[l,j]),k=T.useCallback(()=>{clearTimeout(h.current),!g.current&&!v.current&&(f.current=window.setTimeout(()=>j(!1),i))},[i,j]),M=T.useCallback(()=>j(!1),[j]);return T.useEffect(()=>()=>{clearTimeout(h.current),clearTimeout(f.current)},[]),e.jsx(yAt,{scope:s,open:_,onOpenChange:j,onOpen:w,onClose:k,onDismiss:M,hasSelectionRef:g,isPointerDownOnContentRef:v,children:e.jsx(N6,{...d,children:r})})};BVe.displayName=Aoe;var $Ve="HoverCardTrigger",UVe=T.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=P_e($Ve,r),o=Eoe(r);return e.jsx(I3,{asChild:!0,...o,children:e.jsx(Qr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:kr(t.onPointerEnter,Rne(a.onOpen)),onPointerLeave:kr(t.onPointerLeave,Rne(a.onClose)),onFocus:kr(t.onFocus,a.onOpen),onBlur:kr(t.onBlur,a.onClose),onTouchStart:kr(t.onTouchStart,l=>l.preventDefault())})})});UVe.displayName=$Ve;var vAt="HoverCardPortal",[Xfs,_At]=zVe(vAt,{forceMount:void 0}),One="HoverCardContent",qVe=T.forwardRef((t,s)=>{const r=_At(One,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=P_e(One,t.__scopeHoverCard);return e.jsx(Qc,{present:n||o.open,children:e.jsx(bAt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:kr(t.onPointerEnter,Rne(o.onOpen)),onPointerLeave:kr(t.onPointerLeave,Rne(o.onClose)),ref:s})})});qVe.displayName=One;var bAt=T.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=P_e(One,r),h=Eoe(r),f=T.useRef(null),g=ba(s,f),[v,_]=T.useState(!1);return T.useEffect(()=>{if(v){const j=document.body;return Ohe=j.style.userSelect||j.style.webkitUserSelect,j.style.userSelect="none",j.style.webkitUserSelect="none",()=>{j.style.userSelect=Ohe,j.style.webkitUserSelect=Ohe}}},[v]),T.useEffect(()=>{if(f.current){const j=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var k;((k=document.getSelection())==null?void 0:k.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",j),()=>{document.removeEventListener("pointerup",j),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),T.useEffect(()=>{f.current&&kAt(f.current).forEach(w=>w.setAttribute("tabindex","-1"))}),e.jsx(n_,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:kr(o,j=>{j.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(S6,{...h,...i,onPointerDown:kr(i.onPointerDown,j=>{j.currentTarget.contains(j.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)"}})})}),wAt="HoverCardArrow",jAt=T.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Eoe(r);return e.jsx(C6,{...a,...n,ref:s})});jAt.displayName=wAt;function Rne(t){return s=>s.pointerType==="touch"?void 0:t()}function kAt(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 NAt=BVe,SAt=UVe,VVe=qVe;const CAt=NAt,MAt=SAt,HVe=T.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(VVe,{ref:a,align:s,sideOffset:r,className:$t("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}));HVe.displayName=VVe.displayName;const TAt=[{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"}],AAt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),WVe=({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(CAt,{openDelay:200,closeDelay:100,children:[e.jsx(MAt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(HVe,{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=TAt.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(_a,{src:l.user_avatar||void 0}),e.jsx(gn,{className:"text-[10px]",children:AAt(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 EAt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=T.useState(s),[l,i]=T.useState(!1);T.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const d=()=>{o(v=>v>0?v-1:t.length-1),i(!1)},h=()=>{o(v=>v{r&&(v.key==="ArrowLeft"&&d(),v.key==="ArrowRight"&&h(),v.key==="Escape"&&n(!1))},[r,t.length]);T.useEffect(()=>(window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)),[f]);const g=t[a];return e.jsx(js,{open:r,onOpenChange:n,children:e.jsxs(_s,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(Y,{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(Xr,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{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(hc,{className:"h-8 w-8"})}),e.jsx(Y,{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:h,children:e.jsx(Ri,{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(Y,{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(G4,{className:"h-5 w-5"}):e.jsx(W4,{className:"h-5 w-5"})}),e.jsx("div",{className:$t("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:$t("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:$t("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 c8=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],IAt=({commentId:t,reactions:s,currentUserId:r})=>{var h,f;const n=vs(),[a,o]=T.useState(!1),l=s.find(g=>g.user_id===r),i=Wt({mutationFn:async g=>{l?l.reaction_type===g?await Z.from("community_comment_reactions").delete().eq("id",l.id):await Z.from("community_comment_reactions").update({reaction_type:g}).eq("id",l.id):await Z.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(WVe,{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=c8.find(_=>_.type===g))==null?void 0:v.emoji},g)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(_l,{open:a,onOpenChange:o,children:[e.jsx(bl,{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:[(h=c8.find(g=>g.type===l.reaction_type))==null?void 0:h.emoji," ",(f=c8.find(g=>g.type===l.reaction_type))==null?void 0:f.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ti,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(nl,{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:c8.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 L_e({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],h=o[3],f=i==="#";n.push(e.jsx(bo,{to:f?`/templates/${h}`:`/profile?user=${h}`,className:$t("font-medium hover:underline",f?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:g=>g.stopPropagation(),children:f?d:`@${d}`},`mention-${l++}`))}else if(o[4]){const i=o[4],d=i.replace(/[.,;:!?)]+$/,""),h=i.slice(d.length);let f;try{const g=new URL(d);f=g.hostname+(g.pathname!=="/"?g.pathname.slice(0,20)+(g.pathname.length>20?"...":""):"")}catch{f=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:f},`url-${l++}`)),h&&n.push(h)}a=o.index+o[0].length}return ae.jsx(T.Fragment,{children:i},d))})}function Fne({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:h=!1}){const f=T.useRef(null),g=T.useRef(null),[v,_]=T.useState(!1),[j,w]=T.useState("user"),[k,M]=T.useState(""),[S,E]=T.useState(null),[D,L]=T.useState(0),[B,$]=T.useState({top:0,left:0,width:0}),V=T.useRef(new Map),W=T.useRef(new Map),G=ye=>{if(d==="plain"){const Ee=[];return V.current.forEach((Ue,De)=>{ye.includes(`@${De}`)&&Ee.push(Ue)}),[...new Set(Ee)]}const Se=/@\[([^\]]+)\]\(([^)]+)\)/g,Ke=[];let Ae;for(;(Ae=Se.exec(ye))!==null;)Ke.push(Ae[2]);return[...new Set(Ke)]},J=ye=>{if(d==="plain"){const Ee=[];return W.current.forEach((Ue,De)=>{ye.includes(`#${De}`)&&Ee.push(Ue)}),[...new Set(Ee)]}const Se=/#\[([^\]]+)\]\(([^)]+)\)/g,Ke=[];let Ae;for(;(Ae=Se.exec(ye))!==null;)Ke.push(Ae[2]);return[...new Set(Ke)]};T.useEffect(()=>{if(o){const ye=G(t);o(ye)}if(l){const ye=J(t);l(ye)}},[t,o,l,d]);const{data:ne=[],isLoading:ie}=zt({queryKey:["mention-users",k],queryFn:async()=>{const ye=Z.from("profiles").select("id, name").limit(8),Se=k.length>=1?ye.ilike("name",`%${k}%`):ye.order("name"),{data:Ke,error:Ae}=await Se;if(Ae)throw Ae;const Ee=Ke.map(Ue=>Ue.id),He=await mBe(Ee);return Ke.map(Ue=>({id:Ue.id,name:Ue.name||"Unknown",avatar_url:He.get(Ue.id)}))},enabled:v&&j==="user",staleTime:3e4}),{data:ee=[],isLoading:de}=zt({queryKey:["mention-templates",k],queryFn:async()=>{let ye=Z.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);k.length>=1&&(ye=ye.ilike("name",`%${k}%`));const{data:Se,error:Ke}=await ye;if(Ke)throw Ke;return Se||[]},enabled:v&&j==="template"&&h,staleTime:3e4}),oe=j==="user"?ie:de,ue=j==="user"?ne:ee,ce=ye=>ye.split(" ").map(Se=>Se[0]).join("").toUpperCase().slice(0,2),ge=ye=>{const Se=ye.target.value,Ke=ye.target.selectionStart;s(Se);const Ae=Se.substring(0,Ke),Ee=Ae.lastIndexOf("@"),He=h?Ae.lastIndexOf("#"):-1;let Ue=-1,De="user";if(Ee>He?(Ue=Ee,De="user"):He>Ee&&h&&(Ue=He,De="template"),Ue!==-1){const Ge=Ae.substring(Ue+1),wt=Ge.includes(" "),Ie=Ge.includes(` `);if(!wt&&!Ie&&Ge.length<=30){E(Ue),M(Ge),w(De),_(!0),L(0);return}}_(!1),E(null)},Te=ye=>{if(S===null)return;const Se=t.substring(0,S),Ke=t.substring(S+k.length+1),Ae=j==="user"?"@":"#",Ee=d==="plain"?`${Ae}${ye.name} `:`${Ae}[${ye.name}](${ye.id}) `;d==="plain"&&(j==="user"?V.current.set(ye.name,ye.id):W.current.set(ye.name,ye.id));const He=Se+Ee+Ke;s(He),_(!1),E(null),M(""),setTimeout(()=>{if(f.current){const Ue=Se.length+Ee.length;f.current.focus(),f.current.setSelectionRange(Ue,Ue)}},0)},ve=ye=>{if(!(!v||ue.length===0))switch(ye.key){case"ArrowDown":ye.preventDefault(),L(Se=>(Se+1)%ue.length);break;case"ArrowUp":ye.preventDefault(),L(Se=>(Se-1+ue.length)%ue.length);break;case"Enter":ue[D]&&(ye.preventDefault(),Te(ue[D]));break;case"Escape":ye.preventDefault(),_(!1);break;case"Tab":ue[D]&&(ye.preventDefault(),Te(ue[D]));break}};return T.useEffect(()=>{const ye=Se=>{g.current&&!g.current.contains(Se.target)&&f.current&&!f.current.contains(Se.target)&&_(!1)};return document.addEventListener("mousedown",ye),()=>document.removeEventListener("mousedown",ye)},[]),T.useEffect(()=>{if(!v)return;const ye=()=>{const Se=f.current;if(!Se)return;const Ke=Se.getBoundingClientRect();$({top:Ke.bottom+4,left:Ke.left,width:Ke.width})};return ye(),window.addEventListener("resize",ye),window.addEventListener("scroll",ye,!0),()=>{window.removeEventListener("resize",ye),window.removeEventListener("scroll",ye,!0)}},[v,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Rr,{ref:f,value:t,onChange:ge,onKeyDown:ye=>{ve(ye),ye.defaultPrevented||i==null||i(ye)},placeholder:r,className:$t("resize-none",n),style:{minHeight:a}}),v&&Qh.createPortal(e.jsxs("div",{ref:g,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:B.top,left:B.left,width:B.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:j==="user"?"👤 Mention a person":"📋 Link a template"}),oe?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):ue.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:k.length<1?`Type to search ${j==="user"?"people":"templates"}...`:`No ${j==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:ue.map((ye,Se)=>e.jsx("li",{className:$t("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",Se===D?"bg-accent":"hover:bg-accent/50"),onClick:()=>Te(ye),onMouseEnter:()=>L(Se),children:j==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(fn,{className:"h-6 w-6",children:[e.jsx(_a,{src:ye.avatar_url}),e.jsx(gn,{className:"text-xs",children:ce(ye.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:ye.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:ye.preview_image_url?e.jsx("img",{src:ye.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(hd,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:ye.name})]})},ye.id))})]}),document.body)]})}function PAt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const hMe=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function GVe({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=vs(),[d,h]=T.useState(!1),[f,g]=T.useState(""),[v,_]=T.useState([]),j=Wt({mutationFn:async({content:S,parentCommentId:E})=>{const{data:D,error:L}=await Z.from("community_comments").insert({post_id:s,user_id:r,content:S,parent_comment_id:E}).select("id").single();if(L)throw L;const B=v;if(B.length>0&&D){const $=B.filter(V=>V!==r).map(V=>({comment_id:D.id,mentioned_user_id:V,mentioned_by_user_id:r}));$.length>0&&await Z.from("community_comment_mentions").insert($)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),g(""),_([]),h(!1)}}),w=Wt({mutationFn:async S=>{const{error:E}=await Z.from("community_comments").delete().eq("id",S);if(E)throw E},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),k=()=>{f.trim()&&j.mutate({content:f,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(_a,{src:t.user_avatar||void 0}),e.jsx(gn,{className:"text-xs",children:hMe(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(L_e,{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:_u(new Date(t.created_at),{addSuffix:!0})}),e.jsx(IAt,{commentId:t.id,reactions:t.reactions,currentUserId:r}),r&&l<2&&e.jsxs("button",{onClick:()=>h(!d),className:"hover:text-primary flex items-center gap-1",children:[e.jsx($E,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>w.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),d&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(fn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(_a,{src:n||void 0}),e.jsx(gn,{className:"text-xs",children:hMe((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Fne,{placeholder:`Reply to ${t.user_name}...`,value:f,onChange:g,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:k,disabled:!f.trim()||j.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Wa,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(S=>e.jsx(GVe,{comment:S,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},S.id))})]})}const d8=[{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"}],LAt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Ys(),{avatarUrl:a}=hBe(t==null?void 0:t.id),{onlineUsers:o}=S9e(),{toast:l}=Sa(),i=vs(),d=T.useRef(null),[h,f]=T.useState("all"),[g,v]=T.useState(""),[_,j]=T.useState(""),[w,k]=T.useState(""),[M,S]=T.useState([]),[E,D]=T.useState([]),[L,B]=T.useState(""),[$,V]=T.useState(!1),[W,G]=T.useState(null),[J,ne]=T.useState(""),[ie,ee]=T.useState(new Set),[de,oe]=T.useState({}),[ue,ce]=T.useState({}),[ge,Te]=T.useState([]),[ve,ye]=T.useState([]),[Se,Ke]=T.useState({open:!1,images:[],index:0});T.useEffect(()=>{if(h.startsWith("group:")){const qe=h.replace("group:","");k(qe),j("")}else h!=="all"?(j(h),k("")):(j(""),k(""))},[h]);const{data:Ae=[]}=zt({queryKey:["community-categories"],queryFn:async()=>{const{data:qe,error:Lt}=await Z.from("community_categories").select("*").order("sort_order");if(Lt)throw Lt;return qe}}),{data:Ee=[]}=zt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:qe,error:Lt}=await Z.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Lt)throw Lt;return qe}}),He=20,{data:Ue,isLoading:De,hasNextPage:Ge,fetchNextPage:wt,isFetchingNextPage:Ie}=qlt({queryKey:["community-posts",h],initialPageParam:0,queryFn:async({pageParam:qe})=>{var Pe;const Lt=qe*He,Rt=Lt+He;let Kt=Z.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Lt,Rt);if(h.startsWith("group:")){const Qe=h.replace("group:","");Kt=Kt.eq("private_group_id",Qe)}else h==="all"||(Kt=Kt.eq("category_id",h).is("private_group_id",null));const{data:Xt,error:ss}=await Kt;if(ss)throw ss;const fs=((Xt==null?void 0:Xt.length)||0)>He,fr=(Xt||[]).slice(0,He);if(fr.length===0)return{posts:[],hasMore:!1,nextPage:qe+1};const yt=fr.map(Qe=>Qe.id),bs=[...new Set(fr.filter(Qe=>Qe.category_id).map(Qe=>Qe.category_id))].filter(Boolean),[gr,Br,na,za,go]=await Promise.all([bs.length?Z.from("community_categories").select("*").in("id",bs):Promise.resolve({data:[]}),Z.from("community_post_media").select("*").in("post_id",yt).order("sort_order"),Z.from("community_reactions").select("*").in("post_id",yt),Z.from("community_comments").select("*").in("post_id",yt).order("created_at",{ascending:!0}),Z.from("community_post_resources").select("*").in("post_id",yt)]),Ia=gr==null?void 0:gr.data,nn=Br==null?void 0:Br.data,Qt=na==null?void 0:na.data,lr=za==null?void 0:za.data,Vr=go==null?void 0:go.data,Pr=(lr||[]).map(Qe=>Qe.id),[on,cs]=await Promise.all([Pr.length?Z.from("community_comment_reactions").select("*").in("comment_id",Pr):Promise.resolve({data:[]}),(()=>{const Qe=(Vr||[]).filter(Tt=>Tt.resource_type==="template").map(Tt=>Tt.resource_id);return Qe.length===0?Promise.resolve({data:[]}):Z.from("canva_templates").select("id, name, preview_image_url").in("id",Qe)})()]),ka=(on==null?void 0:on.data)||[],zi=(cs==null?void 0:cs.data)||[],li=new Map(zi.map(Qe=>[Qe.id,{name:Qe.name,preview_image_url:Qe.preview_image_url}])),Or=Array.from(new Set([...fr.map(Qe=>Qe.user_id),...(Qt||[]).map(Qe=>Qe.user_id),...(lr||[]).map(Qe=>Qe.user_id),...ka.map(Qe=>Qe.user_id)])),[Oi,Rc]=await Promise.all([Or.length?Z.from("profiles").select("id, name").in("id",Or):Promise.resolve({data:[]}),mBe(Or)]),Co=new Map(((Pe=Oi==null?void 0:Oi.data)==null?void 0:Pe.map(Qe=>[Qe.id,Qe.name]))||[]),Fc=new Map((Ia||[]).map(Qe=>[Qe.id,Qe])),rt=Qe=>{const Tt=new Map,kt=[];return Qe.forEach(Dt=>{Tt.set(Dt.id,{...Dt,user_name:Co.get(Dt.user_id)||"Unknown User",user_avatar:Rc.get(Dt.user_id),reactions:ka.filter(Zt=>Zt.comment_id===Dt.id).map(Zt=>({...Zt,user_name:Co.get(Zt.user_id)||"Unknown User",user_avatar:Rc.get(Zt.user_id)})),replies:[]})}),Qe.forEach(Dt=>{const Zt=Tt.get(Dt.id);if(Dt.parent_comment_id&&Tt.has(Dt.parent_comment_id)){const Ft=Tt.get(Dt.parent_comment_id);Ft.replies=Ft.replies||[],Ft.replies.push(Zt)}else kt.push(Zt)}),kt};return{posts:fr.map(Qe=>{const Tt=(Vr||[]).filter(kt=>kt.post_id===Qe.id).map(kt=>{let Dt="",Zt=null;if(kt.resource_type==="template"){const Ft=li.get(kt.resource_id);Dt=(Ft==null?void 0:Ft.name)||"Unknown Template",Zt=(Ft==null?void 0:Ft.preview_image_url)||null}return{id:kt.id,resource_type:kt.resource_type,resource_id:kt.resource_id,resource_name:Dt,resource_preview_url:Zt}});return{...Qe,user_name:Co.get(Qe.user_id)||"Unknown User",user_avatar:Rc.get(Qe.user_id),category:Qe.category_id?Fc.get(Qe.category_id):null,media:(nn||[]).filter(kt=>kt.post_id===Qe.id),reactions:((Qt||[]).filter(kt=>kt.post_id===Qe.id)||[]).map(kt=>({...kt,user_name:Co.get(kt.user_id)||"Unknown User",user_avatar:Rc.get(kt.user_id)})),comments:rt((lr||[]).filter(kt=>kt.post_id===Qe.id)),resources:Tt}}),hasMore:fs,nextPage:qe+1}},getNextPageParam:qe=>qe.hasMore?qe.nextPage:void 0}),st=T.useMemo(()=>(Ue==null?void 0:Ue.pages.flatMap(qe=>qe.posts))??[],[Ue]),he=Wt({mutationFn:async()=>{V(!0);const{data:qe,error:Lt}=await Z.from("community_posts").insert({user_id:t.id,category_id:w?null:_||null,private_group_id:w||null,content:g,link_url:L||null}).select().single();if(Lt)throw Lt;for(let Kt=0;Kt0){const Kt=ge.filter(Xt=>Xt!==t.id).map(Xt=>({post_id:qe.id,mentioned_user_id:Xt,mentioned_by_user_id:t.id}));Kt.length>0&&await Z.from("community_post_mentions").insert(Kt)}const Rt=PAt(g);if(Rt.length>0){const Kt=Rt.map(Xt=>({post_id:qe.id,resource_type:"template",resource_id:Xt}));await Z.from("community_post_resources").insert(Kt)}return qe},onSuccess:async qe=>{var Lt;i.invalidateQueries({queryKey:["community-posts"]}),v(""),Te([]),ye([]),j(""),k(""),S([]),D([]),B(""),l({title:"Post created!"});try{const Rt=((Lt=t==null?void 0:t.user_metadata)==null?void 0:Lt.name)||"Someone",Kt=g.length>50?g.substring(0,50)+"...":g;await Z.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Rt}: ${Kt}`,url:"/community"}})}catch(Rt){console.error("Failed to send push notification:",Rt)}},onError:qe=>{l({title:"Error creating post",description:qe.message,variant:"destructive"})},onSettled:()=>V(!1)}),We=Wt({mutationFn:async({postId:qe,content:Lt})=>{const{error:Rt}=await Z.from("community_posts").update({content:Lt}).eq("id",qe);if(Rt)throw Rt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),G(null),ne(""),l({title:"Post updated!"})}}),et=Wt({mutationFn:async qe=>{const{error:Lt}=await Z.from("community_posts").delete().eq("id",qe);if(Lt)throw Lt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),Ye=Wt({mutationFn:async({postId:qe,isPinned:Lt})=>{const{error:Rt}=await Z.from("community_posts").update({is_pinned:!Lt,pinned_at:Lt?null:new Date().toISOString(),pinned_by:Lt?null:t==null?void 0:t.id}).eq("id",qe);if(Rt)throw Rt},onSuccess:(qe,{isPinned:Lt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Lt?"Post unpinned":"Post pinned to top"})}}),ke=Wt({mutationFn:async({postId:qe,reactionType:Lt})=>{var Kt;const Rt=(Kt=st.find(Xt=>Xt.id===qe))==null?void 0:Kt.reactions.find(Xt=>Xt.user_id===(t==null?void 0:t.id));Rt?Rt.reaction_type===Lt?await Z.from("community_reactions").delete().eq("id",Rt.id):await Z.from("community_reactions").update({reaction_type:Lt}).eq("id",Rt.id):await Z.from("community_reactions").insert({post_id:qe,user_id:t.id,reaction_type:Lt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),at=Wt({mutationFn:async({postId:qe,content:Lt})=>{const{data:Rt,error:Kt}=await Z.from("community_comments").insert({post_id:qe,user_id:t.id,content:Lt}).select("id").single();if(Kt)throw Kt;const Xt=ue[qe]||[];if(Xt.length>0&&Rt){const ss=Xt.filter(fs=>fs!==t.id).map(fs=>({comment_id:Rt.id,mentioned_user_id:fs,mentioned_by_user_id:t.id}));ss.length>0&&await Z.from("community_comment_mentions").insert(ss)}},onSuccess:(qe,{postId:Lt})=>{i.invalidateQueries({queryKey:["community-posts"]}),oe(Rt=>({...Rt,[Lt]:""})),ce(Rt=>({...Rt,[Lt]:[]}))}});Wt({mutationFn:async qe=>{const{error:Lt}=await Z.from("community_comments").delete().eq("id",qe);if(Lt)throw Lt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const Fe=qe=>{const Lt=Array.from(qe.target.files||[]);if(Lt.length+M.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}S(Rt=>[...Rt,...Lt]),Lt.forEach(Rt=>{const Kt=new FileReader;Kt.onloadend=()=>{D(Xt=>[...Xt,Kt.result])},Kt.readAsDataURL(Rt)})},it=qe=>{S(Lt=>Lt.filter((Rt,Kt)=>Kt!==qe)),D(Lt=>Lt.filter((Rt,Kt)=>Kt!==qe))},dt=qe=>qe.split(" ").map(Lt=>Lt[0]).join("").toUpperCase().slice(0,2),tt=qe=>{const Lt={};return qe.forEach(Rt=>{Lt[Rt.reaction_type]=(Lt[Rt.reaction_type]||0)+1}),Lt},ut=qe=>{var Lt;return(Lt=qe.find(Rt=>Rt.user_id===(t==null?void 0:t.id)))==null?void 0:Lt.reaction_type},xt=qe=>qe.reduce((Lt,Rt)=>Lt+1+(Rt.replies?xt(Rt.replies):0),0),_t=qe=>{if(n)return!0;if(!s||!qe.private_group_id)return!1;const Lt=Ee.find(Rt=>Rt.id===qe.private_group_id);return Lt!=null&&Lt.brokerage_id?r.some(Rt=>Rt.id===Lt.brokerage_id):!1};return e.jsx(Vs,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(gAt,{categories:Ae,privateGroups:Ee,selectedFilter:h,onFilterChange:f,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(xAt,{categories:Ae,privateGroups:Ee,selectedFilter:h,onFilterChange:f,onlineUsers:o}),e.jsx(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(fn,{className:"h-10 w-10",children:[e.jsx(_a,{src:a||void 0}),e.jsx(gn,{children:t!=null&&t.email?dt(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Fne,{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:Te,onTemplatesChange:ye,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),E.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:E.map((qe,Lt)=>{var Rt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Rt=M[Lt])!=null&&Rt.type.startsWith("video/")?e.jsx("video",{src:qe,className:"w-full h-full object-cover"}):e.jsx("img",{src:qe,alt:"",className:"w-full h-full object-cover"}),e.jsx(Y,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>it(Lt),children:e.jsx(Xr,{className:"h-3 w-3"})})]},Lt)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ro,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Be,{value:L,onChange:qe=>B(qe.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>B(""),children:e.jsx(Xr,{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:Fe,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>{var qe;return(qe=d.current)==null?void 0:qe.click()},children:[e.jsx(fl,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>{var qe;return(qe=d.current)==null?void 0:qe.click()},children:[e.jsx(Wn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>B("https://"),children:[e.jsx(Ro,{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:[Ee.length>0?e.jsxs(er,{value:w||_||"none",onValueChange:qe=>{qe==="none"?(j(""),k("")):qe.startsWith("group:")?(k(qe.replace("group:","")),j("")):(j(qe),k(""))},children:[e.jsx(Qs,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(tr,{placeholder:"Select..."})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No category"}),Ae.map(qe=>e.jsxs(Et,{value:qe.id,children:[qe.icon," ",qe.name]},qe.id)),Ee.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"}),Ee.map(qe=>e.jsxs(Et,{value:`group:${qe.id}`,children:[qe.icon||"🔒"," ",qe.name]},qe.id))]})]})]}):e.jsxs(er,{value:_,onValueChange:j,children:[e.jsx(Qs,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(tr,{placeholder:"Category"})}),e.jsx(Js,{children:Ae.map(qe=>e.jsxs(Et,{value:qe.id,children:[qe.icon," ",qe.name]},qe.id))})]}),e.jsxs(Y,{size:"sm",onClick:()=>he.mutate(),disabled:!g.trim()||$,children:[e.jsx(Wa,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),De?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((qe,Lt)=>e.jsx(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ys,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ys,{className:"h-4 w-32"}),e.jsx(ys,{className:"h-4 w-full"}),e.jsx(ys,{className:"h-4 w-3/4"})]})]})})},Lt))}):st.length===0?e.jsx(Oe,{children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx(Gl,{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:[st.map(qe=>{var Lt,Rt,Kt,Xt;return e.jsx(Oe,{children:e.jsxs($e,{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(_a,{src:qe.user_avatar||void 0}),e.jsx(gn,{children:dt(qe.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:qe.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:_u(new Date(qe.created_at),{addSuffix:!0})}),qe.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(ct,{variant:"secondary",className:"text-xs",children:[qe.category.icon," ",qe.category.name]})]})]})]})]}),(qe.user_id===(t==null?void 0:t.id)||_t(qe))&&e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Rp,{className:"h-4 w-4"})})}),e.jsxs(ju,{align:"end",children:[_t(qe)&&qe.private_group_id&&e.jsx(Va,{onClick:()=>Ye.mutate({postId:qe.id,isPinned:qe.is_pinned}),children:qe.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(RE,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(E1,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),qe.user_id===(t==null?void 0:t.id)&&e.jsxs(Va,{onClick:()=>{G(qe),ne(qe.content)},children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Va,{className:"text-destructive",onClick:()=>et.mutate(qe.id),children:[e.jsx(Ir,{className:"h-4 w-4 mr-2"}),qe.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),qe.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(E1,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(L_e,{content:qe.content})}),qe.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${qe.media.length===1?"grid-cols-1":qe.media.length===2?"grid-cols-2":qe.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:qe.media.slice(0,4).map((ss,fs)=>{const fr=fs===3&&qe.media.length>4,yt=qe.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${qe.media.length===1?"max-h-[500px]":qe.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>Ke({open:!0,images:qe.media.map(bs=>({url:bs.media_url,type:bs.media_type==="video"?"video":"image"})),index:fs}),children:[ss.media_type==="video"?e.jsx("video",{src:ss.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:ss.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})}),fr&&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:["+",yt]})})]},ss.id)})}),qe.link_url&&e.jsxs("a",{href:qe.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[qe.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:qe.link_image,alt:qe.link_title||"Link preview",className:"w-full h-full object-cover",onError:ss=>{ss.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:qe.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:qe.link_title}),qe.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:qe.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(qe.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(Ro,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:qe.link_url})]})})]}),qe.reactions.length>0&&e.jsx(WVe,{reactions:qe.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(tt(qe.reactions)).slice(0,3).map(([ss])=>{var fs;return e.jsx("span",{className:"text-base",children:(fs=d8.find(fr=>fr.type===ss))==null?void 0:fs.emoji},ss)})}),e.jsx("span",{children:qe.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"ghost",size:"sm",className:"flex-1",children:[ut(qe.reactions)?e.jsx("span",{className:"mr-1",children:(Lt=d8.find(ss=>ss.type===ut(qe.reactions)))==null?void 0:Lt.emoji}):e.jsx(Ed,{className:"h-4 w-4 mr-1"}),ut(qe.reactions)?(Rt=d8.find(ss=>ss.type===ut(qe.reactions)))==null?void 0:Rt.label:"Like"]})}),e.jsx(nl,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:d8.map(ss=>e.jsx("button",{onClick:()=>ke.mutate({postId:qe.id,reactionType:ss.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:ss.label,children:ss.emoji},ss.type))})})]}),e.jsxs(Y,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>ee(ss=>{const fs=new Set(ss);return fs.has(qe.id)?fs.delete(qe.id):fs.add(qe.id),fs}),children:[e.jsx(Gl,{className:"h-4 w-4 mr-1"}),(()=>{const ss=xt(qe.comments);return ss>0?`Comment (${ss})`:"Comment"})()]})]}),ie.has(qe.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[qe.comments.map(ss=>e.jsx(GVe,{comment:ss,postId:qe.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:_t(qe)},ss.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(_a,{src:a||void 0}),e.jsx(gn,{className:"text-xs",children:dt(((Kt=t.email)==null?void 0:Kt.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Fne,{placeholder:"Write a comment... (use @ to mention)",value:de[qe.id]||"",onChange:ss=>oe(fs=>({...fs,[qe.id]:ss})),onMentionsChange:ss=>ce(fs=>({...fs,[qe.id]:ss})),mentionFormat:"plain",onKeyDown:ss=>{var fs;ss.defaultPrevented||ss.key==="Enter"&&!ss.shiftKey&&((fs=de[qe.id])!=null&&fs.trim())&&(ss.preventDefault(),at.mutate({postId:qe.id,content:de[qe.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>{var ss;(ss=de[qe.id])!=null&&ss.trim()&&at.mutate({postId:qe.id,content:de[qe.id]})},disabled:!((Xt=de[qe.id])!=null&&Xt.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Wa,{className:"h-4 w-4"})})]})]})]})]})},qe.id)}),Ge&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(Y,{variant:"outline",onClick:()=>wt(),disabled:Ie,children:Ie?"Loading…":"Load more posts"})})]}),e.jsx(js,{open:!!W,onOpenChange:()=>G(null),children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Edit Post"})}),e.jsx(Rr,{value:J,onChange:qe=>ne(qe.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>G(null),children:"Cancel"}),e.jsx(Y,{onClick:()=>{W&&We.mutate({postId:W.id,content:J})},disabled:!J.trim(),children:"Save Changes"})]})]})}),e.jsx(EAt,{images:Se.images,initialIndex:Se.index,open:Se.open,onOpenChange:qe=>Ke(Lt=>({...Lt,open:qe}))})]})]})})},IC={open:{label:"Open",icon:ca,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Gl,color:"bg-blue-500"},resolved:{label:"Resolved",icon:yi,color:"bg-green-500"},closed:{label:"Closed",icon:Cc,color:"bg-muted-foreground"}},mMe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function DAt(){const{user:t}=Ys(),s=vs(),[r,n]=T.useState(null),[a,o]=T.useState(""),{data:l=[],isLoading:i}=zt({queryKey:["support-tickets"],queryFn:async()=>{const{data:g,error:v}=await Z.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=[]}=zt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:g,error:v}=await Z.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}),h=Wt({mutationFn:async g=>{if(!r||!t)throw new Error("Missing data");const{error:v}=await Z.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(""),be.success("Reply sent!")},onError:()=>{be.error("Failed to send reply")}}),f=()=>{a.trim()&&h.mutate(a)};if(r){const g=IC[r.status].icon;return e.jsx(Vs,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(bi,{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(ct,{variant:"secondary",children:mMe[r.category]}),e.jsxs(ct,{className:IC[r.status].color,children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),IC[r.status].label]})]})]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Tr,{children:["Created on ",Bs(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx($e,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Conversation"})}),e.jsxs($e,{children:[e.jsx(po,{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:Bs(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(ud,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Rr,{placeholder:"Type your reply...",value:a,onChange:v=>o(v.target.value),className:"min-h-[80px]"}),e.jsx(Y,{onClick:f,disabled:!a.trim()||h.isPending,className:"self-end",children:e.jsx(Wa,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Vs,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Oe,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx($e,{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(Dy,{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(Zfe,{trigger:e.jsxs(Y,{size:"lg",className:"gap-2",children:[e.jsx(ar,{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(Ha,{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(Zfe,{trigger:e.jsxs(Y,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(ar,{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(Oe,{className:"border-dashed",children:e.jsxs($e,{className:"text-center py-12",children:[e.jsx(Gl,{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=IC[g.status].icon;return e.jsx(Oe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(g),children:e.jsx($e,{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(ct,{variant:"outline",className:"text-xs",children:mMe[g.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Bs(new Date(g.created_at),"MMM d, yyyy")})]})]}),e.jsxs(ct,{className:IC[g.status].color,children:[e.jsx(v,{className:"h-3 w-3 mr-1"}),IC[g.status].label]})]})})},g.id)})})]})})}function OAt({open:t,onOpenChange:s}){return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ls,{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(xn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ps,{children:"Schedule Agent Onboarding"}),e.jsx(en,{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 RAt({open:t,onOpenChange:s}){const{brokerageId:r}=Ys(),[n,a]=T.useState(""),[o,l]=T.useState([]),[i,d]=T.useState(!1),{data:h,isLoading:f}=zt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:w,error:k}=await Z.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(k)throw k;return w},enabled:t&&!!r}),g=h==null?void 0:h.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())||w.email.toLowerCase().includes(n.toLowerCase())),v=w=>{l(k=>k.includes(w)?k.filter(M=>M!==w):[...k,w])},_=async()=>{if(o.length===0){be.error("Please select at least one agent");return}d(!0);try{const{data:w,error:k}=await Z.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(k)throw k;be.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(w){console.error("Error sending onboarding link:",w),be.error(w.message||"Failed to send onboarding link")}finally{d(!1)}},j=w=>{w||(l([]),a("")),s(w)};return e.jsx(js,{open:t,onOpenChange:j,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Ls,{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(Wa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ps,{children:"Send Onboarding Link"}),e.jsx(en,{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(On,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search agents...",value:n,onChange:w=>a(w.target.value),className:"pl-10"})]}),f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Us,{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(br,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(po,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:g==null?void 0:g.map(w=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>v(w.id),children:[e.jsx(Do,{checked:o.includes(w.id),onCheckedChange:()=>v(w.id)}),e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{className:"text-xs",children:w.name.split(" ").map(k=>k[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:w.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w.email})]})]},w.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(Y,{onClick:_,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function FAt(){const[t,s]=T.useState(!1),[r,n]=T.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{className:"mb-8",children:[e.jsx(Ht,{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(br,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Gt,{children:"Agent Onboarding"}),e.jsx(Tr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx($e,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(Y,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(Y,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(Wa,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(OAt,{open:t,onOpenChange:s}),e.jsx(RAt,{open:r,onOpenChange:n})]})}function zAt({open:t,onOpenChange:s}){return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Ls,{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(Cx,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ps,{children:"Schedule Launch Meeting"}),e.jsx(en,{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 BAt(){const[t,s]=T.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{className:"mb-8",children:[e.jsx(Ht,{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(Cx,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Gt,{children:"Launch or ReLaunch Meeting"}),e.jsx(Tr,{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($e,{children:e.jsxs(Y,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(Cx,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(zAt,{open:t,onOpenChange:s})]})}function $At(){const t=Yr(),[s,r]=T.useState(""),[n,a]=T.useState(null),{data:o,isLoading:l}=zt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:w,error:k}=await Z.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(k)throw k;return w}}),{data:i}=zt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:w,error:k}=await Z.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(k)throw k;return w}}),{data:d}=zt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:w,error:k}=await Z.from("brokerage_resource_pdfs").select("resource_id");if(k)throw k;return w}}),{data:h}=zt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:w,error:k}=await Z.from("brokerage_resource_videos").select("resource_id");if(k)throw k;return w}}),{data:f}=zt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:w,error:k}=await Z.from("brokerage_resource_links").select("resource_id");if(k)throw k;return w}}),g=o==null?void 0:o.filter(w=>{var S;const k=w.title.toLowerCase().includes(s.toLowerCase())||((S=w.description)==null?void 0:S.toLowerCase().includes(s.toLowerCase())),M=!n||w.category_id===n;return k&&M}),v=i==null?void 0:i.filter(w=>o==null?void 0:o.some(k=>k.category_id===w.id)),_=w=>{const k=(d==null?void 0:d.filter(E=>E.resource_id===w).length)||0,M=(h==null?void 0:h.filter(E=>E.resource_id===w).length)||0,S=(f==null?void 0:f.filter(E=>E.resource_id===w).length)||0;return{pdfCount:k,videoCount:M,linkCount:S}},j=w=>{t(`/brokerage-resources/${w}`)};return e.jsx(Vs,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(FAt,{}),e.jsx(BAt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(On,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search resources...",value:s,onChange:w=>r(w.target.value),className:"pl-10"})]}),v&&v.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ct,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),v.map(w=>e.jsx(ct,{variant:n===w.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(w.id),children:w.name},w.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(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((w,k)=>e.jsxs(Oe,{children:[e.jsx(ys,{className:"h-40 w-full"}),e.jsx(Ht,{children:e.jsx(ys,{className:"h-5 w-3/4"})}),e.jsxs($e,{children:[e.jsx(ys,{className:"h-4 w-full mb-2"}),e.jsx(ys,{className:"h-4 w-2/3"})]})]},k))}):(g==null?void 0:g.length)===0?e.jsxs(Oe,{className:"p-12 text-center",children:[e.jsx(Fu,{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(w=>{const{pdfCount:k,videoCount:M,linkCount:S}=_(w.id),E=i==null?void 0:i.find(D=>D.id===w.category_id);return e.jsxs(Oe,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>j(w.id),children:[w.preview_image_url?e.jsx("img",{src:w.preview_image_url,alt:w.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(Fu,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Ht,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Gt,{className:"text-lg line-clamp-1",children:w.title}),E&&e.jsx(ct,{variant:"secondary",className:"shrink-0 text-xs",children:E.name})]})}),e.jsxs($e,{children:[w.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:w.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[k>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Yn,{className:"h-4 w-4"}),k]}),M>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wn,{className:"h-4 w-4"}),M]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ro,{className:"h-4 w-4"}),S]})]})]})]},w.id)})})]})})}const UAt=()=>{const{resourceId:t}=wl(),{data:s,isLoading:r}=zt({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await Z.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await Z.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await Z.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:d}=await Z.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(Vs,{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(Vs,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(Y,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(bo,{to:"/brokerage-resources",children:[e.jsx(bi,{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(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Wn,{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(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Yn,{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(Yn,{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(Vi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(bn,{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(bn,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(bn,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Vs,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Fu,{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(Y,{asChild:!0,className:"mt-4",children:e.jsx(bo,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function qAt(){const{onlineUsers:t,totalOnline:s}=S9e();return e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(ct,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(Td,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx($e,{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(po,{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(_a,{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 ",_u(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const pMe={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:br,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:KE,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:Zm,path:"/admin/subscriptions",color:"bg-gradient-to-br from-green-500/20 to-green-500/10 text-green-600"},{title:"Subscription Discounts",description:"Create and manage coupon codes",icon:Kp,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:Kc,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:br,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:hm,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:Zc,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:hd,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:C1,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:a0,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:Sn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:Sn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:r0,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:Km,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:Fu,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Fu,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:zr,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:Nk,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:Im,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:zr,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:M4,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:Mx,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:oo,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:vo,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:Jm,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:br,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:Eo,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:D4,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:t0,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:qn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:zr,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:Sc,path:"/admin/analytics",color:"bg-emerald-500/10 text-emerald-600"}]},"agent-os":{label:"Agent OS",sections:[{title:"Agent OS Control Center",description:"Manage InnerCircle feature: relationship types, action types, scripts, plans & feature flags",icon:Ti,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:Zn,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:Gp,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:Yy,path:"/admin/guest-book-analytics",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"}]}};function VAt(){const t=Yr();return e.jsx(Vs,{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(qAt,{})})]}),e.jsxs(Qa,{defaultValue:"users",className:"w-full",children:[e.jsx(Ga,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1",children:Object.entries(pMe).map(([s,r])=>e.jsx(Fs,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(pMe).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(Oe,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(Ht,{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(Gt,{className:"text-base",children:n.title})]}),e.jsx($e,{className:"pt-0",children:e.jsx(Tr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Fn=T.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:$t("w-full caption-bottom text-sm",t),...s})}));Fn.displayName="Table";const zn=T.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:$t("[&_tr]:border-b",t),...s}));zn.displayName="TableHeader";const Bn=T.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:$t("[&_tr:last-child]:border-0",t),...s}));Bn.displayName="TableBody";const HAt=T.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:$t("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));HAt.displayName="TableFooter";const ws=T.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:$t("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));ws.displayName="TableRow";const Ct=T.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:$t("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));Ct.displayName="TableHead";const ot=T.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:$t("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));ot.displayName="TableCell";const WAt=T.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:$t("mt-4 text-sm text-muted-foreground",t),...s}));WAt.displayName="TableCaption";const GAt=()=>{const{isAdmin:t}=Ys(),s=Yr(),[r,n]=T.useState([]),[a,o]=T.useState(!0),[l,i]=T.useState(!1),[d,h]=T.useState(null);T.useEffect(()=>{if(!t){s("/dashboard");return}f()},[t]);const f=async()=>{try{const{data:w,error:k}=await Z.from("app_tiles").select("*").order("name");if(k)throw k;n(w||[])}catch(w){console.error("Error loading apps:",w),be.error("Failed to load apps")}finally{o(!1)}},g=async w=>{w.preventDefault();const k=new FormData(w.currentTarget),M={name:k.get("name"),description:k.get("description"),icon:k.get("icon"),app_id:k.get("app_id"),target_url:k.get("target_url"),required_tags:k.get("required_tags").split(",").map(S=>S.trim()).filter(Boolean)};try{if(d){const{error:S}=await Z.from("app_tiles").update(M).eq("id",d.id);if(S)throw S;be.success("App updated successfully")}else{const{error:S}=await Z.from("app_tiles").insert([M]);if(S)throw S;be.success("App created successfully")}i(!1),h(null),f()}catch(S){console.error("Error saving app:",S),be.error("Failed to save app")}},v=async w=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:k}=await Z.from("app_tiles").delete().eq("id",w);if(k)throw k;be.success("App deleted successfully"),f()}catch(k){console.error("Error deleting app:",k),be.error("Failed to delete app")}},_=w=>{h(w),i(!0)},j=()=>{h(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(Y,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(bi,{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(js,{open:l,onOpenChange:i,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{onClick:j,children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(_s,{className:"max-w-2xl",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:d?"Edit App":"Create New App"}),e.jsx(en,{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(je,{htmlFor:"name",children:"App Name"}),e.jsx(Be,{id:"name",name:"name",defaultValue:d==null?void 0:d.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"app_id",children:"App ID"}),e.jsx(Be,{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(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{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(je,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(Be,{id:"icon",name:"icon",defaultValue:d==null?void 0:d.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"target_url",children:"Target URL"}),e.jsx(Be,{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(je,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(Be,{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(Y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",children:d?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Application Tiles"}),e.jsx(Tr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx($e,{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(Y,{onClick:j,children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Icon"}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"App ID"}),e.jsx(Ct,{children:"Target URL"}),e.jsx(Ct,{children:"Tags"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:r.map(w=>e.jsxs(ws,{children:[e.jsx(ot,{className:"text-2xl",children:w.icon}),e.jsx(ot,{className:"font-medium",children:w.name}),e.jsx(ot,{className:"font-mono text-sm",children:w.app_id}),e.jsx(ot,{className:"text-sm text-muted-foreground max-w-xs truncate",children:w.target_url}),e.jsx(ot,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:w.required_tags.map(k=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:k},k))})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>_(w),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>v(w.id),children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},w.id))})]})})]})})]})};function Yu({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(bo,{to:"/admin",children:e.jsxs(Y,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(bi,{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 u8=({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(ct,{variant:"destructive",className:$t("gap-1",s),children:[e.jsx(Lu,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(ct,{variant:"destructive",className:$t("gap-1",s),children:[e.jsx(ca,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(ct,{className:$t("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(ca,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(ct,{variant:"secondary",className:$t("gap-1",s),children:[e.jsx(ca,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},KVe=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Sa(),l=T.useRef(null),[i,d]=T.useState([]),[h,f]=T.useState(""),[g,v]=T.useState(!1),[_,j]=T.useState("upload"),[w,k]=T.useState(null),M=()=>{d([]),f(""),j("upload"),k(null),l.current&&(l.current.value="")},S=()=>{M(),s(!1)},E=V=>{const W=V.split(` `).map(ee=>ee.trim()).filter(ee=>ee);if(W.length===0)return[];const G=W[0].toLowerCase(),ne=G.includes("first")||G.includes("last")||G.includes("email")||G.includes("name")||G.includes("phone")||G.includes("sms")||G.includes("consent")?W.slice(1):W,ie=[];for(const ee of ne){const oe=(ee.includes(" ")?ee.split(" "):ee.split(",")).map(ue=>ue.trim().replace(/^["']|["']$/g,""));if(oe.length>=2){let ue="",ce="",ge="",Te="",ve;if(oe.length===2){const Ke=oe[0].split(" ");ue=Ke[0]||"",ce=Ke.slice(1).join(" ")||"",ge=oe[1]}else if(oe.length===3)ue=oe[0],ce=oe[1],ge=oe[2];else if(oe.length===4)ue=oe[0],ce=oe[1],ge=oe[2],Te=oe[3];else if(oe.length>=5){ue=oe[0],ce=oe[1],ge=oe[2],Te=oe[3];const Ke=oe[4].toLowerCase();ve=Ke==="true"||Ke==="yes"||Ke==="1"||Ke==="y"}const Se=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(ge);ie.push({firstName:ue.trim(),lastName:ce.trim(),email:ge.trim().toLowerCase(),phone:Te.trim()||void 0,smsConsent:ve,isValid:Se&&ue.trim().length>0,error:Se?ue.trim()?void 0:"Missing name":"Invalid email"})}}return ie},D=V=>{var J;const W=(J=V.target.files)==null?void 0:J[0];if(!W)return;const G=new FileReader;G.onload=ne=>{var de;const ie=(de=ne.target)==null?void 0:de.result,ee=E(ie);if(ee.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}d(ee),j("preview")},G.readAsText(W)},L=async()=>{const V=i.filter(G=>G.isValid);if(V.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const W=n||h||null;v(!0);try{const{data:{session:G}}=await Z.auth.getSession(),J=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${G==null?void 0:G.access_token}`},body:JSON.stringify({users:V.map(ie=>({firstName:ie.firstName,lastName:ie.lastName,email:ie.email,phone:ie.phone,smsConsent:ie.smsConsent})),brokerageId:W})}),ne=await J.json();if(!J.ok)throw new Error(ne.error||"Failed to import users");k(ne),j("result"),ne.created>0&&a(),o({title:"Import Complete",description:`${ne.created} user(s) created successfully.${ne.failed>0?` ${ne.failed} failed.`:""}`})}catch(G){console.error("Import error:",G),o({title:"Import Failed",description:G.message||"Failed to import users",variant:"destructive"})}finally{v(!1)}},B=i.filter(V=>V.isValid).length,$=i.filter(V=>!V.isValid).length;return e.jsx(js,{open:t,onOpenChange:S,children:e.jsxs(_s,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(Qy,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(en,{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:D,className:"hidden"}),e.jsx(ji,{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(Y,{onClick:()=>{var V;return(V=l.current)==null?void 0:V.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(je,{children:"Assign to Brokerage (optional)"}),e.jsxs(er,{value:h||"none",onValueChange:V=>f(V==="none"?"":V),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select a brokerage..."})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No brokerage"}),r.map(V=>e.jsx(Et,{value:V.id,children:V.name},V.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(oi,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[B," 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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/30",children:[e.jsx(Ct,{children:"First Name"}),e.jsx(Ct,{children:"Last Name"}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:"Phone"}),e.jsx(Ct,{children:"SMS"}),e.jsx(Ct,{children:"Status"})]})}),e.jsx(Bn,{children:i.slice(0,100).map((V,W)=>e.jsxs(ws,{children:[e.jsx(ot,{children:V.firstName}),e.jsx(ot,{children:V.lastName}),e.jsx(ot,{children:V.email}),e.jsx(ot,{className:"text-muted-foreground",children:V.phone||"-"}),e.jsx(ot,{className:"text-muted-foreground",children:V.smsConsent===!0?"✓":V.smsConsent===!1?"✗":"-"}),e.jsx(ot,{children:V.isValid?e.jsx(ct,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(ct,{variant:"destructive",children:V.error||"Invalid"})})]},W))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),_==="result"&&w&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(oi,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:[w.created," agent(s) created and invited"]}),w.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[w.failed," failed to create"]})]}),w.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[w.errors.slice(0,10).map((V,W)=>e.jsxs("li",{children:["• ",V]},W)),w.errors.length>10&&e.jsxs("li",{children:["...and ",w.errors.length-10," more"]})]})]})]}),e.jsxs(Hn,{children:[_==="upload"&&e.jsx(Y,{variant:"outline",onClick:S,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"outline",onClick:M,children:"Back"}),e.jsx(Y,{onClick:L,disabled:g||B===0,children:g?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${B} Agent${B!==1?"s":""}`})]}),_==="result"&&e.jsx(Y,{onClick:S,children:"Done"})]})]})})},KAt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:qn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:vo},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:md}];function ZVe({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=T.useState("custom"),[l,i]=T.useState(""),[d,h]=T.useState(""),f=Pft(),g=_=>{o(_.type),i(_.title),h(_.message)},v=async _=>{if(_.preventDefault(),!l.trim()){pn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await f.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:d.trim()||void 0}),pn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),h(""),o("custom")}catch{pn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(md,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(en,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(je,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:KAt.map((_,j)=>e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>g(_),className:"text-xs",children:[e.jsx(_.icon,{className:"h-3 w-3 mr-1"}),_.title]},j))})]}),e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(er,{value:a,onValueChange:_=>o(_),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(Et,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(Et,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(Et,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ad,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"title",children:"Title *"}),e.jsx(Be,{id:"title",value:l,onChange:_=>i(_.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Rr,{id:"message",value:d,onChange:_=>h(_.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:f.isPending,children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),f.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Rhe={points_earned:{label:"Points Earned",icon:vo,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Zn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:Ad,color:"bg-green-500"},custom:{label:"Custom",icon:Sn,color:"bg-purple-500"}};function ZAt(){const[t,s]=T.useState(""),[r,n]=T.useState("all"),[a,o]=T.useState("all"),{data:l=[],isLoading:i}=zt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:f,error:g}=await Z.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(g)throw g;const v=[...new Set([...f.map(w=>w.user_id),...f.map(w=>w.created_by).filter(Boolean)])],{data:_}=await Z.from("profiles").select("id, name, email").in("id",v),j=new Map((_==null?void 0:_.map(w=>[w.id,w]))||[]);return f.map(w=>{var k,M,S;return{...w,user_name:((k=j.get(w.user_id))==null?void 0:k.name)||"Unknown",user_email:((M=j.get(w.user_id))==null?void 0:M.email)||"",creator_name:w.created_by?((S=j.get(w.created_by))==null?void 0:S.name)||"System":"Auto-triggered"}})}}),d=l.filter(f=>{var j,w;const g=((j=f.user_name)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||((w=f.user_email)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||f.title.toLowerCase().includes(t.toLowerCase()),v=r==="all"||f.celebration_type===r,_=a==="all"||a==="seen"&&f.seen_at||a==="unseen"&&!f.seen_at;return g&&v&&_}),h={total:l.length,seen:l.filter(f=>f.seen_at).length,unseen:l.filter(f=>!f.seen_at).length,byType:Object.keys(Rhe).reduce((f,g)=>(f[g]=l.filter(v=>v.celebration_type===g).length,f),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Us,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:h.total})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:h.seen})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:h.unseen})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:h.byType.custom||0})})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(md,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(Tr,{children:"View all celebrations awarded to agents"})]}),e.jsxs($e,{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(On,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by agent name, email, or title...",value:t,onChange:f=>s(f.target.value),className:"pl-9"})]}),e.jsxs(er,{value:r,onValueChange:n,children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{placeholder:"Filter by type"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Types"}),Object.entries(Rhe).map(([f,g])=>e.jsx(Et,{value:f,children:g.label},f))]})]}),e.jsxs(er,{value:a,onValueChange:o,children:[e.jsx(Qs,{className:"w-[140px]",children:e.jsx(tr,{placeholder:"Status"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Status"}),e.jsx(Et,{value:"seen",children:"Seen"}),e.jsx(Et,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Type"}),e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Points"}),e.jsx(Ct,{children:"Created By"}),e.jsx(Ct,{children:"Created"}),e.jsx(Ct,{children:"Status"})]})}),e.jsx(Bn,{children:d.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(f=>{const g=Rhe[f.celebration_type],v=g.icon;return e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs(ct,{variant:"outline",className:"gap-1",children:[e.jsx(v,{className:"h-3 w-3"}),g.label]})}),e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:f.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:f.user_email})]})}),e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:f.title}),f.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:f.message})]})}),e.jsx(ot,{children:f.points_amount?e.jsxs(ct,{variant:"secondary",children:["+",f.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ot,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:f.creator_name})}),e.jsx(ot,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Bs(new Date(f.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(ot,{children:f.seen_at?e.jsx(ct,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(ct,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},f.id)})})]})}),d.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",d.length," of ",l.length," celebrations"]})]})]})]})}const YAt=()=>{const{user:t}=Ys(),{toast:s}=Sa(),[r,n]=T.useState([]),[a,o]=T.useState(!0),[l,i]=T.useState(!1),[d,h]=T.useState("all"),[f,g]=T.useState("all"),[v,_]=T.useState("new"),[j,w]=T.useState(new Set),k=T.useCallback(async()=>{try{o(!0);const{data:ie,error:ee}=await Z.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(ee)throw ee;const{data:de,error:oe}=await Z.from("trial_email_exports").select("user_id");if(oe)throw oe;const ue=new Set((de||[]).map(ge=>ge.user_id)),ce=(ie||[]).map(ge=>({...ge,converted_from_trial_at:ge.converted_from_trial_at??null,already_exported:ue.has(ge.id)}));ce.sort((ge,Te)=>new Date(Te.created_at).getTime()-new Date(ge.created_at).getTime()),n(ce)}catch(ie){console.error("Error loading trial users:",ie),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);T.useEffect(()=>{k()},[k]);const M=ie=>ie.trial_started_at?"ghl":"stripe",S=ie=>ie.trial_expires_at?ie.trial_expires_at:ie.subscription_end_date?ie.subscription_end_date:null,E=ie=>ie.converted_from_trial_at!==null,D=ie=>{if(E(ie))return!1;const ee=S(ie);return ee?new Date(ee).getTime()<=Date.now():!1},L=r.filter(ie=>!(d!=="all"&&M(ie)!==d||f==="active"&&(D(ie)||E(ie))||f==="expired"&&!D(ie)||f==="converted"&&!E(ie)||v==="new"&&ie.already_exported||v==="exported"&&!ie.already_exported)),B=()=>{j.size===L.length?w(new Set):w(new Set(L.map(ie=>ie.id)))},$=ie=>{const ee=new Set(j);ee.has(ie)?ee.delete(ie):ee.add(ie),w(ee)},V=async()=>{if(j.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const ie=r.filter(ve=>j.has(ve.id)),ee="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",de=ie.map(ve=>{const ye=(ve.name||"").split(" "),Se=ye[0]||"",Ke=ye.slice(1).join(" ")||"",Ae=M(ve)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Ee=E(ve)?"Converted":D(ve)?"Expired":"Active",He=ve.created_at?new Date(ve.created_at).toLocaleDateString():"",Ue=S(ve)?new Date(S(ve)).toLocaleDateString():"";return`"${Se}","${Ke}","${ve.email}","${ve.phone||""}","${Ae}","${Ee}","${He}","${Ue}"`}),oe=[ee,...de].join(` `),ue=new Blob([oe],{type:"text/csv"}),ce=URL.createObjectURL(ue),ge=document.createElement("a");ge.href=ce,ge.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,ge.click(),URL.revokeObjectURL(ce);const Te=ie.filter(ve=>!ve.already_exported).map(ve=>({user_id:ve.id,exported_by:t.id}));if(Te.length>0){const{error:ve}=await Z.from("trial_email_exports").upsert(Te,{onConflict:"user_id"});ve&&console.error("Error marking exports:",ve)}s({title:"Export complete",description:`Downloaded ${ie.length} trial user(s). ${Te.length} newly marked as exported.`}),w(new Set),k()}catch(ie){console.error("Export error:",ie),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},W=r.filter(ie=>!ie.already_exported).length,G=r.filter(ie=>ie.already_exported).length,J=r.filter(ie=>E(ie)).length,ne=r.filter(ie=>!D(ie)&&!E(ie)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Us,{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(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"Total"}),e.jsx(Gt,{className:"text-2xl",children:r.length})]})}),e.jsx(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"New (Not Exported)"}),e.jsx(Gt,{className:"text-2xl text-green-600",children:W})]})}),e.jsx(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"Active Trials"}),e.jsx(Gt,{className:"text-2xl",children:ne})]})}),e.jsx(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"Converted 🎉"}),e.jsx(Gt,{className:"text-2xl text-primary",children:J})]})}),e.jsx(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"Already Exported"}),e.jsx(Gt,{className:"text-2xl text-muted-foreground",children:G})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(er,{value:v,onValueChange:ie=>_(ie),children:[e.jsx(Qs,{className:"w-[160px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Users"}),e.jsx(Et,{value:"new",children:"New Only"}),e.jsx(Et,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(er,{value:d,onValueChange:ie=>h(ie),children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Trial Types"}),e.jsx(Et,{value:"stripe",children:"Credit Card Trial"}),e.jsx(Et,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(er,{value:f,onValueChange:ie=>g(ie),children:[e.jsx(Qs,{className:"w-[160px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Statuses"}),e.jsx(Et,{value:"active",children:"Active Trial"}),e.jsx(Et,{value:"expired",children:"Expired"}),e.jsx(Et,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(Y,{onClick:V,disabled:l||j.size===0,children:[l?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Export Selected (",j.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Ct,{className:"w-[40px]",children:e.jsx(Do,{checked:L.length>0&&j.size===L.length,onCheckedChange:B})}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:"Trial Type"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{children:"Signup Date"}),e.jsx(Ct,{children:"Expires / Renews"}),e.jsx(Ct,{children:"Exported"})]})}),e.jsx(Bn,{children:L.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):L.map(ie=>{const ee=M(ie),de=E(ie),oe=D(ie),ue=S(ie);return e.jsxs(ws,{className:`hover:bg-muted/30 ${de?"bg-primary/5":""}`,children:[e.jsx(ot,{children:e.jsx(Do,{checked:j.has(ie.id),onCheckedChange:()=>$(ie.id)})}),e.jsx(ot,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ie.name,de&&e.jsx(Jd,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(ot,{className:"text-muted-foreground",children:ie.email}),e.jsx(ot,{children:ee==="stripe"?e.jsxs(ct,{variant:"outline",className:"gap-1",children:[e.jsx(Zm,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(ct,{variant:"secondary",className:"gap-1",children:[e.jsx(zr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(ot,{children:de?e.jsxs(ct,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Jd,{className:"h-3 w-3"}),"Converted"]}):oe?e.jsx(ct,{variant:"destructive",children:"Expired"}):e.jsx(ct,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(ot,{className:"text-sm",children:ie.created_at?new Date(ie.created_at).toLocaleDateString():"—"}),e.jsx(ot,{className:"text-sm",children:de&&ue?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(ue).toLocaleDateString()]}):ue?new Date(ue).toLocaleDateString():"—"}),e.jsx(ot,{children:ie.already_exported?e.jsx(oi,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ct,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},ie.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",L.length," of ",r.length," trial users · ",J," converted to paid"]})]})},XAt=()=>{const[t,s]=T.useState([]),[r,n]=T.useState(!0);return T.useEffect(()=>{(async()=>{const{data:o,error:l}=await Z.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(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Oe,{children:e.jsxs($e,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Ir,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"User Deletion History"})}),e.jsx($e,{children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Date"}),e.jsx(Ct,{children:"User"}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:"Brokerage"}),e.jsx(Ct,{children:"Type"}),e.jsx(Ct,{children:"Deleted By"})]})}),e.jsx(Bn,{children:t.map(a=>e.jsxs(ws,{children:[e.jsx(ot,{className:"whitespace-nowrap text-sm",children:Bs(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(ot,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(ot,{children:a.brokerage_name||"—"}),e.jsx(ot,{children:e.jsx(ct,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(ot,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},CN=t=>{const{user:s}=Ys(),r=vs(),n=zt({queryKey:["teams",t],queryFn:async()=>{let g=Z.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=>zt({queryKey:["team-members",g],queryFn:async()=>{const{data:v,error:_}=await Z.from("team_members").select("*").eq("team_id",g).order("role",{ascending:!0});if(_)throw _;const j=(v||[]).map(M=>M.user_id),{data:w}=await Z.from("profiles").select("id, name, email, avatar_url").in("id",j),k=new Map((w||[]).map(M=>[M.id,M]));return(v||[]).map(M=>({...M,profile:k.get(M.user_id)||null}))},enabled:!!g}),o=Wt({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:j}=await Z.from("teams").insert(v).select().single();if(j)throw j;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),be.success("Team created!")},onError:g=>{be.error("Failed to create team: "+g.message)}}),l=Wt({mutationFn:async({id:g,...v})=>{const{data:_,error:j}=await Z.from("teams").update(v).eq("id",g).select().single();if(j)throw j;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),be.success("Team updated")},onError:g=>{be.error("Failed to update team: "+g.message)}}),i=Wt({mutationFn:async g=>{const{error:v}=await Z.from("teams").delete().eq("id",g);if(v)throw v},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),be.success("Team deleted")},onError:g=>{be.error("Failed to delete team: "+g.message)}}),d=Wt({mutationFn:async g=>{const{data:v,error:_}=await Z.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]}),be.success("Member added to team")},onError:g=>{be.error(g.message)}}),h=Wt({mutationFn:async g=>{const{error:v}=await Z.from("team_members").delete().eq("id",g.member_id);if(v)throw v},onSuccess:(g,v)=>{r.invalidateQueries({queryKey:["team-members",v.team_id]}),be.success("Member removed from team")},onError:g=>{be.error("Failed to remove member: "+g.message)}}),f=Wt({mutationFn:async g=>{const{error:v}=await Z.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]}),be.success("Member role updated")},onError:g=>{be.error("Failed to update role: "+g.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:d,removeMember:h,updateMemberRole:f,useTeamMembers:a}},QAt=()=>{const{user:t}=Ys();return zt({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},YVe=t=>{const{user:s}=Ys(),r=vs(),n=zt({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:d}=await Z.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 h=i.map(M=>M.contact_id),f=[...new Set(i.map(M=>M.added_by))],g=i.filter(M=>M.claimed_by).map(M=>M.claimed_by),v=[...new Set([...f,...g])],[_,j]=await Promise.all([Z.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",h),Z.from("profiles").select("id, name, avatar_url").in("id",v)]),w=new Map((_.data||[]).map(M=>[M.id,M])),k=new Map((j.data||[]).map(M=>[M.id,M]));return i.map(M=>({...M,status:M.claimed_by?"claimed":"available",contact:w.get(M.contact_id)||null,contributor:k.get(M.added_by)||null,claimer:M.claimed_by&&k.get(M.claimed_by)||null}))},enabled:!!t&&!!s}),a=Wt({mutationFn:async i=>{const{data:d,error:h}=await Z.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(h)throw h;return d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),be.success("Contact added to Lead Pond")},onError:i=>{be.error(i.message)}}),o=Wt({mutationFn:async i=>{const{error:d}=await Z.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),be.success("Lead claimed!")},onError:i=>{be.error(i.message)}}),l=Wt({mutationFn:async i=>{const{error:d}=await Z.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),be.success("Lead returned to pond")},onError:i=>{be.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},JAt=()=>{const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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"]}),be.success("Contact transferred successfully")},onError:s=>{be.error(s.message||"Failed to transfer contact")}})};function XVe({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=Ys(),{data:l}=h_(),{useTeamMembers:i}=CN(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),h=JAt(),[f,g]=T.useState(null),[v,_]=T.useState(""),[j,w]=T.useState(!1),k=d.filter(B=>B.user_id!==(o==null?void 0:o.id)),M=async()=>{if(f){w(!0);try{for(const B of r)await h.mutateAsync({contactId:B,toUserId:f,notes:v||void 0});s(!1),g(null),_(""),a==null||a()}catch{}finally{w(!1)}}},S=k.find(B=>B.user_id===f),E=r.length>1,D=n.length>0?E?`${n.length} contacts`:n[0]:E?`${r.length} contacts`:"this contact";return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(Zy,{className:"h-5 w-5"}),"Transfer ",D]}),e.jsxs(en,{children:["Select a team member to transfer ",E?"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(je,{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:k.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):k.map(B=>{var $,V,W;return e.jsxs("button",{onClick:()=>g(B.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${f===B.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(_a,{src:(($=B.profile)==null?void 0:$.avatar_url)||""}),e.jsx(gn,{className:"text-xs",children:(((V=B.profile)==null?void 0:V.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((W=B.profile)==null?void 0:W.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:B.role.replace("_"," ")})]})]},B.user_id)})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Rr,{id:"transfer-notes",value:v,onChange:B=>_(B.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{onClick:M,disabled:!f||j,children:[j?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Zy,{className:"h-4 w-4 mr-2"}),"Transfer",S?` to ${(L=S.profile)==null?void 0:L.name}`:""]})]})]})})}const D_e=()=>{const t=Yr(),{data:s,isLoading:r}=QAt(),{data:n}=h_(),[a,o]=T.useState(""),[l,i]=T.useState("all"),[d,h]=T.useState(null),[f,g]=T.useState(""),v=(n==null?void 0:n.role)==="team_leader",_=T.useMemo(()=>{if(!s)return[];const w=new Map;return s.forEach(k=>{w.has(k.owner_user_id)||w.set(k.owner_user_id,{id:k.owner_user_id,name:k.owner_name||"Unknown",avatar:k.owner_avatar_url})}),Array.from(w.values())},[s]),j=T.useMemo(()=>{if(!s)return[];let w=s;if(l!=="all"&&(w=w.filter(k=>k.owner_user_id===l)),a.trim()){const k=a.toLowerCase();w=w.filter(M=>{var S,E,D;return(M.first_name+" "+(M.last_name||"")).toLowerCase().includes(k)||((S=M.email)==null?void 0:S.toLowerCase().includes(k))||((E=M.phone)==null?void 0:E.includes(k))||((D=M.owner_name)==null?void 0:D.toLowerCase().includes(k))})}return w},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"h-10 w-full"}),e.jsx(ys,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(br,{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(Oe,{children:e.jsx($e,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:w=>o(w.target.value),className:"pl-9"})]}),e.jsxs(er,{value:l,onValueChange:i,children:[e.jsx(Qs,{className:"w-[200px]",children:e.jsx(tr,{placeholder:"Filter by agent"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Team Members"}),_.map(w=>e.jsx(Et,{value:w.id,children:w.name},w.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[j.length," contact",j.length!==1?"s":""," from ",_.length," teammate",_.length!==1?"s":""]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0 overflow-x-auto",children:e.jsxs(Fn,{className:"min-w-[800px]",children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{children:"Contact Info"}),e.jsx(Ct,{children:"Address"}),e.jsx(Ct,{children:"Lead Source"}),e.jsx(Ct,{children:"Date Added"}),v&&e.jsx(Ct,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Bn,{children:j.length===0?e.jsx(ws,{children:e.jsx(ot,{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"})}):j.map(w=>e.jsxs(ws,{className:`hover:bg-accent/50 ${v?"cursor-pointer":""}`,onClick:v?()=>t(`/mission-control/contacts/${w.id}`):void 0,children:[e.jsx(ot,{className:"font-medium",children:e.jsxs("span",{className:v?"hover:text-primary hover:underline transition-colors":"",children:[w.first_name," ",w.last_name||""]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(fn,{className:"h-6 w-6",children:[e.jsx(_a,{src:w.owner_avatar_url||""}),e.jsx(gn,{className:"text-[10px]",children:(w.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:w.owner_name||"Unknown"})]})}),e.jsx(ot,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[w.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(zr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:w.email})]}),w.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Ha,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:w.phone})]}),!w.email&&!w.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(ot,{children:w.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Gi,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:w.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(ot,{children:w.lead_source?e.jsx(ct,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:w.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(ot,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Bs(new Date(w.created_at),"MMM d, yyyy")})}),v&&e.jsx(ot,{children:e.jsx(Y,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:k=>{k.stopPropagation(),h(w.id),g(`${w.first_name} ${w.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(Zy,{className:"h-4 w-4"})})})]},w.id))})]})})}),e.jsx(XVe,{open:!!d,onOpenChange:w=>{w||h(null)},contactIds:d?[d]:[],contactNames:f?[f]:[],onComplete:()=>h(null)})]})},O_e=({teamId:t})=>{const{user:s}=Ys(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=YVe(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(ys,{className:"h-20 w-full"},d))});if(r.length===0)return e.jsx(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Nx,{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 h,f,g,v,_,j,w;return e.jsx(Oe,{children:e.jsxs($e,{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:[(h=d.contact)==null?void 0:h.first_name," ",((f=d.contact)==null?void 0:f.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(zr,{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(Ha,{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(_a,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(gn,{className:"text-[8px]",children:(((j=d.contributor)==null?void 0:j.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((w=d.contributor)==null?void 0:w.name)||"Unknown"]})]})]}),e.jsxs(Y,{size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[e.jsx(NE,{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 h,f,g;return e.jsx(Oe,{className:"opacity-75",children:e.jsxs($e,{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:[(h=d.contact)==null?void 0:h.first_name," ",((f=d.contact)==null?void 0:f.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(ct,{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(Y,{size:"sm",variant:"outline",onClick:()=>o.mutate(d.id),disabled:o.isPending,children:[e.jsx(Ik,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},QVe=({teamId:t})=>{const{useTeamMembers:s}=CN(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=zt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:j}=await Z.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(j)throw j;return _||[]},enabled:n.length>0}),{data:i=[],isLoading:d}=zt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:j}=await Z.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(j)throw j;return _||[]},enabled:n.length>0}),{data:h=[],isLoading:f}=zt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:j}=await Z.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(j)throw j;return _||[]},enabled:n.length>0});if(l||d||f)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(ys,{className:"h-20 w-full"},_))});const v=_=>{const j=a.get(_);return{name:(j==null?void 0:j.name)||"Unknown",avatar:(j==null?void 0:j.avatar_url)||"",initials:((j==null?void 0:j.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(Oe,{children:e.jsxs($e,{className:"flex items-center gap-3 p-4",children:[e.jsx(Gp,{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(Oe,{children:e.jsxs($e,{className:"flex items-center gap-3 p-4",children:[e.jsx(Zn,{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(Oe,{children:e.jsxs($e,{className:"flex items-center gap-3 p-4",children:[e.jsx(Wn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:h.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]}),e.jsxs(Qa,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(Ga,{children:[e.jsxs(Fs,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(Fs,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(Fs,{value:"videos",children:["Videos (",h.length,")"]})]}),e.jsx(Zs,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Fhe,{icon:e.jsx(Gp,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const j=v(_.owner_user_id);return e.jsx(Oe,{children:e.jsxs($e,{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(_a,{src:j.avatar}),e.jsx(gn,{className:"text-xs",children:j.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:[j.name," · ",Bs(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(ct,{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(wi,{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(Fhe,{icon:e.jsx(Zn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const j=v(_.agent_id);return e.jsx(Oe,{children:e.jsxs($e,{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(_a,{src:j.avatar}),e.jsx(gn,{className:"text-xs",children:j.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:[j.name," · ",Bs(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(ct,{className:"text-xs",children:"Active"}):e.jsx(ct,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(br,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx(Zs,{value:"videos",className:"space-y-2",children:h.length===0?e.jsx(Fhe,{icon:e.jsx(Wn,{className:"h-10 w-10"}),label:"No videos yet"}):h.map(_=>{const j=v(_.owner_user_id);return e.jsx(Oe,{children:e.jsxs($e,{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(_a,{src:j.avatar}),e.jsx(gn,{className:"text-xs",children:j.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:[j.name," · ",Bs(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(ct,{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(wi,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},Fhe=({icon:t,label:s})=>e.jsx(Oe,{children:e.jsxs($e,{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})]})}),JVe=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:d,isAddingMember:h})=>{const{useTeamMembers:f}=CN(),{data:g=[],isLoading:v}=f(t.id),[_,j]=T.useState(!1),[w,k]=T.useState(""),[M,S]=T.useState("team_member"),{data:E}=zt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:$}=await Z.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),V=new Map;return($||[]).forEach(W=>{var G;V.set(W.user_id,((G=W.teams)==null?void 0:G.name)||"another team")}),V}}),D=new Set(g.map($=>$.user_id)),L=s.filter($=>!D.has($.id)),B=async()=>{w&&(await a(w,M),k(""),S("team_member"),j(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Y,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(Qa,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"members",children:"Members"}),e.jsxs(Fs,{value:"contacts",children:[e.jsx(bk,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(Fs,{value:"lead-pond",children:[e.jsx(Nx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(Fs,{value:"shared-assets",children:[e.jsx(om,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(Fs,{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(js,{open:_,onOpenChange:j,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{size:"sm",children:[e.jsx(Zc,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Add Team Member"}),e.jsxs(en,{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(je,{children:"Agent"}),e.jsxs(er,{value:w,onValueChange:k,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select an agent"})}),e.jsxs(Js,{children:[L.length===0&&e.jsx(Et,{value:"none",disabled:!0,children:"No available agents"}),L.map($=>{const V=E==null?void 0:E.get($.id);return e.jsx(Et,{value:$.id,disabled:!!V,children:e.jsxs("span",{className:"flex items-center gap-2",children:[$.name||$.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]})},$.id)})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Role"}),e.jsxs(er,{value:M,onValueChange:S,children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"team_leader",children:"Team Leader"}),e.jsx(Et,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(Y,{onClick:B,disabled:!w||h,children:h?"Adding...":"Add to Team"})]})]})]})]}),v?e.jsx("div",{className:"space-y-3",children:[1,2,3].map($=>e.jsx(ys,{className:"h-16 w-full"},$))}):g.length===0?e.jsx(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(br,{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($=>{var V,W,G,J,ne;return e.jsx(Oe,{children:e.jsxs($e,{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(_a,{src:((V=$.profile)==null?void 0:V.avatar_url)||""}),e.jsx(gn,{children:(((W=$.profile)==null?void 0:W.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((G=$.profile)==null?void 0:G.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(J=$.profile)==null?void 0:J.email})]}),$.role==="team_leader"?e.jsxs(ct,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(kh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(ct,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(er,{value:$.role,onValueChange:ie=>l($.id,ie),children:[e.jsx(Qs,{className:"w-[140px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"team_leader",children:"Team Leader"}),e.jsx(Et,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(QE,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Remove Member?"}),e.jsxs(cc,{children:["Remove ",((ne=$.profile)==null?void 0:ne.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:()=>o($.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},$.id)})})]}),e.jsx(Zs,{value:"contacts",className:"space-y-4",children:e.jsx(D_e,{})}),t.lead_pond_enabled&&e.jsx(Zs,{value:"lead-pond",className:"space-y-4",children:e.jsx(O_e,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(Zs,{value:"shared-assets",className:"space-y-4",children:e.jsx(QVe,{teamId:t.id})}),e.jsxs(Zs,{value:"settings",className:"space-y-4",children:[e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{className:"text-lg",children:"Team Settings"}),e.jsx(Tr,{children:"Configure how this team operates."})]}),e.jsxs($e,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Team Name"}),e.jsx(Be,{defaultValue:t.name,onBlur:$=>{$.target.value!==t.name&&n({name:$.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Rr,{defaultValue:t.description||"",onBlur:$=>{$.target.value!==(t.description||"")&&n({description:$.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Contact Visibility"}),e.jsxs(er,{defaultValue:t.contact_visibility,onValueChange:$=>n({contact_visibility:$}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(Et,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(Et,{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(je,{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(ln,{checked:t.lead_pond_enabled,onCheckedChange:$=>n({lead_pond_enabled:$})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{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(ln,{checked:t.shared_assets_enabled,onCheckedChange:$=>n({shared_assets_enabled:$})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{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(ln,{checked:t.shared_videos_enabled??!1,onCheckedChange:$=>n({shared_videos_enabled:$})})]})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsxs(Y,{variant:"destructive",size:"sm",children:[e.jsx(Ir,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Delete Team?"}),e.jsxs(cc,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},eHe=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,h]=T.useState(1),[f,g]=T.useState(""),[v,_]=T.useState(""),[j,w]=T.useState(""),[k,M]=T.useState(""),[S,E]=T.useState([]),D=()=>{h(1),g(""),_(""),w(""),M(""),E([])},L=W=>{W||D(),s(W)},B=async()=>{const W=j&&j!=="none"?j:i||null;await r({name:f.trim(),description:v.trim()||void 0,brokerage_id:W,leaderId:k||void 0,memberIds:S.length>0?S:void 0}),D()},$=W=>{W!==k&&E(G=>G.includes(W)?G.filter(J=>J!==W):[...G,W])},V=a.filter(W=>W.id!==k);return e.jsx(js,{open:t,onOpenChange:L,children:e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:d===1?"Create New Team":"Assign Team Members"}),e.jsx(en,{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:$t("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:$t("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(je,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(Be,{id:"team-name",value:f,onChange:W=>g(W.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"team-desc",children:"Description"}),e.jsx(Rr,{id:"team-desc",value:v,onChange:W=>_(W.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(je,{children:"Brokerage"}),e.jsxs(er,{value:j,onValueChange:w,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No brokerage (independent)"}),l.map(W=>e.jsx(Et,{value:W.id,children:W.name},W.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{className:"flex items-center gap-1.5",children:[e.jsx(kh,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(er,{value:k,onValueChange:W=>{M(W),E(G=>G.filter(J=>J!==W))},children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No leader for now"}),a.map(W=>e.jsx(Et,{value:W.id,children:W.name||W.email||"Unknown"},W.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{className:"flex items-center gap-1.5",children:[e.jsx(Zc,{className:"h-3.5 w-3.5"}),"Initial Members",S.length>0&&e.jsxs(ct,{variant:"secondary",className:"ml-1 text-xs",children:[S.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:V.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(br,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):V.map(W=>{const G=S.includes(W.id);return e.jsxs("button",{type:"button",className:$t("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",G&&"bg-primary/5"),onClick:()=>$(W.id),children:[e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(_a,{src:W.avatar_url||""}),e.jsx(gn,{className:"text-xs",children:(W.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:W.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:W.email})]}),e.jsx("div",{className:$t("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",G?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:G&&e.jsx(ma,{className:"h-3 w-3"})})]},W.id)})})]})]})}),e.jsx(Hn,{className:"gap-2 sm:gap-0",children:d===1?e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(Y,{onClick:()=>h(2),disabled:!f.trim(),children:["Next",e.jsx(qi,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"outline",onClick:()=>h(1),children:[e.jsx(bi,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(Y,{onClick:B,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},eEt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=CN(),[d,h]=T.useState(!1),[f,g]=T.useState(null),[v,_]=T.useState(""),{data:j}=zt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:L,error:B}=await Z.from("brokerages").select("id, name").order("name");if(B)throw B;return L||[]}}),{data:w}=zt({queryKey:["admin-team-member-info",t.map(L=>L.id).join(",")],queryFn:async()=>{var W;if(t.length===0)return{};const{data:L}=await Z.from("team_members").select("team_id, user_id, role").in("team_id",t.map(G=>G.id));if(!L)return{};const B=L.filter(G=>G.role==="team_leader").map(G=>G.user_id);let $={};if(B.length>0){const{data:G}=await Z.from("profiles").select("id, name").in("id",B);G&&($=Object.fromEntries(G.map(J=>[J.id,{name:J.name}])))}const V={};for(const G of t){const J=L.filter(ie=>ie.team_id===G.id),ne=J.find(ie=>ie.role==="team_leader");V[G.id]={count:J.length,leaderName:ne&&((W=$[ne.user_id])==null?void 0:W.name)||null}}return V},enabled:t.length>0}),k=(f==null?void 0:f.brokerage_id)||null,{data:M}=zt({queryKey:["brokerage-agents-for-teams",k],queryFn:async()=>{let L=Z.from("profiles").select("id, name, email, avatar_url").order("name");k&&(L=L.eq("brokerage_id",k));const{data:B,error:$}=await L;if($)throw $;return B||[]},enabled:!!f}),S=Object.fromEntries((j||[]).map(L=>[L.id,L.name])),E=async L=>{const B=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:B.id,user_id:L.leaderId,role:"team_leader"}),L.memberIds)for(const $ of L.memberIds)await o.mutateAsync({team_id:B.id,user_id:$,role:"team_member"});h(!1)};if(f)return e.jsx(JVe,{team:f,brokerageAgents:M||[],onBack:()=>g(null),onUpdate:L=>n.mutateAsync({id:f.id,...L}).then(B=>g(B)),onAddMember:(L,B)=>o.mutateAsync({team_id:f.id,user_id:L,role:B}),onRemoveMember:L=>l.mutateAsync({team_id:f.id,member_id:L}),onUpdateRole:(L,B)=>i.mutateAsync({team_id:f.id,member_id:L,role:B}),onDeleteTeam:()=>{a.mutate(f.id),g(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const D=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(On,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{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:[D.length," of ",t.length," teams"]})]}),e.jsxs(Y,{size:"sm",onClick:()=>h(!0),children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(eHe,{open:d,onOpenChange:h,onCreateTeam:E,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:j,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Ct,{className:"font-semibold",children:"Team Name"}),e.jsx(Ct,{className:"font-semibold",children:"Brokerage"}),e.jsx(Ct,{className:"font-semibold",children:"Leader"}),e.jsx(Ct,{className:"font-semibold",children:"Members"}),e.jsx(Ct,{className:"font-semibold",children:"Visibility"}),e.jsx(Ct,{className:"w-[100px]"})]})}),e.jsx(Bn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsx(ys,{className:"h-4 w-32"})}),e.jsx(ot,{children:e.jsx(ys,{className:"h-4 w-24"})}),e.jsx(ot,{children:e.jsx(ys,{className:"h-4 w-28"})}),e.jsx(ot,{children:e.jsx(ys,{className:"h-4 w-12"})}),e.jsx(ot,{children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx(ot,{children:e.jsx(ys,{className:"h-4 w-16"})})]},L))}):D.length===0?e.jsx(ws,{children:e.jsx(ot,{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."})}):D.map(L=>{const B=w==null?void 0:w[L.id];return e.jsxs(ws,{className:"hover:bg-muted/30",children:[e.jsxs(ot,{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(ot,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:S[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(ot,{children:B!=null&&B.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(kh,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),B.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(ot,{children:e.jsxs(ct,{variant:"secondary",className:"text-xs",children:[e.jsx(br,{className:"h-3 w-3 mr-1"}),(B==null?void 0:B.count)??0]})}),e.jsx(ot,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(Bu,{className:"h-3 w-3"}),L.contact_visibility.replace("_"," ")]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>g(L),title:"Edit team",children:e.jsx(Xa,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{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(Ir,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},tEt=()=>{const t=Yr(),{user:s,isAdmin:r}=Ys(),{startImpersonation:n,isLoading:a}=Tve(),{toast:o}=Sa(),[l,i]=T.useState([]),[d,h]=T.useState([]),[f,g]=T.useState([]),[v,_]=T.useState({}),[j,w]=T.useState(!0),[k,M]=T.useState({}),[S,E]=T.useState(!1),[D,L]=T.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[B,$]=T.useState(!1),[V,W]=T.useState(""),[G,J]=T.useState(1),[ne,ie]=T.useState(50),[ee,de]=T.useState("all"),[oe,ue]=T.useState("all"),[ce,ge]=T.useState("all"),[Te,ve]=T.useState("all"),[ye,Se]=T.useState(!1),[Ke,Ae]=T.useState(!1),[Ee,He]=T.useState(null),[Ue,De]=T.useState(null),[Ge,wt]=T.useState(!1),[Ie,st]=T.useState({name:"",email:"",brokerage_id:"",phone:""}),[he,We]=T.useState(null),[et,Ye]=T.useState(!1),[ke,at]=T.useState(""),[Fe,it]=T.useState(!1),[dt,tt]=T.useState(!1),[ut,xt]=T.useState(null),[_t,qe]=T.useState(""),[Lt,Rt]=T.useState(!1),[Kt,Xt]=T.useState(!1),[ss,fs]=T.useState(null),[fr,yt]=T.useState(!1),[bs,gr]=T.useState(!1),[Br,na]=T.useState(null),[za,go]=T.useState(""),[Ia,nn]=T.useState(!1),[Qt,lr]=T.useState({email:"",name:"",password:"",phone:""}),[Vr,Pr]=T.useState(!1),[on,cs]=T.useState(!1),[ka,zi]=T.useState(""),[li,Or]=T.useState(!1),[Oi,Rc]=T.useState(!1),[Co,Fc]=T.useState(""),[rt,_e]=T.useState(new Set),[Pe,Qe]=T.useState(!1),[Tt,kt]=T.useState(!1),[Dt,Zt]=T.useState(null),[Ft,Jt]=T.useState(!1),[Ss,ps]=T.useState(null),[ur,Dr]=T.useState([]),[cr,jn]=T.useState([]),[kn,yn]=T.useState(!1),[aa,so]=T.useState({});T.useEffect(()=>{!s||!r||(Pa(),Fo())},[s,r]);const Po=async()=>{try{const{data:Nt,error:Cs}=await Z.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Cs)throw Cs;const Ks={};for(const dn of Nt??[])Ks[dn.brokerage_id]||(Ks[dn.brokerage_id]=[]),Ks[dn.brokerage_id].push(dn.user_id);_(Ks)}catch(Nt){console.error("Error loading brokerage manager assignments:",Nt)}},Pa=async()=>{try{w(!0);const{data:Nt,error:Cs}=await Z.functions.invoke("get-user-details");if(Cs)throw Cs;const Ks=Nt.users||[];i(Ks),g(Nt.brokerages||[]),await Po();const dn=Ks.filter(vn=>vn.roles.includes("assistant"));if(dn.length>0){const vn=dn.map(Qn=>Qn.id),{data:fa}=await Z.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",vn);if(fa&&fa.length>0){const Qn=[...new Set(fa.map(Nu=>Nu.agent_id))],{data:La}=await Z.from("profiles").select("id, name, email").in("id",Qn),_m={};for(const Nu of fa){const Yl=La==null?void 0:La.find(Da=>Da.id===Nu.agent_id);Yl&&(_m[Nu.assistant_id]={agent_name:Yl.name||"",agent_email:Yl.email||""})}so(_m)}}}catch(Nt){console.error("Error loading members:",Nt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{w(!1)}},Fo=async()=>{try{const{data:Nt,error:Cs}=await Z.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Cs)throw Cs;h(Nt||[])}catch(Nt){console.error("Error loading apps:",Nt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},Ki=async Nt=>{if(!Ie.name.trim()||!Ie.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Ie.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Ks}=await Z.from("profiles").update({name:Ie.name.trim(),email:Ie.email.trim(),brokerage_id:Ie.brokerage_id||null,phone:Ie.phone.trim()||null}).eq("id",Nt);if(Ks)throw Ks;o({title:"Success",description:"Member details updated successfully"}),He(null),Pa()}catch(Ks){console.error("Error updating member:",Ks),o({title:"Error",description:Ks.message||"Failed to update member",variant:"destructive"})}},pa=async Nt=>{try{const{data:{session:Cs}}=await Z.auth.getSession(),Ks=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Cs==null?void 0:Cs.access_token}`},body:JSON.stringify({userId:Nt})}),dn=await Ks.json();if(!Ks.ok)throw new Error(dn.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Cs){console.error("Error resending welcome email:",Cs),o({title:"Error",description:Cs.message||"Failed to resend welcome email",variant:"destructive"})}},Zi=async(Nt,Cs)=>{try{const{error:Ks}=await Z.functions.invoke("send-password-reset",{body:{email:Nt,redirectTo:window.location.origin}});if(Ks)throw Ks;o({title:"Password Reset Sent",description:`Password reset email sent to ${Cs}`})}catch(Ks){console.error("Error sending password reset:",Ks),o({title:"Error",description:Ks.message||"Failed to send password reset email",variant:"destructive"})}},ci=async(Nt,Cs)=>{if(confirm(`Are you sure you want to delete ${Cs}? This action cannot be undone.`))try{const{data:{session:Ks}}=await Z.auth.getSession(),dn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ks==null?void 0:Ks.access_token}`},body:JSON.stringify({userId:Nt})}),vn=await dn.json();if(!dn.ok)throw new Error(vn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Pa()}catch(Ks){console.error("Error deleting user:",Ks),o({title:"Error",description:Ks.message||"Failed to delete user",variant:"destructive"})}},Xn=async()=>{if(!D.email||!D.name||!D.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(D.role==="brokerage_manager"&&!D.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}E(!0);try{const{data:{session:Nt}}=await Z.auth.getSession(),Cs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Nt==null?void 0:Nt.access_token}`},body:JSON.stringify(D)}),Ks=await Cs.json();if(!Cs.ok)throw new Error(Ks.error||"Failed to create user");if(D.role&&D.role!=="user"&&Ks.userId){const dn=D.role==="brokerage_manager"?D.brokerage_id:void 0;await Yi(Ks.userId,D.role,"add",dn)}o({title:"Success",description:`User ${D.email} created successfully`}),L({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),$(!1),Pa()}catch(Nt){console.error("Error creating user:",Nt),o({title:"Error",description:Nt.message||"Failed to create user",variant:"destructive"})}finally{E(!1)}},Yi=async(Nt,Cs,Ks,dn)=>{try{const{data:{session:vn}}=await Z.auth.getSession(),fa={userId:Nt,role:Cs,action:Ks};if(Cs==="brokerage_manager"){if(!dn){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}fa.brokerageId=dn}const Qn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vn==null?void 0:vn.access_token}`},body:JSON.stringify(fa)}),La=await Qn.json();if(!Qn.ok)throw new Error(La.error||"Failed to manage user role");o({title:"Success",description:`Role ${Ks==="add"?"added":"removed"} successfully`}),Pa()}catch(vn){console.error("Error managing user role:",vn),o({title:"Error",description:vn.message||"Failed to manage user role",variant:"destructive"})}},Ll=(Nt,Cs)=>Cs.length===0?!0:Cs.some(Ks=>Nt.includes(Ks)),Zl=async(Nt,Cs,Ks)=>{const dn=`${Nt}-${Cs.id}`;We(dn);try{if(Ks){const vn=l.find(Qn=>Qn.id===Nt),fa=Cs.required_tags.filter(Qn=>vn==null?void 0:vn.tags.includes(Qn));for(const Qn of fa){const{error:La}=await Z.from("user_tags").delete().eq("user_id",Nt).eq("tag",Qn);if(La)throw La}o({title:"Access Removed",description:`Removed access to ${Cs.name}`})}else if(Cs.required_tags.length>0){const{error:vn}=await Z.from("user_tags").insert({user_id:Nt,tag:Cs.required_tags[0]});if(vn)throw vn;o({title:"Access Granted",description:`Granted access to ${Cs.name}`})}await Pa()}catch(vn){console.error("Error toggling access:",vn),o({title:"Error",description:vn.message||"Failed to update access",variant:"destructive"})}finally{We(null)}},fd=async()=>{const Nt=ke.trim();if(!Nt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(Nt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(f.find(Ks=>Ks.name.toLowerCase()===Nt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}it(!0);try{const{error:Ks}=await Z.from("brokerages").insert({name:Nt});if(Ks)throw Ks;o({title:"Success",description:`Brokerage "${Nt}" created successfully`}),at(""),Ye(!1),Pa()}catch(Ks){console.error("Error creating brokerage:",Ks),o({title:"Error",description:Ks.message||"Failed to create brokerage",variant:"destructive"})}finally{it(!1)}},dp=Nt=>{xt(Nt),qe(Nt.name),tt(!0)},al=()=>{xt(null),qe(""),tt(!1)},nu=async()=>{if(!ut)return;const Nt=_t.trim();if(!Nt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(Nt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Rt(!0);try{const{error:Cs}=await Z.from("brokerages").update({name:Nt}).eq("id",ut.id);if(Cs)throw Cs;o({title:"Success",description:"Brokerage updated successfully"}),al(),Pa()}catch(Cs){console.error("Error updating brokerage:",Cs),o({title:"Error",description:Cs.message||"Failed to update brokerage",variant:"destructive"})}finally{Rt(!1)}},zc=async(Nt,Cs)=>{var Ks;if(!Cs||typeof Cs!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const dn={userId:Nt,role:"brokerage_manager",action:"add",brokerageId:Cs};console.debug("[assignManagerToBrokerage] payload",dn);const{data:{session:vn}}=await Z.auth.getSession(),fa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vn==null?void 0:vn.access_token}`},body:JSON.stringify(dn)}),Qn=await fa.json();if(!fa.ok&&!((Ks=Qn.error)!=null&&Ks.includes("duplicate")))throw new Error(Qn.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Pa()}catch(dn){console.error("Error assigning manager:",dn),o({title:"Error",description:dn.message||"Failed to assign manager",variant:"destructive"})}},Lh=Nt=>{fs(Nt),Xt(!0)},il=async()=>{if(ss){yt(!0);try{const Nt=l.filter(dn=>dn.brokerage_id===ss.id),{data:{session:Cs}}=await Z.auth.getSession();for(const dn of Nt){const vn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Cs==null?void 0:Cs.access_token}`},body:JSON.stringify({userId:dn.id})});if(!vn.ok){const fa=await vn.json();console.error(`Failed to delete user ${dn.email}:`,fa.error)}}const{error:Ks}=await Z.from("brokerages").delete().eq("id",ss.id);if(Ks)throw Ks;o({title:"Success",description:`Brokerage "${ss.name}" and ${Nt.length} member(s) deleted`}),Xt(!1),fs(null),Pa()}catch(Nt){console.error("Error deleting brokerage:",Nt),o({title:"Error",description:Nt.message||"Failed to delete brokerage",variant:"destructive"})}finally{yt(!1)}}},df=Nt=>{na(Nt),go(""),gr(!0)},Lg=()=>{na(null),go(""),gr(!1)},A0=async Nt=>{try{const{error:Cs}=await Z.from("profiles").update({brokerage_id:null}).eq("id",Nt);if(Cs)throw Cs;o({title:"Success",description:"User removed from brokerage"}),Pa()}catch(Cs){console.error("Error removing user from brokerage:",Cs),o({title:"Error",description:Cs.message||"Failed to remove user",variant:"destructive"})}},E0=async(Nt,Cs)=>{try{const{error:Ks}=await Z.from("profiles").update({brokerage_id:Cs}).eq("id",Nt);if(Ks)throw Ks;o({title:"Success",description:"User added to brokerage"}),Pa()}catch(Ks){console.error("Error adding user to brokerage:",Ks),o({title:"Error",description:Ks.message||"Failed to add user",variant:"destructive"})}},I0=async()=>{if(!Br||!Qt.email||!Qt.name||!Qt.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Pr(!0);try{const{data:{session:Nt}}=await Z.auth.getSession(),Cs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Nt==null?void 0:Nt.access_token}`},body:JSON.stringify({...Qt,brokerage_id:Br.id,role:"user"})}),Ks=await Cs.json();if(!Cs.ok)throw new Error(Ks.error||"Failed to create agent");o({title:"Success",description:`Agent ${Qt.email} created successfully`}),lr({email:"",name:"",password:"",phone:""}),nn(!1),Pa()}catch(Nt){console.error("Error creating agent:",Nt),o({title:"Error",description:Nt.message||"Failed to create agent",variant:"destructive"})}finally{Pr(!1)}},ym=Nt=>l.filter(Cs=>Cs.brokerage_id===Nt),Xu=Nt=>{const Cs=ym(Nt);if(!za)return Cs;const Ks=za.toLowerCase();return Cs.filter(dn=>dn.name.toLowerCase().includes(Ks)||dn.email.toLowerCase().includes(Ks))},gd=Nt=>l.filter(Cs=>Cs.brokerage_id!==Nt),ku=l.filter(Nt=>{var Ks;if(V){const dn=V.toLowerCase();if(!(Nt.name.toLowerCase().includes(dn)||Nt.email.toLowerCase().includes(dn)||((Ks=Nt.brokerage_name)==null?void 0:Ks.toLowerCase().includes(dn))))return!1}if(ee==="claimed"&&!Nt.claimed||ee==="unclaimed"&&Nt.claimed||oe!=="all"&&!Nt.roles.includes(oe))return!1;const Cs=Nt.is_trial||Nt.subscription_status==="trialing";return!(ce==="trial"&&!Cs||ce==="non-trial"&&Cs||Te==="none"&&Nt.brokerage_id||Te!=="all"&&Te!=="none"&&Nt.brokerage_id!==Te)}),Bc=ku.length,xd=ne===0,Jo=xd?1:Math.ceil(Bc/ne),Qu=xd?0:(G-1)*ne,vm=xd?Bc:Qu+ne,au=ku.slice(Qu,vm),uf=Nt=>{W(Nt),J(1)},P0=Nt=>{ie(Nt),J(1)},Qx=(Nt,Cs)=>{Nt(Cs),J(1)},hf=async(Nt,Cs)=>{Se(!0);try{const Ks=l.find(Qn=>Qn.id===Nt);if(!Ks)return;const dn=Ks.trial_expires_at?new Date(Ks.trial_expires_at):new Date,vn=new Date(dn.getTime()+Cs*24*60*60*1e3),{error:fa}=await Z.from("profiles").update({trial_expires_at:vn.toISOString()}).eq("id",Nt);if(fa)throw fa;o({title:"Trial Extended",description:`Trial extended by ${Cs} days`}),Pa()}catch(Ks){console.error("Error extending trial:",Ks),o({title:"Error",description:Ks.message||"Failed to extend trial",variant:"destructive"})}finally{Se(!1)}},Dd=async Nt=>{Ae(!0);try{const{error:Cs}=await Z.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",Nt);if(Cs)throw Cs;o({title:"Account Converted",description:"User has been converted to a full account"}),Pa(),Ju()}catch(Cs){console.error("Error converting trial:",Cs),o({title:"Error",description:Cs.message||"Failed to convert account",variant:"destructive"})}finally{Ae(!1)}},L0=async Nt=>{yn(!0);try{const{data:Cs}=await Z.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",Nt);if(Cs&&Cs.length>0){const dn=Cs.map(fa=>fa.assistant_id),{data:vn}=await Z.from("profiles").select("id, name, email").in("id",dn);Dr(Cs.map(fa=>{const Qn=vn==null?void 0:vn.find(La=>La.id===fa.assistant_id);return{id:fa.id,assistant_id:fa.assistant_id,assistant_name:(Qn==null?void 0:Qn.name)||"Unknown",assistant_email:(Qn==null?void 0:Qn.email)||"",permissions:fa.permissions||{}}}))}else Dr([]);const{data:Ks}=await Z.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",Nt);if(Ks&&Ks.length>0){const dn=Ks.map(fa=>fa.agent_id),{data:vn}=await Z.from("profiles").select("id, name, email").in("id",dn);jn(Ks.map(fa=>{const Qn=vn==null?void 0:vn.find(La=>La.id===fa.agent_id);return{id:fa.id,agent_id:fa.agent_id,agent_name:(Qn==null?void 0:Qn.name)||"Unknown",agent_email:(Qn==null?void 0:Qn.email)||"",permissions:fa.permissions||{}}}))}else jn([])}catch(Cs){console.error("Error loading assistant data:",Cs)}finally{yn(!1)}},up=Nt=>{De(Nt),st({name:Nt.name,email:Nt.email,brokerage_id:Nt.brokerage_id||"",phone:Nt.phone||""}),wt(!0),L0(Nt.id)},Ju=()=>{De(null),wt(!1),st({name:"",email:"",brokerage_id:"",phone:""})},fM=async()=>{Ue&&(await Ki(Ue.id),Ju())},DN=Nt=>{_e(Cs=>{const Ks=new Set(Cs);return Ks.has(Nt)?Ks.delete(Nt):Ks.add(Nt),Ks})},Jx=()=>{if(rt.size===au.length&&au.every(Nt=>rt.has(Nt.id))){const Nt=new Set(rt);au.forEach(Cs=>Nt.delete(Cs.id)),_e(Nt)}else{const Nt=new Set(rt);au.forEach(Cs=>Nt.add(Cs.id)),_e(Nt)}},da=()=>{_e(new Set)},D0=async()=>{if(rt.size===0)return;Qe(!0);let Nt=0,Cs=0;try{const{data:{session:Ks}}=await Z.auth.getSession();for(const dn of rt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ks==null?void 0:Ks.access_token}`},body:JSON.stringify({userId:dn})})).ok?Nt++:Cs++}catch{Cs++}o({title:"Bulk Email Complete",description:`Sent ${Nt} emails${Cs>0?`, ${Cs} failed`:""}`}),da()}catch(Ks){o({title:"Error",description:Ks.message||"Failed to send emails",variant:"destructive"})}finally{Qe(!1)}},w_=async()=>{if(rt.size===0)return;Qe(!0);let Nt=0,Cs=0;try{const{data:{session:Ks}}=await Z.auth.getSession();for(const dn of rt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ks==null?void 0:Ks.access_token}`},body:JSON.stringify({userId:dn})})).ok?Nt++:Cs++}catch{Cs++}o({title:"Bulk Password Reset Complete",description:`Sent ${Nt} reset emails${Cs>0?`, ${Cs} failed`:""}`}),da()}catch(Ks){o({title:"Error",description:Ks.message||"Failed to send password reset emails",variant:"destructive"})}finally{Qe(!1)}},ON=async()=>{if(rt.size===0)return;const Nt=l.filter(vn=>rt.has(vn.id)).map(vn=>vn.name).slice(0,5).join(", "),Cs=rt.size>5?` and ${rt.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${rt.size} users (${Nt}${Cs})? This action cannot be undone.`))return;Qe(!0);let Ks=0,dn=0;try{const{data:{session:vn}}=await Z.auth.getSession();for(const fa of rt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vn==null?void 0:vn.access_token}`},body:JSON.stringify({userId:fa})})).ok?Ks++:dn++}catch{dn++}o({title:"Bulk Delete Complete",description:`Deleted ${Ks} users${dn>0?`, ${dn} failed`:""}`}),da(),Pa()}catch(vn){o({title:"Error",description:vn.message||"Failed to delete users",variant:"destructive"})}finally{Qe(!1)}},RN=async()=>{kt(!0);try{const{data:{session:Nt}}=await Z.auth.getSession(),Cs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Nt==null?void 0:Nt.access_token}`}});if(!Cs.ok){const dn=await Cs.json();throw new Error(dn.error||"Failed to sync phones")}const Ks=await Cs.json();o({title:"Phone Sync Complete",description:`Pulled ${Ks.summary.pulledFromGHL} from GHL, pushed ${Ks.summary.pushedToGHL} to GHL, ${Ks.summary.alreadySynced} already synced`}),Pa()}catch(Nt){o({title:"Error",description:Nt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{kt(!1)}},hp=async(Nt,Cs)=>{Zt(Nt);try{const{data:{session:Ks}}=await Z.auth.getSession(),{data:dn}=await Z.from("profiles").select("phone").eq("id",Nt).single(),vn=(dn==null?void 0:dn.phone)||"",fa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ks==null?void 0:Ks.access_token}`},body:JSON.stringify({email:Cs,action:"update",phone:vn||void 0})});if(!fa.ok){const La=await fa.json();throw new Error(La.error||"Failed to sync with GHL")}const Qn=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Cs)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:vn?`Phone ${vn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),Pa()}catch(Ks){o({title:"Error",description:Ks.message||"Failed to sync phone",variant:"destructive"})}finally{Zt(null)}},Dg=async Nt=>{await n(Nt)},ey=()=>{if(rt.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const Nt=l.filter(La=>rt.has(La.id)),Cs=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Ks=Nt.map(La=>[La.name,La.email,La.phone||"",La.brokerage_name||"",La.roles.join("; "),La.claimed?"Claimed":"Unclaimed",new Date(La.created_at).toLocaleDateString()]),dn=[Cs.join(","),...Ks.map(La=>La.map(_m=>`"${(_m||"").replace(/"/g,'""')}"`).join(","))].join(` `),vn=new Blob([dn],{type:"text/csv"}),fa=URL.createObjectURL(vn),Qn=document.createElement("a");Qn.href=fa,Qn.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Qn.click(),URL.revokeObjectURL(fa),o({title:"Export complete",description:`Exported ${Nt.length} member(s)`})};return j?e.jsx(Vs,{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(Vs,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{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(Y,{size:"sm",variant:"outline",onClick:RN,disabled:Tt,children:[Tt?e.jsx(Us,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Ha,{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(Y,{size:"sm",variant:"outline",onClick:()=>cs(!0),children:[e.jsx(Qy,{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(js,{open:B,onOpenChange:$,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{size:"sm",children:[e.jsx(Zc,{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(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Create New User"}),e.jsx(en,{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(je,{htmlFor:"name",children:"Name"}),e.jsx(Be,{id:"name",placeholder:"John Doe",value:D.name,onChange:Nt=>L({...D,name:Nt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"email",children:"Email"}),e.jsx(Be,{id:"email",type:"email",placeholder:"john@example.com",value:D.email,onChange:Nt=>L({...D,email:Nt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"password",children:"Password"}),e.jsx(Be,{id:"password",type:"password",placeholder:"Min 6 characters",value:D.password,onChange:Nt=>L({...D,password:Nt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Be,{id:"phone",type:"tel",placeholder:"555-123-4567",value:D.phone,onChange:Nt=>L({...D,phone:Nt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{htmlFor:"brokerage",children:["Brokerage",D.role==="brokerage_manager"?" (required)":""]}),e.jsxs(er,{value:D.brokerage_id||"none",onValueChange:Nt=>L({...D,brokerage_id:Nt==="none"?"":Nt}),children:[e.jsx(Qs,{id:"brokerage",children:e.jsx(tr,{placeholder:D.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"None"}),f.map(Nt=>e.jsx(Et,{value:Nt.id,children:Nt.name},Nt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"role",children:"Role"}),e.jsxs(er,{value:D.role,onValueChange:Nt=>L({...D,role:Nt}),children:[e.jsx(Qs,{id:"role",children:e.jsx(tr,{placeholder:"Select role"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"user",children:"User"}),e.jsx(Et,{value:"moderator",children:"Moderator"}),e.jsx(Et,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(Et,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(er,{value:D.trial_days||"none",onValueChange:Nt=>L({...D,trial_days:Nt==="none"?"":Nt}),children:[e.jsx(Qs,{id:"trial_days",children:e.jsx(tr,{placeholder:"No trial (full access)"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No trial (full access)"}),e.jsx(Et,{value:"7",children:"7-day trial"}),e.jsx(Et,{value:"30",children:"30-day trial"}),e.jsx(Et,{value:"60",children:"60-day trial"}),e.jsx(Et,{value:"90",children:"90-day trial"}),e.jsx(Et,{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(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(Y,{onClick:Xn,disabled:S,children:S?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(Qa,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"members",children:"Members"}),e.jsx(Fs,{value:"brokerages",children:"Brokerages"}),e.jsx(Fs,{value:"teams",children:"Teams"}),e.jsx(Fs,{value:"trials",children:"Trial Users"}),e.jsx(Fs,{value:"access",children:"Access Matrix"}),e.jsx(Fs,{value:"celebrations",children:"Celebrations"}),e.jsx(Fs,{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(On,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search members...",value:V,onChange:Nt=>uf(Nt.target.value),className:"pl-10 h-9"})]}),e.jsxs(er,{value:ee,onValueChange:Nt=>Qx(de,Nt),children:[e.jsx(Qs,{className:"w-[130px] h-9",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Status"}),e.jsx(Et,{value:"claimed",children:"Active"}),e.jsx(Et,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(er,{value:oe,onValueChange:Nt=>Qx(ue,Nt),children:[e.jsx(Qs,{className:"w-[130px] h-9",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Roles"}),e.jsx(Et,{value:"admin",children:"Admin"}),e.jsx(Et,{value:"brokerage_manager",children:"Manager"}),e.jsx(Et,{value:"assistant",children:"Assistant"}),e.jsx(Et,{value:"user",children:"User"})]})]}),e.jsxs(er,{value:ce,onValueChange:Nt=>Qx(ge,Nt),children:[e.jsx(Qs,{className:"w-[130px] h-9",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Users"}),e.jsx(Et,{value:"trial",children:"Trial Only"}),e.jsx(Et,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(er,{value:Te,onValueChange:Nt=>Qx(ve,Nt),children:[e.jsx(Qs,{className:"w-[150px] h-9",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Brokerages"}),e.jsx(Et,{value:"none",children:"No Brokerage"}),f.map(Nt=>e.jsx(Et,{value:Nt.id,children:Nt.name},Nt.id))]})]}),(V||ee!=="all"||oe!=="all"||ce!=="all"||Te!=="all")&&e.jsxs(Y,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{W(""),de("all"),ue("all"),ge("all"),ve("all"),J(1)},children:[e.jsx(Xr,{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:xd?`Showing all ${Bc} members`:`Showing ${Qu+1}-${Math.min(vm,Bc)} of ${Bc} members`}),e.jsxs(er,{value:ne.toString(),onValueChange:Nt=>P0(Number(Nt)),children:[e.jsx(Qs,{className:"h-9 w-[110px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"50",children:"50 / page"}),e.jsx(Et,{value:"100",children:"100 / page"}),e.jsx(Et,{value:"250",children:"250 / page"}),e.jsx(Et,{value:"0",children:"All"})]})]})]})]}),rt.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(Oy,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[rt.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Y,{size:"sm",variant:"outline",onClick:D0,disabled:Pe,children:[Pe?e.jsx(Us,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(zr,{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(Y,{size:"sm",variant:"outline",onClick:w_,disabled:Pe,children:[Pe?e.jsx(Us,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Xm,{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(Y,{size:"sm",variant:"outline",onClick:ey,children:[e.jsx(Vi,{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(Y,{size:"sm",variant:"destructive",onClick:ON,disabled:Pe,children:[Pe?e.jsx(Us,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Ir,{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(Y,{size:"sm",variant:"ghost",onClick:da,disabled:Pe,children:e.jsx(Xr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Ct,{className:"w-[50px]",children:e.jsx(Do,{checked:au.length>0&&au.every(Nt=>rt.has(Nt.id)),onCheckedChange:Jx,"aria-label":"Select all on page"})}),e.jsx(Ct,{className:"font-semibold",children:"Name"}),e.jsx(Ct,{className:"font-semibold",children:"Brokerage"}),e.jsx(Ct,{className:"font-semibold",children:"Status"}),e.jsx(Ct,{className:"font-semibold",children:"Role"}),e.jsx(Ct,{className:"font-semibold",children:"Last Login"}),e.jsx(Ct,{className:"w-[100px]"})]})}),e.jsx(Bn,{children:au.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:7,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):au.map(Nt=>e.jsxs(ws,{className:`hover:bg-muted/30 ${rt.has(Nt.id)?"bg-primary/5":""}`,children:[e.jsx(ot,{children:e.jsx(Do,{checked:rt.has(Nt.id),onCheckedChange:()=>DN(Nt.id),"aria-label":`Select ${Nt.name}`})}),e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>up(Nt),className:"text-primary hover:underline font-medium text-left",children:Nt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Nt.email})]})}),e.jsx(ot,{className:"text-muted-foreground",children:Nt.brokerage_name||"—"}),e.jsx(ot,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(ct,{variant:Nt.claimed?"default":"secondary",className:Nt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:Nt.claimed?"Active":"Pending"}),Nt.is_trial&&Nt.trial_expires_at&&e.jsx(u8,{expiresAt:Nt.trial_expires_at,className:"w-fit"}),!Nt.is_trial&&Nt.subscription_status==="trialing"&&Nt.subscription_end_date&&e.jsx(u8,{expiresAt:Nt.subscription_end_date,className:"w-fit"})]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[Nt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:Nt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),Nt.roles.includes("assistant")&&e.jsxs(ct,{variant:"outline",className:"text-[10px] ml-1",children:["Asst",aa[Nt.id]?` → ${aa[Nt.id].agent_name||aa[Nt.id].agent_email}`:""]})]})}),e.jsx(ot,{className:"text-muted-foreground",children:Nt.last_sign_in_at?new Date(Nt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(ot,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{ps(Nt),Jt(!0)},title:"Send celebration",children:e.jsx(md,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>up(Nt),title:"Edit member",children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>hp(Nt.id,Nt.email),disabled:Dt===Nt.id,title:"Sync phone with GHL",children:Dt===Nt.id?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(Ha,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>pa(Nt.id),title:"Resend welcome email",children:e.jsx(zr,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Zi(Nt.email,Nt.name),title:"Send password reset",children:e.jsx(kk,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>Dg(Nt.id),disabled:a||Nt.id===(s==null?void 0:s.id),title:Nt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${Nt.name}`,children:a?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(R4,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>ci(Nt.id,Nt.name),title:"Delete user",children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},Nt.id))})]})}),Jo>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 ",G," of ",Jo]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>J(1),disabled:G===1,children:"First"}),e.jsx(Y,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>J(Nt=>Math.max(1,Nt-1)),disabled:G===1,children:e.jsx(hc,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Jo)},(Nt,Cs)=>{let Ks;return Jo<=5||G<=3?Ks=Cs+1:G>=Jo-2?Ks=Jo-4+Cs:Ks=G-2+Cs,e.jsx(Y,{variant:G===Ks?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>J(Ks),children:Ks},Ks)})}),e.jsx(Y,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>J(Nt=>Math.min(Jo,Nt+1)),disabled:G===Jo,children:e.jsx(Ri,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>J(Jo),disabled:G===Jo,children:"Last"})]})]})]}),e.jsx(js,{open:Ge,onOpenChange:wt,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Edit Member"}),e.jsx(en,{children:"Update member details, roles, and app access"})]}),Ue&&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(je,{htmlFor:"edit-name",children:"Name"}),e.jsx(Be,{id:"edit-name",value:Ie.name,onChange:Nt=>st({...Ie,name:Nt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"edit-email",children:"Email"}),e.jsx(Be,{id:"edit-email",type:"email",value:Ie.email,onChange:Nt=>st({...Ie,email:Nt.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(je,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Be,{id:"edit-phone",type:"tel",value:Ie.phone,onChange:Nt=>st({...Ie,phone:Nt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(er,{value:Ie.brokerage_id||"none",onValueChange:Nt=>st({...Ie,brokerage_id:Nt==="none"?"":Nt}),children:[e.jsx(Qs,{id:"edit-brokerage",children:e.jsx(tr,{placeholder:"Select brokerage"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"None"}),f.map(Nt=>e.jsx(Et,{value:Nt.id,children:Nt.name},Nt.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:[Ue.roles.map(Nt=>e.jsxs(ct,{variant:"default",className:"gap-1",children:[e.jsx(Bu,{className:"h-3 w-3"}),Nt,Nt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>Yi(Ue.id,Nt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Xr,{className:"h-3 w-3"})})]},Nt)),Ue.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(er,{onValueChange:Nt=>Yi(Ue.id,Nt,"add"),children:[e.jsx(Qs,{className:"w-[200px]",children:e.jsx(tr,{placeholder:"Add role..."})}),e.jsxs(Js,{children:[!Ue.roles.includes("admin")&&e.jsx(Et,{value:"admin",children:"Admin"}),!Ue.roles.includes("user")&&e.jsx(Et,{value:"user",children:"User"})]})]}),!Ue.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"})]}),(ur.length>0||cr.length>0||Ue.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(br,{className:"h-4 w-4"}),"Assistant Relationships"]}),kn?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Us,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[ur.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Has assistants:"}),ur.map(Nt=>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:Nt.assistant_name}),e.jsx(ct,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Nt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(Nt.permissions).filter(([,Cs])=>Cs).map(([Cs])=>e.jsx(ct,{variant:"secondary",className:"text-[10px] capitalize",children:Cs},Cs))})]},Nt.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(Nt=>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:Nt.agent_name}),e.jsx(ct,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Nt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(Nt.permissions).filter(([,Cs])=>Cs).map(([Cs])=>e.jsx(ct,{variant:"secondary",className:"text-[10px] capitalize",children:Cs},Cs))})]},Nt.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(Nt=>{const Cs=Ll(Ue.tags,Nt.required_tags),Ks=`${Ue.id}-${Nt.id}`,dn=he===Ks,vn=Nt.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:Nt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:Nt.name}),vn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:dn?e.jsx(Us,{className:"h-4 w-4 animate-spin text-muted-foreground"}):vn?e.jsx(ct,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(ln,{checked:Cs,onCheckedChange:()=>Zl(Ue.id,Nt,Cs)})})]},Nt.id)})})]}),(Ue.is_trial||Ue.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(ca,{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:[Ue.trial_expires_at&&e.jsx(u8,{expiresAt:Ue.trial_expires_at}),!Ue.trial_expires_at&&Ue.subscription_status==="trialing"&&Ue.subscription_end_date&&e.jsx(u8,{expiresAt:Ue.subscription_end_date})]}),(Ue.trial_expires_at||Ue.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Ue.trial_expires_at||Ue.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>hf(Ue.id,7),disabled:ye,children:[e.jsx(N1,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>hf(Ue.id,14),disabled:ye,children:[e.jsx(N1,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>hf(Ue.id,30),disabled:ye,children:[e.jsx(N1,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(Y,{size:"sm",variant:"default",onClick:()=>Dd(Ue.id),disabled:Ke,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Lk,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Ue.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Ue.trial_started_at).toLocaleDateString(),Ue.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Ue.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:[Ue.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Ue.email_confirmed_at).toLocaleString()]}),Ue.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Ue.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Ue.created_at).toLocaleString()]})]})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:Ju,children:"Cancel"}),e.jsx(Y,{onClick:fM,children:"Save Changes"})]})]})}),e.jsxs(Zs,{value:"access",children:[d.length===0?e.jsx(Oe,{children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(Y,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Member Access Matrix"}),e.jsx(Tr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs($e,{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(Nt=>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:Nt.icon}),e.jsx("span",{className:"text-sm",children:Nt.name})]})},Nt.id))]})}),e.jsxs("tbody",{children:[au.map(Nt=>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:Nt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Nt.email})]})}),d.map(Cs=>{const Ks=Ll(Nt.tags,Cs.required_tags),dn=`${Nt.id}-${Cs.id}`,vn=he===dn;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:vn?e.jsx(Us,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(ln,{checked:Ks,onCheckedChange:()=>Zl(Nt.id,Cs,Ks),disabled:Cs.required_tags.length===0})})},Cs.id)})]},Nt.id)),au.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"})})]})]})}),Jo>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 ",Qu+1,"-",Math.min(vm,Bc)," of ",Bc," • Page ",G," of ",Jo]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Y,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>J(Nt=>Math.max(1,Nt-1)),disabled:G===1,children:e.jsx(hc,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>J(Nt=>Math.min(Jo,Nt+1)),disabled:G===Jo,children:e.jsx(Ri,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(Y,{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(On,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search brokerages...",value:ka,onChange:Nt=>zi(Nt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[f.filter(Nt=>Nt.name.toLowerCase().includes(ka.toLowerCase())).length," of ",f.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>{const Nt=[];for(const Qn of f){const La=v[Qn.id]??[];for(const _m of La){const Nu=l.find(Yl=>Yl.id===_m);if(Nu){const Yl=(Nu.name||"").trim().split(/\s+/),Da=Yl[0]||"",FN=Yl.slice(1).join(" ")||"";Nt.push({firstName:Da,lastName:FN,email:Nu.email,brokerageName:Qn.name})}}}if(Nt.length===0){o({title:"No managers found to export"});return}const Ks=[["First Name","Last Name","Email","Brokerage Name"].join(","),...Nt.map(Qn=>[Qn.firstName,Qn.lastName,Qn.email,Qn.brokerageName].map(La=>`"${(La||"").replace(/"/g,'""')}"`).join(","))].join(` `),dn=new Blob([Ks],{type:"text/csv"}),vn=URL.createObjectURL(dn),fa=document.createElement("a");fa.href=vn,fa.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,fa.click(),URL.revokeObjectURL(vn),o({title:`Exported ${Nt.length} managers`})},children:[e.jsx(Vi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(js,{open:et,onOpenChange:Ye,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{size:"sm",children:[e.jsx(Ya,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Create New Brokerage"}),e.jsx(en,{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(je,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Be,{id:"brokerage-name",placeholder:"Enter brokerage name",value:ke,onChange:Nt=>at(Nt.target.value),maxLength:100})]})}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>Ye(!1),children:"Cancel"}),e.jsx(Y,{onClick:fd,disabled:Fe,children:Fe?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Ct,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(Ct,{className:"font-semibold",children:"Manager(s)"}),e.jsx(Ct,{className:"font-semibold",children:"Agents"}),e.jsx(Ct,{className:"w-[150px]"})]})}),e.jsx(Bn,{children:(()=>{const Nt=f.filter(Cs=>Cs.name.toLowerCase().includes(ka.toLowerCase()));return Nt.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:ka?"No brokerages match your search":"No brokerages found"})}):Nt.map(Cs=>{const Ks=l.filter(Qn=>Qn.brokerage_id===Cs.id),vn=(v[Cs.id]??[]).map(Qn=>l.find(La=>La.id===Qn)).filter(Boolean),fa=Ks.length;return e.jsxs(ws,{className:"hover:bg-muted/30",children:[e.jsx(ot,{children:e.jsx("button",{onClick:()=>dp(Cs),className:"text-primary hover:underline font-medium",children:Cs.name})}),e.jsx(ot,{children:vn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:vn.map(Qn=>e.jsx(ct,{variant:"secondary",className:"text-xs",children:Qn.name},Qn.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(ot,{children:[fa," member",fa!==1?"s":""]}),e.jsx(ot,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(Y,{size:"sm",variant:"outline",className:"h-8",onClick:()=>df(Cs),children:[e.jsx(br,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>dp(Cs),title:"Edit brokerage",children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Lh(Cs),title:"Delete brokerage",children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},Cs.id)})})()})]})}),e.jsx(js,{open:dt,onOpenChange:tt,children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Edit Brokerage"}),e.jsx(en,{children:"Update brokerage details and manage managers"})]}),ut&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(Be,{id:"edit-brokerage-name",value:_t,onChange:Nt=>qe(Nt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{children:"Managers"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click × to remove manager access for this brokerage (keeps them as a member)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(()=>{const Cs=(v[ut.id]??[]).map(Ks=>l.find(dn=>dn.id===Ks)).filter(Boolean);return Cs.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Cs.map(Ks=>e.jsxs(ct,{variant:"default",className:"gap-1",children:[e.jsx(Bu,{className:"h-3 w-3"}),Ks.name,e.jsx("button",{onClick:()=>Yi(Ks.id,"brokerage_manager","remove",ut.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Xr,{className:"h-3 w-3"})})]},Ks.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(_l,{open:li,onOpenChange:Or,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":li,className:"w-full justify-between",children:["Search for a member...",e.jsx(On,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(nl,{className:"w-full p-0",align:"start",children:e.jsxs(wg,{children:[e.jsx(jg,{placeholder:"Search by name or email..."}),e.jsxs(kg,{className:"max-h-[200px]",children:[e.jsx(Ng,{children:"No members found."}),e.jsx(Sg,{children:(()=>{const Nt=new Set(v[ut.id]??[]);return l.filter(Cs=>!Nt.has(Cs.id)&&(r||Cs.brokerage_id===ut.id)).map(Cs=>e.jsxs(Vm,{value:`${Cs.name} ${Cs.email}`,onSelect:()=>{zc(Cs.id,ut.id),Or(!1)},children:[Cs.name," (",Cs.email,")"]},Cs.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(Nt=>Nt.brokerage_id===ut.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(Nt=>Nt.brokerage_id===ut.id).map(Nt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:Nt.name}),Nt.roles.includes("brokerage_manager")&&e.jsx(ct,{variant:"outline",className:"text-xs",children:"Manager"})]},Nt.id))})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:al,children:"Cancel"}),e.jsx(Y,{onClick:nu,disabled:Lt,children:Lt?"Saving...":"Save Changes"})]})]})}),e.jsx(js,{open:Kt,onOpenChange:Xt,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(en,{children:['Are you sure you want to delete "',ss==null?void 0:ss.name,'"?']})]}),e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Warning: This action cannot be undone!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This will permanently delete:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground list-disc list-inside",children:[e.jsxs("li",{children:['The brokerage "',ss==null?void 0:ss.name,'"']}),e.jsxs("li",{children:["All ",l.filter(Nt=>Nt.brokerage_id===(ss==null?void 0:ss.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>Xt(!1),children:"Cancel"}),e.jsx(Y,{variant:"destructive",onClick:il,disabled:fr,children:fr?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(js,{open:bs,onOpenChange:gr,children:e.jsxs(_s,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(Ya,{className:"h-5 w-5"}),"Manage ",Br==null?void 0:Br.name]}),e.jsx(en,{children:"Add, remove, or manage users in this brokerage"})]}),Br&&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(On,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search members...",value:za,onChange:Nt=>go(Nt.target.value),className:"pl-10 h-9"})]}),e.jsxs(js,{open:Ia,onOpenChange:nn,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{size:"sm",children:[e.jsx(Zc,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Add New Agent"}),e.jsxs(en,{children:["Create a new agent for ",Br.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"agent-name",children:"Name"}),e.jsx(Be,{id:"agent-name",placeholder:"John Doe",value:Qt.name,onChange:Nt=>lr({...Qt,name:Nt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"agent-email",children:"Email"}),e.jsx(Be,{id:"agent-email",type:"email",placeholder:"john@example.com",value:Qt.email,onChange:Nt=>lr({...Qt,email:Nt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"agent-password",children:"Password"}),e.jsx(Be,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:Qt.password,onChange:Nt=>lr({...Qt,password:Nt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(Be,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:Qt.phone,onChange:Nt=>lr({...Qt,phone:Nt.target.value})})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>nn(!1),children:"Cancel"}),e.jsx(Y,{onClick:I0,disabled:Vr,children:Vr?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(_l,{open:Oi,onOpenChange:Rc,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":Oi,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(On,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(nl,{className:"w-[300px] p-0",align:"start",children:e.jsxs(wg,{children:[e.jsx(jg,{placeholder:"Search users...",value:Co,onValueChange:Fc}),e.jsxs(kg,{children:[e.jsx(Ng,{children:"No users found."}),e.jsx(Sg,{children:gd(Br.id).filter(Nt=>Co===""||Nt.name.toLowerCase().includes(Co.toLowerCase())||Nt.email.toLowerCase().includes(Co.toLowerCase())).map(Nt=>e.jsxs(Vm,{value:`${Nt.name} ${Nt.email}`,onSelect:()=>{E0(Nt.id,Br.id),Rc(!1),Fc("")},children:[Nt.name," (",Nt.email,")"]},Nt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Ct,{className:"font-semibold",children:"Name"}),e.jsx(Ct,{className:"font-semibold",children:"Email"}),e.jsx(Ct,{className:"font-semibold",children:"Status"}),e.jsx(Ct,{className:"font-semibold",children:"Role"}),e.jsx(Ct,{className:"w-[120px]"})]})}),e.jsx(Bn,{children:Xu(Br.id).length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:za?"No matching members found":"No members in this brokerage"})}):Xu(Br.id).map(Nt=>e.jsxs(ws,{className:"hover:bg-muted/30",children:[e.jsx(ot,{className:"font-medium",children:Nt.name}),e.jsx(ot,{className:"text-muted-foreground",children:Nt.email}),e.jsx(ot,{children:Nt.claimed?e.jsx(ct,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(ct,{variant:"secondary",children:"Pending"})}),e.jsx(ot,{children:Nt.roles.includes("brokerage_manager")?e.jsxs(ct,{variant:"outline",className:"gap-1",children:[e.jsx(Bu,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!Nt.claimed&&e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>pa(Nt.id),title:"Resend welcome email",children:e.jsx(zr,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>A0(Nt.id),title:"Remove from brokerage",children:e.jsx(Xr,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>Dg(Nt.id),disabled:a||Nt.id===(s==null?void 0:s.id),title:Nt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${Nt.name}`,children:a?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(R4,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>ci(Nt.id,Nt.name),title:"Delete user",children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},Nt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[ym(Br.id).length," total member",ym(Br.id).length!==1?"s":""," •",ym(Br.id).filter(Nt=>Nt.roles.includes("brokerage_manager")).length," manager",ym(Br.id).filter(Nt=>Nt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(Hn,{children:e.jsx(Y,{variant:"outline",onClick:Lg,children:"Close"})})]})})]}),e.jsx(Zs,{value:"teams",children:e.jsx(eEt,{})}),e.jsx(Zs,{value:"trials",children:e.jsx(YAt,{})}),e.jsx(Zs,{value:"celebrations",children:e.jsx(ZAt,{})}),e.jsx(Zs,{value:"deletions",children:e.jsx(XAt,{})})]})]}),e.jsx(KVe,{open:on,onOpenChange:cs,brokerages:f,onSuccess:Pa}),Ss&&e.jsx(ZVe,{open:Ft,onOpenChange:Nt=>{Jt(Nt),Nt||ps(null)},userId:Ss.id,userName:Ss.name})]})},sEt=()=>{const[t,s]=T.useState([]),[r,n]=T.useState(!0),[a,o]=T.useState(!1),[l,i]=T.useState(""),[d,h]=T.useState(""),[f,g]=T.useState(""),[v,_]=T.useState("");T.useEffect(()=>{j()},[]);const j=async()=>{const{data:L,error:B}=await Z.from("invite_codes").select("*").order("created_at",{ascending:!1});B?(be.error("Failed to load invite codes"),console.error(B)):s(L||[]),n(!1)},w=async L=>{if(L.preventDefault(),!l.trim()){be.error("Please enter a code");return}o(!0);const{error:B}=await Z.from("invite_codes").insert({code:l.trim().toUpperCase(),description:d.trim()||null,max_uses:f?parseInt(f):null,trial_days:v?parseInt(v):null});B?B.code==="23505"?be.error("This code already exists"):(be.error("Failed to create invite code"),console.error(B)):(be.success("Invite code created"),i(""),h(""),g(""),_(""),j()),o(!1)},k=async(L,B)=>{const{error:$}=await Z.from("invite_codes").update({is_active:!B}).eq("id",L);$?be.error("Failed to update code"):s(t.map(V=>V.id===L?{...V,is_active:!B}:V))},M=async L=>{const{error:B}=await Z.from("invite_codes").delete().eq("id",L);B?be.error("Failed to delete code"):(be.success("Code deleted"),s(t.filter($=>$.id!==L)))},S="https://dashboard.relevelup.com",E=L=>{const B=`${S}/join?code=${L}`;navigator.clipboard.writeText(B),be.success("Link copied to clipboard")},D=`${S}/join`;return e.jsx(Vs,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Create New Code"}),e.jsxs(Tr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:D})]})]}),e.jsx($e,{children:e.jsxs("form",{onSubmit:w,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"code",children:"Code"}),e.jsx(Be,{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(je,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Be,{id:"description",placeholder:"For marketing campaign",value:d,onChange:L=>h(L.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(Be,{id:"maxUses",type:"number",placeholder:"Unlimited",value:f,onChange:L=>g(L.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(Be,{id:"trialDays",type:"number",placeholder:"None",value:v,onChange:L=>_(L.target.value),className:"w-28"})]}),e.jsxs(Y,{type:"submit",disabled:a,children:[a?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Active Codes"})}),e.jsx($e,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Us,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Code"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{children:"Uses"}),e.jsx(Ct,{children:"Trial"}),e.jsx(Ct,{children:"Created"}),e.jsx(Ct,{children:"Active"}),e.jsx(Ct,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(L=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-mono font-medium",children:L.code}),e.jsx(ot,{className:"text-muted-foreground",children:L.description||"—"}),e.jsxs(ot,{children:[L.uses_count,L.max_uses&&` / ${L.max_uses}`]}),e.jsx(ot,{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(ot,{className:"text-muted-foreground",children:Bs(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(ot,{children:e.jsx(ln,{checked:L.is_active,onCheckedChange:()=>k(L.id,L.is_active)})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>E(L.code),title:"Copy invite link",children:e.jsx(Di,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>M(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},Q6=async t=>{try{const{data:s,error:r}=await Z.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}},K3=async t=>{try{const{data:s,error:r}=await Z.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}}},rEt=async(t,s)=>await Q6("new_templates")?K3({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}),nEt=async(t,s)=>K3({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),aEt=async(t,s)=>await Q6("new_events")?K3({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),iEt=async(t,s)=>await Q6("new_toolbox")?K3({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),Bge=async(t,s)=>await Q6("new_social_swag")?K3({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}),oEt=async(t,s)=>await Q6("new_newsletters")?K3({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),h8={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 lEt(){const t=Yr(),s=vs(),[r,n]=T.useState(!1),[a,o]=T.useState(null),[l,i]=T.useState(h8),[d,h]=T.useState(null),[f,g]=T.useState(null),[v,_]=T.useState(!1),j=T.useRef(null),[w,k]=T.useState(!1),[M,S]=T.useState(null),[E,D]=T.useState(!1),[L,B]=T.useState(null),[$,V]=T.useState(null),[W,G]=T.useState(!0),[J,ne]=T.useState(""),{data:ie,isLoading:ee}=zt({queryKey:["admin-events"],queryFn:async()=>{const{data:ke,error:at}=await Z.from("events").select("*").order("event_date",{ascending:!0});if(at)throw at;return ke}}),{data:de}=zt({queryKey:["event-registrations-count"],queryFn:async()=>{const{data:ke,error:at}=await Z.from("event_registrations").select("event_id");if(at)throw at;const Fe={};return ke.forEach(it=>{Fe[it.event_id]=(Fe[it.event_id]||0)+1}),Fe}}),{data:oe,isLoading:ue}=zt({queryKey:["event-registrations-details",M==null?void 0:M.id],queryFn:async()=>{if(!M)return[];const{data:ke,error:at}=await Z.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",M.id).order("registered_at",{ascending:!1});if(at)throw at;if(!ke||ke.length===0)return[];const Fe=ke.map(tt=>tt.user_id).filter(Boolean);let it=[];if(Fe.length>0){const{data:tt,error:ut}=await Z.from("profiles").select("id, name, email").in("id",Fe);if(ut)throw ut;it=tt||[]}const dt=new Map((it==null?void 0:it.map(tt=>[tt.id,tt]))||[]);return ke.map(tt=>({...tt,profiles:tt.user_id&&dt.get(tt.user_id)||null}))},enabled:!!M}),{data:ce,isLoading:ge}=zt({queryKey:["event-attendees-details",M==null?void 0:M.id],queryFn:async()=>{if(!M)return[];const{data:ke,error:at}=await Z.from("event_attendees").select("id, user_id, zoom_email, zoom_name, join_time, leave_time, duration_minutes, manually_added, created_at").eq("event_id",M.id).order("created_at",{ascending:!1});if(at)throw at;if(!ke||ke.length===0)return[];const Fe=ke.map(xt=>xt.user_id).filter(Boolean);let it=[];if(Fe.length>0){const{data:xt,error:_t}=await Z.from("profiles").select("id, name, email").in("id",Fe);if(_t)throw _t;it=xt||[]}const{data:dt}=await Z.from("agent_points").select("user_id").eq("event_id",M.id),tt=new Set((dt==null?void 0:dt.map(xt=>xt.user_id))||[]),ut=new Map((it==null?void 0:it.map(xt=>[xt.id,xt]))||[]);return ke.map(xt=>({...xt,profiles:xt.user_id&&ut.get(xt.user_id)||null,points_awarded:xt.user_id?tt.has(xt.user_id):!1}))},enabled:!!M}),Te=ke=>{S(ke),k(!0)},ve=Wt({mutationFn:async ke=>{const{data:{session:at}}=await Z.auth.getSession();if(!at)throw new Error("Not authenticated");const Fe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${at.access_token}`},body:JSON.stringify({event_id:ke})}),it=await Fe.json();if(!Fe.ok)throw new Error(it.error||"Failed to sync");return it},onSuccess:ke=>{s.invalidateQueries({queryKey:["event-registrations-details",M==null?void 0:M.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),be.success(ke.message)},onError:ke=>{be.error("Failed to sync: "+ke.message)}}),ye=Wt({mutationFn:async ke=>{const{data:{session:at}}=await Z.auth.getSession();if(!at)throw new Error("Not authenticated");const Fe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${at.access_token}`},body:JSON.stringify({event_id:ke})}),it=await Fe.json();if(!Fe.ok)throw new Error(it.error||"Failed to sync attendees");return it},onSuccess:ke=>{s.invalidateQueries({queryKey:["event-attendees-details",M==null?void 0:M.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),ke!=null&&ke.message?be.success(ke.message):be.success(`Synced ${ke.synced||0} attendees. ${ke.points_awarded||0} points awarded!`)},onError:ke=>{be.error("Failed to sync attendees: "+ke.message)}}),Se=Wt({mutationFn:async({eventId:ke,testMode:at})=>{const{data:{session:Fe}}=await Z.auth.getSession();if(!Fe)throw new Error("Not authenticated");const it=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Fe.access_token}`},body:JSON.stringify({event_id:ke,test_mode:at})}),dt=await it.json();if(!it.ok)throw new Error(dt.error||"Failed to send reminders");return dt},onSuccess:ke=>{ke.test?be.success(ke.message||"Test email sent!"):be.success(ke.message||`Reminder emails sent to ${ke.sent} registrants!`)},onError:ke=>{be.error("Failed to send reminders: "+ke.message)}}),{data:Ke}=zt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let ke=[],at=0;const Fe=1e3;for(;;){const{data:it,error:dt}=await Z.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(at,at+Fe-1);if(dt)throw dt;if(!it||it.length===0||(ke=[...ke,...it],it.length{const{error:dt}=await Z.from("event_attendees").update({user_id:at}).eq("id",ke);if(dt)throw dt;if(it&&Fe){const{error:ut}=await Z.from("zoom_email_aliases").upsert({user_id:at,zoom_email:Fe.toLowerCase()},{onConflict:"zoom_email"});ut&&console.error("Failed to save alias:",ut)}const tt=M==null?void 0:M.id;if(tt){const{data:ut}=await Z.from("user_roles").select("id").eq("user_id",at).eq("role","admin").single();if(!ut){const{data:xt}=await Z.from("agent_points").select("id").eq("user_id",at).eq("event_id",tt).single();xt||(await Z.rpc("award_attendance_points",{p_user_id:at,p_event_id:tt,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await Z.rpc("check_and_award_badges",{p_user_id:at}))}}return{userId:at,zoomEmail:Fe,shouldSaveAlias:it}},onSuccess:ke=>{s.invalidateQueries({queryKey:["event-attendees-details",M==null?void 0:M.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let at="Attendee linked and points awarded!";ke.shouldSaveAlias&&ke.zoomEmail&&(at+=` Email "${ke.zoomEmail}" will be auto-matched in the future.`),be.success(at),D(!1),B(null),V(null),ne("")},onError:ke=>{be.error("Failed to link attendee: "+ke.message)}}),Ee=ke=>{B(ke),V(null),G(!0),ne(""),D(!0)},He=()=>{!L||!$||Ae.mutate({attendeeId:L.id,userId:$,zoomEmail:L.zoom_email,shouldSaveAlias:W})},Ue=(Ke==null?void 0:Ke.filter(ke=>{var Fe,it;if(!J)return!0;const at=J.toLowerCase();return((Fe=ke.name)==null?void 0:Fe.toLowerCase().includes(at))||((it=ke.email)==null?void 0:it.toLowerCase().includes(at))}))||[],De=async ke=>{const at=ke.name.split(".").pop(),it=`${`${crypto.randomUUID()}.${at}`}`,{error:dt}=await Z.storage.from("event-images").upload(it,ke);if(dt)throw dt;const{data:{publicUrl:tt}}=Z.storage.from("event-images").getPublicUrl(it);return tt},Ge=ke=>{var Fe;const at=(Fe=ke.target.files)==null?void 0:Fe[0];if(at){if(at.size>5*1024*1024){be.error("Image must be less than 5MB");return}h(at),g(URL.createObjectURL(at))}},wt=()=>{h(null),g(null),i({...l,image_url:""}),j.current&&(j.current.value="")},Ie=Wt({mutationFn:async ke=>{_(!0);let at=ke.image_url;d&&(at=await De(d)||"");const Fe=new Date(ke.event_date),[it,dt]=ke.event_time.split(":");Fe.setHours(parseInt(it),parseInt(dt));const tt=[new Date(Fe)];if(ke.is_recurring&&ke.recurrence_end_date){let qe=new Date(Fe);for(;ke.recurrence_pattern==="weekly"?qe=Gj(qe,1):ke.recurrence_pattern==="biweekly"?qe=Gj(qe,2):qe=Ch(qe,1),!(qe>ke.recurrence_end_date);)tt.push(new Date(qe))}const ut=tt.map(qe=>({title:ke.title,description:ke.description||null,image_url:at||null,video_url:ke.video_url||null,event_date:qe.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:xt,error:_t}=await Z.from("events").insert(ut).select();if(_t)throw _t;return xt&&xt.length>0&&aEt(ke.title,xt[0].id),tt.length},onSuccess:ke=>{s.invalidateQueries({queryKey:["admin-events"]}),be.success(ke>1?`${ke} recurring events created successfully`:"Event created successfully"),n(!1),i(h8),h(null),g(null),_(!1)},onError:ke=>{be.error("Failed to create event: "+ke.message),_(!1)}}),st=Wt({mutationFn:async({id:ke,data:at})=>{_(!0);let Fe=at.image_url;d&&(Fe=await De(d)||"");const it=new Date(at.event_date),[dt,tt]=at.event_time.split(":");it.setHours(parseInt(dt),parseInt(tt));const{error:ut}=await Z.from("events").update({title:at.title,description:at.description||null,image_url:Fe||null,video_url:at.video_url||null,event_date:it.toISOString(),zoom_link:at.zoom_link,zoom_meeting_id:at.zoom_meeting_id||null,capacity:at.capacity?parseInt(at.capacity):null,is_published:at.is_published}).eq("id",ke);if(ut)throw ut},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),be.success("Event updated successfully"),n(!1),o(null),i(h8),h(null),g(null),_(!1)},onError:ke=>{be.error("Failed to update event: "+ke.message),_(!1)}}),he=Wt({mutationFn:async ke=>{const{error:at}=await Z.from("events").delete().eq("id",ke);if(at)throw at},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),be.success("Event deleted successfully")},onError:ke=>{be.error("Failed to delete event: "+ke.message)}}),We=ke=>{var Fe;const at=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:at,event_time:Bs(at,"HH:mm"),zoom_link:ke.zoom_link,zoom_meeting_id:ke.zoom_meeting_id||"",capacity:((Fe=ke.capacity)==null?void 0:Fe.toString())||"",is_published:ke.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),g(ke.image_url||null),h(null),n(!0)},et=ke=>{if(ke.preventDefault(),!l.event_date){be.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){be.error("Please select an end date for recurring events");return}a?st.mutate({id:a.id,data:l}):Ie.mutate(l)},Ye=()=>{n(!1),o(null),i(h8),h(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(Y,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(bi,{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(Oe,{className:"mb-6",children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsx(Gt,{children:"All Events"}),e.jsxs(js,{open:r,onOpenChange:ke=>!ke&&Ye(),children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{onClick:()=>n(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:et,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"title",children:"Title *"}),e.jsx(Be,{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(je,{children:"Description"}),e.jsx(Ig,{content:l.description,onChange:ke=>i({...l,description:ke}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Event Image"}),e.jsx("input",{type:"file",ref:j,accept:"image/*",onChange:Ge,className:"hidden"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(Y,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:wt,children:e.jsx(Xr,{className:"h-4 w-4"})})]}):e.jsxs(Y,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var ke;return(ke=j.current)==null?void 0:ke.click()},children:[e.jsx(ji,{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(je,{children:"Date *"}),e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(xn,{className:"mr-2 h-4 w-4"}),l.event_date?Bs(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{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(je,{htmlFor:"time",children:"Time *"}),e.jsx(Be,{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(je,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(Be,{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(je,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(Be,{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(je,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(Be,{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(je,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(Be,{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(BE,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(je,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(ln,{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(je,{children:"Frequency"}),e.jsxs(er,{value:l.recurrence_pattern,onValueChange:ke=>i({...l,recurrence_pattern:ke}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"weekly",children:"Weekly"}),e.jsx(Et,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(Et,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Repeat Until"}),e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(xn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?Bs(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{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,at=new Date(l.event_date);for(;at=l.recurrence_pattern==="weekly"?Gj(at,1):l.recurrence_pattern==="biweekly"?Gj(at,2):Ch(at,1),!(at>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(je,{htmlFor:"is_published",children:"Published"}),e.jsx(ln,{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(Y,{type:"button",variant:"outline",onClick:Ye,className:"flex-1",children:"Cancel"}),e.jsx(Y,{type:"submit",className:"flex-1",disabled:Ie.isPending||st.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($e,{children:ee?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(ie==null?void 0:ie.length)===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Date & Time"}),e.jsx(Ct,{children:"Registrations"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:ie==null?void 0:ie.map(ke=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:ke.title}),e.jsx(ot,{children:Bs(new Date(ke.event_date),"PPP p")}),e.jsx(ot,{children:e.jsxs(Y,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>Te(ke),children:[e.jsx(br,{className:"h-4 w-4"}),(de==null?void 0:de[ke.id])||0,ke.capacity&&` / ${ke.capacity}`]})}),e.jsx(ot,{children:e.jsx("span",{className:$t("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(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>window.open(ke.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(bn,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>We(ke),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&he.mutate(ke.id)},children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},ke.id))})]})})]}),e.jsx(js,{open:w,onOpenChange:k,children:e.jsxs(_s,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),M==null?void 0:M.title]}),e.jsx(en,{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(Y,{variant:"ghost",size:"sm",onClick:()=>Se.mutate({eventId:M.id,testMode:!0}),disabled:Se.isPending,children:[e.jsx(zr,{className:$t("h-4 w-4 mr-2",Se.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>Se.mutate({eventId:M.id}),disabled:Se.isPending||!(oe!=null&&oe.length),children:[e.jsx(zr,{className:$t("h-4 w-4 mr-2",Se.isPending&&"animate-spin")}),Se.isPending?"Sending...":"Send Reminder to All"]}),(M==null?void 0:M.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>ve.mutate(M.id),disabled:ve.isPending,children:[e.jsx(el,{className:$t("h-4 w-4 mr-2",ve.isPending&&"animate-spin")}),ve.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(Y,{variant:"default",size:"sm",onClick:()=>ye.mutate(M.id),disabled:ye.isPending,children:[e.jsx(vo,{className:$t("h-4 w-4 mr-2",ye.isPending&&"animate-spin")}),ye.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(Qa,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-2",children:[e.jsxs(Fs,{value:"registrations",className:"gap-2",children:[e.jsx(br,{className:"h-4 w-4"}),"Registrations (",(oe==null?void 0:oe.length)||0,")"]}),e.jsxs(Fs,{value:"attendees",className:"gap-2",children:[e.jsx(oi,{className:"h-4 w-4"}),"Attendees (",(ce==null?void 0:ce.length)||0,")"]})]}),e.jsx(Zs,{value:"registrations",className:"mt-4",children:ue?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(oe==null?void 0:oe.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(M==null?void 0:M.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:"Registered"}),e.jsx(Ct,{children:"Status"})]})}),e.jsx(Bn,{children:oe==null?void 0:oe.map(ke=>{var dt,tt;const at=((dt=ke.profiles)==null?void 0:dt.name)||ke.zoom_name||"Unknown",Fe=((tt=ke.profiles)==null?void 0:tt.email)||ke.zoom_email||null,it=!ke.user_id;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[at,it&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(ot,{children:Fe?e.jsxs("a",{href:`mailto:${Fe}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(zr,{className:"h-3 w-3"}),Fe]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ot,{className:"text-muted-foreground text-sm",children:Bs(new Date(ke.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(ot,{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:ge?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(ce==null?void 0:ce.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(M==null?void 0:M.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:[(ce==null?void 0:ce.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 (",ce==null?void 0:ce.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:ce==null?void 0:ce.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(Y,{variant:"outline",size:"sm",onClick:()=>Ee(ke),className:"gap-1",children:[e.jsx(Jm,{className:"h-3 w-3"}),"Link to Profile"]})]},ke.id))})]}),e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:"Duration"}),e.jsx(Ct,{children:"Points"})]})}),e.jsx(Bn,{children:ce==null?void 0:ce.filter(ke=>ke.user_id).map(ke=>{var it,dt;const at=((it=ke.profiles)==null?void 0:it.name)||ke.zoom_name||"Unknown",Fe=((dt=ke.profiles)==null?void 0:dt.email)||ke.zoom_email||null;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[at,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(ot,{children:Fe?e.jsxs("a",{href:`mailto:${Fe}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(zr,{className:"h-3 w-3"}),Fe]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ot,{children:ke.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(ca,{className:"h-3 w-3"}),ke.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ot,{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(vo,{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(js,{open:E,onOpenChange:D,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(Jm,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(en,{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(je,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name or email...",value:J,onChange:ke=>ne(ke.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Ue.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:Ue.slice(0,20).map(ke=>e.jsxs("button",{type:"button",onClick:()=>V(ke.id),className:$t("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(Do,{id:"save-alias",checked:W,onCheckedChange:ke=>G(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(Y,{variant:"outline",onClick:()=>D(!1),children:"Cancel"}),e.jsx(Y,{onClick:He,disabled:!$||Ae.isPending,children:Ae.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}const cEt=()=>{const{user:t}=Ys(),{toast:s}=Sa(),r=vs(),[n,a]=Oc(),[o,l]=T.useState(!1),[i,d]=T.useState(null),[h,f]=T.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]=T.useState(null),[_,j]=T.useState(0),[w,k]=T.useState(!1),[M,S]=T.useState(null),[E,D]=T.useState(""),[L,B]=T.useState(""),[$,V]=T.useState(""),[W,G]=T.useState(!1),[J,ne]=T.useState(!1),{data:ie=[]}=zt({queryKey:["template-categories"],queryFn:async()=>{const{data:st,error:he}=await Z.from("template_categories").select("*").order("name");if(he)throw he;return st}}),{data:ee=[]}=zt({queryKey:["template-types"],queryFn:async()=>{const{data:st,error:he}=await Z.from("template_types").select("*").order("name");if(he)throw he;return st}}),{data:de=[],isLoading:oe}=zt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:st,error:he}=await Z.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(he)throw he;const{data:We,error:et}=await Z.from("template_links").select("*").order("sort_order");if(et)throw et;const{data:Ye,error:ke}=await Z.from("template_guides").select("*").order("sort_order");if(ke)throw ke;return st.map(Fe=>({...Fe,links:(We==null?void 0:We.filter(it=>it.template_id===Fe.id))||[],guides:(Ye==null?void 0:Ye.filter(it=>it.template_id===Fe.id))||[]}))}});T.useEffect(()=>{const st=n.get("edit");if(st&&de.length>0){const he=de.find(We=>We.id===st);he&&(ye(he),a({},{replace:!0}))}},[de,n]);const ue=Wt({mutationFn:async st=>{const{data:he,error:We}=await Z.from("template_categories").insert({name:st}).select().single();if(We)throw We;return he},onSuccess:st=>{r.invalidateQueries({queryKey:["template-categories"]}),f({...h,category_id:st.id}),B(""),G(!1),s({title:"Category added"})},onError:st=>{s({title:"Error adding category",description:st.message,variant:"destructive"})}}),ce=Wt({mutationFn:async st=>{const{data:he,error:We}=await Z.from("template_types").insert({name:st}).select().single();if(We)throw We;return he},onSuccess:st=>{r.invalidateQueries({queryKey:["template-types"]}),f({...h,type_id:st.id}),V(""),ne(!1),s({title:"Type added"})},onError:st=>{s({title:"Error adding type",description:st.message,variant:"destructive"})}}),ge=Wt({mutationFn:async st=>{var ke;let he=st.existingImageUrl;if(st.image){const at=st.image.name.split(".").pop(),Fe=`${Date.now()}-${Math.random().toString(36).substring(7)}.${at}`,{error:it}=await Z.storage.from("template-previews").upload(Fe,st.image);if(it)throw it;const{data:dt}=Z.storage.from("template-previews").getPublicUrl(Fe);he=dt.publicUrl}const We={name:st.template.name,description:st.template.description||null,category_id:st.template.category_id||null,type_id:st.template.type_id||null,preview_image_url:he,video_url:st.videoUrl||null,publish_date:st.template.publish_date?new Date(st.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let et=st.templateId;if(et){const{error:at}=await Z.from("canva_templates").update(We).eq("id",et);if(at)throw at;const{error:Fe}=await Z.from("template_links").delete().eq("template_id",et);if(Fe)throw Fe;const it=((ke=st.existingGuides)==null?void 0:ke.map(ut=>ut.id).filter(Boolean))||[],dt=st.template.guides.map(ut=>ut.id).filter(Boolean),tt=it.filter(ut=>!dt.includes(ut));tt.length>0&&await Z.from("template_guides").delete().in("id",tt)}else{const{data:at,error:Fe}=await Z.from("canva_templates").insert(We).select().single();if(Fe)throw Fe;et=at.id,rEt(st.template.name,at.id)}const Ye=st.template.links.filter(at=>at.title.trim()&&at.canva_share_link.trim());if(Ye.length>0){const at=Ye.map((it,dt)=>({template_id:et,title:it.title.trim(),canva_share_link:it.canva_share_link.trim(),sort_order:dt})),{error:Fe}=await Z.from("template_links").insert(at);if(Fe)throw Fe}for(let at=0;at{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),ve(),l(!1),s({title:i?"Template updated":"Template created"})},onError:st=>{s({title:"Error saving template",description:st.message,variant:"destructive"})}}),Te=Wt({mutationFn:async st=>{const{error:he}=await Z.from("canva_templates").delete().eq("id",st);if(he)throw he},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:st=>{s({title:"Error deleting template",description:st.message,variant:"destructive"})}}),ve=()=>{f({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),S(null),D(""),d(null),G(!1),ne(!1),B(""),V(""),v(null),j(0),k(!1)},ye=st=>{var he;d(st),f({name:st.name,description:st.description||"",category_id:st.category_id||"",type_id:st.type_id||"",publish_date:st.publish_date?new Date(st.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:st.links&&st.links.length>0?st.links.map(We=>({id:We.id,title:We.title,canva_share_link:We.canva_share_link,sort_order:We.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((he=st.guides)==null?void 0:he.map(We=>({id:We.id,name:We.name,file_url:We.file_url,file_type:We.file_type,file_size:We.file_size,sort_order:We.sort_order})))||[],video_url:st.video_url||""}),D(st.preview_image_url||""),v(null),l(!0)},Se=st=>{var We;const he=(We=st.target.files)==null?void 0:We[0];he&&(S(he),D(URL.createObjectURL(he)))},Ke=()=>{f({...h,links:[...h.links,{title:"",canva_share_link:"",sort_order:h.links.length}]})},Ae=st=>{if(h.links.length<=1)return;const he=h.links.filter((We,et)=>et!==st);f({...h,links:he})},Ee=(st,he,We)=>{const et=[...h.links];et[st]={...et[st],[he]:We},f({...h,links:et})},He=st=>{const he=st.target.files;if(!he)return;const We=Array.from(he).map((et,Ye)=>({name:et.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:et.type,file_size:et.size,sort_order:h.guides.length+Ye,file:et}));f({...h,guides:[...h.guides,...We]}),st.target.value=""},Ue=st=>{const he=h.guides.filter((We,et)=>et!==st);f({...h,guides:he})},De=(st,he)=>{const We=[...h.guides];We[st]={...We[st],name:he},f({...h,guides:We})},Ge=async()=>{if(!g)return null;k(!0),j(0);try{const{data:st,error:he}=await Z.functions.invoke("bunny-upload",{body:{action:"create",title:h.name||g.name}});if(he)throw new Error(he.message);const{videoId:We,libraryId:et}=st,{data:Ye,error:ke}=await Z.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:We}});if(ke)throw new Error(ke.message);const at=new XMLHttpRequest;return await new Promise((it,dt)=>{at.upload.addEventListener("progress",tt=>{if(tt.lengthComputable){const ut=Math.round(tt.loaded/tt.total*100);j(ut)}}),at.addEventListener("load",()=>{at.status>=200&&at.status<300?it():dt(new Error(`Upload failed with status ${at.status}`))}),at.addEventListener("error",()=>dt(new Error("Upload failed"))),at.open("PUT",Ye.uploadUrl),at.setRequestHeader("AccessKey",Ye.apiKey),at.send(g)}),`https://player.mediadelivery.net/embed/${et}/${We}`}catch(st){return console.error("Bunny upload error:",st),s({title:"Video upload failed",description:st instanceof Error?st.message:"Unknown error",variant:"destructive"}),null}finally{k(!1)}},wt=st=>{var We;const he=(We=st.target.files)==null?void 0:We[0];he&&v(he),st.target.value=""},Ie=async st=>{if(st.preventDefault(),!h.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(h.links.filter(et=>et.title.trim()&&et.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let We=h.video_url;if(g){const et=await Ge();if(!et)return;We=et}ge.mutate({template:h,image:M,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:We})};return e.jsx(Vs,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:de.length})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:ee.length})})]})]}),e.jsxs(js,{open:o,onOpenChange:st=>{l(st),st||ve()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:Ie,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"name",children:"Name *"}),e.jsx(Be,{id:"name",value:h.name,onChange:st=>f({...h,name:st.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Ig,{content:h.description,onChange:st=>f({...h,description:st}),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(je,{children:"Canva Links *"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:Ke,className:"gap-1",children:[e.jsx(ar,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:h.links.map((st,he)=>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(Be,{value:st.title,onChange:We=>Ee(he,"title",We.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Be,{value:st.canva_share_link,onChange:We=>Ee(he,"canva_share_link",We.target.value),placeholder:"https://www.canva.com/design/..."})]}),h.links.length>1&&e.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Ae(he),children:e.jsx(Xr,{className:"h-4 w-4"})})]},he))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Category"}),W?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:L,onChange:st=>B(st.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(Y,{type:"button",size:"sm",onClick:()=>L.trim()&&ue.mutate(L.trim()),disabled:ue.isPending,children:"Add"}),e.jsx(Y,{type:"button",size:"sm",variant:"ghost",onClick:()=>{G(!1),B("")},children:e.jsx(Xr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(er,{value:h.category_id,onValueChange:st=>f({...h,category_id:st}),children:[e.jsx(Qs,{className:"flex-1",children:e.jsx(tr,{placeholder:"Select category"})}),e.jsx(Js,{children:ie.map(st=>e.jsx(Et,{value:st.id,children:st.name},st.id))})]}),e.jsx(Y,{type:"button",variant:"outline",size:"icon",onClick:()=>G(!0),children:e.jsx(ar,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Template Type"}),J?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:$,onChange:st=>V(st.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(Y,{type:"button",size:"sm",onClick:()=>$.trim()&&ce.mutate($.trim()),disabled:ce.isPending,children:"Add"}),e.jsx(Y,{type:"button",size:"sm",variant:"ghost",onClick:()=>{ne(!1),V("")},children:e.jsx(Xr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(er,{value:h.type_id,onValueChange:st=>f({...h,type_id:st}),children:[e.jsx(Qs,{className:"flex-1",children:e.jsx(tr,{placeholder:"Select type"})}),e.jsx(Js,{children:ee.map(st=>e.jsx(Et,{value:st.id,children:st.name},st.id))})]}),e.jsx(Y,{type:"button",variant:"outline",size:"icon",onClick:()=>ne(!0),children:e.jsx(ar,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Be,{id:"publish_date",type:"date",value:h.publish_date,onChange:st=>f({...h,publish_date:st.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(je,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[E?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:E,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx(Y,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{S(null),D("")},children:e.jsx(Xr,{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(fl,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Be,{type:"file",accept:"image/*",onChange:Se,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(je,{children:"Video (Optional)"}),h.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(Wn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>f({...h,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:h.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):w?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Us,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(rl,{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(Wn,{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(Y,{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(Xr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Be,{type:"file",accept:"video/*",onChange:wt,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(Wn,{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(je,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Be,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:He,className:"hidden"}),e.jsx(Y,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(ji,{className:"h-3 w-3"}),"Add Files"]})})]})]}),h.guides.length>0?e.jsx("div",{className:"space-y-2",children:h.guides.map((st,he)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(Yn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Be,{value:st.name,onChange:We=>De(he,We.target.value),placeholder:"Guide name",className:"flex-1"}),st.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(st.file_size/1024).toFixed(0)," KB"]}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Ue(he),children:e.jsx(Xr,{className:"h-4 w-4"})})]},st.id||he))}):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.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>{l(!1),ve()},children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:ge.isPending,children:ge.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:oe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):de.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Preview"}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Links"}),e.jsx(Ct,{children:"Category"}),e.jsx(Ct,{children:"Type"}),e.jsx(Ct,{children:"Publish Date"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:de.map(st=>{var he,We,et,Ye,ke;return e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:st.preview_image_url?e.jsx("img",{src:st.preview_image_url,alt:st.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(fl,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(ot,{className:"font-medium",children:st.name}),e.jsx(ot,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(ct,{variant:"secondary",children:[((he=st.links)==null?void 0:he.length)||0," link",(((We=st.links)==null?void 0:We.length)||0)!==1?"s":""]}),(((et=st.guides)==null?void 0:et.length)||0)>0&&e.jsxs(ct,{variant:"outline",className:"gap-1",children:[e.jsx(Yn,{className:"h-3 w-3"}),(Ye=st.guides)==null?void 0:Ye.length," guide",(((ke=st.guides)==null?void 0:ke.length)||0)!==1?"s":""]})]})}),e.jsx(ot,{children:st.category?e.jsx(ct,{variant:"secondary",children:st.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ot,{children:st.type?e.jsx(ct,{variant:"outline",children:st.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ot,{className:"text-muted-foreground",children:new Date(st.publish_date).toLocaleDateString()}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{size:"icon",variant:"ghost",onClick:()=>ye(st),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&Te.mutate(st.id)},children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},st.id)})})]})})})]})})};function tHe({selectedTemplateIds:t,onChange:s}){const[r,n]=T.useState(""),[a,o]=T.useState(!1),{data:l=[]}=zt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:g,error:v}=await Z.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())),h=g=>{s([...t,g])},f=g=>{s(t.filter(v=>v!==g))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{className:"flex items-center gap-2",children:[e.jsx(Sk,{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(ct,{variant:"secondary",className:"gap-1 pr-1",children:[g.name,e.jsx("button",{type:"button",onClick:()=>f(g.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Xr,{className:"h-3 w-3"})})]},g.id))}),e.jsxs(_l,{open:a,onOpenChange:o,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(Sk,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(nl,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(On,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Be,{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:()=>{h(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(Sk,{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 dEt=[{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"}],uEt=()=>{const{user:t}=Ys(),[s,r]=Oc(),{toast:n}=Sa(),a=vs(),[o,l]=T.useState(!1),[i,d]=T.useState(null),[h,f]=T.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[g,v]=T.useState(null),[_,j]=T.useState(""),[w,k]=T.useState([]),[M,S]=T.useState([]),[E,D]=T.useState([]),[L,B]=T.useState([]),[$,V]=T.useState(""),[W,G]=T.useState(!1),[J,ne]=T.useState(null),[ie,ee]=T.useState(0),[de,oe]=T.useState(!1),[ue,ce]=T.useState(null),{data:ge=[]}=zt({queryKey:["academy-categories"],queryFn:async()=>{const{data:he,error:We}=await Z.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(We)throw We;return he}}),{data:Te=[],isLoading:ve}=zt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:he,error:We}=await Z.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(We)throw We;const{data:et,error:Ye}=await Z.from("academy_resources").select("*").order("sort_order");if(Ye)throw Ye;return he.map(at=>({...at,resources:(et==null?void 0:et.filter(Fe=>Fe.video_id===at.id))||[]}))}});T.useEffect(()=>{const he=s.get("edit");if(he&&Te.length>0){const We=Te.find(et=>et.id===he);We&&(He(We),r({},{replace:!0}))}},[Te,s]);const ye=Wt({mutationFn:async he=>{const{data:We,error:et}=await Z.from("academy_categories").insert({name:he,sort_order:ge.length}).select().single();if(et)throw et;return We},onSuccess:he=>{a.invalidateQueries({queryKey:["academy-categories"]}),f({...h,category_id:he.id}),V(""),G(!1),n({title:"Category added"})},onError:he=>{n({title:"Error adding category",description:he.message,variant:"destructive"})}}),Se=Wt({mutationFn:async he=>{let We=he.existingThumbnailUrl;if(he.thumbnail){const ke=he.thumbnail.name.split(".").pop(),at=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${ke}`,{error:Fe}=await Z.storage.from("academy-resources").upload(at,he.thumbnail);if(Fe)throw Fe;const{data:it}=Z.storage.from("academy-resources").getPublicUrl(at);We=it.publicUrl}const et={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:We,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 Ye=he.videoId;if(Ye){const{error:ke}=await Z.from("academy_videos").update(et).eq("id",Ye);if(ke)throw ke}else{const{data:ke,error:at}=await Z.from("academy_videos").insert(et).select().single();if(at)throw at;Ye=ke.id,nEt(he.video.title,ke.id)}if(he.resourcesToDelete.length>0){const{error:ke}=await Z.from("academy_resources").delete().in("id",he.resourcesToDelete);if(ke)throw ke}for(let ke=0;ke0){const{error:ke}=await Z.from("academy_video_templates").insert(L.map(at=>({video_id:Ye,template_id:at})));if(ke)throw ke}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Ee(),l(!1),n({title:i?"Video updated":"Video created"})},onError:he=>{n({title:"Error saving video",description:he.message,variant:"destructive"})}}),Ke=Wt({mutationFn:async he=>{const{error:We}=await Z.from("academy_videos").delete().eq("id",he);if(We)throw We},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"})}}),Ae=Wt({mutationFn:async({id:he,is_published:We})=>{const{error:et}=await Z.from("academy_videos").update({is_published:We}).eq("id",he);if(et)throw et},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:he=>{n({title:"Error updating video",description:he.message,variant:"destructive"})}}),Ee=()=>{f({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),v(null),j(""),k([]),S([]),D([]),d(null),B([]),V(""),ne(null),ee(0),oe(!1),ce(null)},He=async he=>{d(he),f({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}),j(he.thumbnail_url||""),S(he.resources||[]),k([]),D([]);const{data:We}=await Z.from("academy_video_templates").select("template_id").eq("video_id",he.id);B((We||[]).map(et=>et.template_id)),l(!0)},Ue=he=>{var et;const We=(et=he.target.files)==null?void 0:et[0];We&&(v(We),j(URL.createObjectURL(We)))},De=he=>{const We=he.target.files;if(We){const et=Array.from(We).map(Ye=>({file:Ye,title:Ye.name.replace(/\.[^/.]+$/,"")}));k([...w,...et])}he.target.value=""},Ge=he=>{k(w.filter((We,et)=>et!==he))},wt=he=>{D([...E,he]),S(M.filter(We=>We.id!==he))},Ie=async()=>{if(!J)return null;oe(!0),ee(0);try{const{data:he,error:We}=await Z.functions.invoke("bunny-upload",{body:{action:"create",title:h.title||J.name}});if(We)throw new Error(We.message);const{videoId:et,libraryId:Ye}=he;ce(et);const{data:ke,error:at}=await Z.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:et}});if(at)throw new Error(at.message);const Fe=new XMLHttpRequest;return await new Promise((dt,tt)=>{Fe.upload.addEventListener("progress",ut=>{if(ut.lengthComputable){const xt=Math.round(ut.loaded/ut.total*100);ee(xt)}}),Fe.addEventListener("load",()=>{Fe.status>=200&&Fe.status<300?dt():tt(new Error(`Upload failed with status ${Fe.status}`))}),Fe.addEventListener("error",()=>tt(new Error("Upload failed"))),Fe.open("PUT",ke.uploadUrl),Fe.setRequestHeader("AccessKey",ke.apiKey),Fe.send(J)}),`https://player.mediadelivery.net/embed/${Ye}/${et}`}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{oe(!1)}},st=async he=>{if(he.preventDefault(),!h.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let We=h.video_url;if(h.video_type==="bunny_stream"&&J&&!i){const et=await Ie();if(!et)return;We=et}else if(!h.video_url.trim()&&h.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(h.video_type==="bunny_stream"&&!J&&!h.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}Se.mutate({video:{...h,video_url:We},thumbnail:g,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:w,resourcesToDelete:E})};return e.jsx(Vs,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:Te.length})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:Te.filter(he=>he.is_published).length})})]})]}),e.jsxs(js,{open:o,onOpenChange:he=>{l(he),he||Ee()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:st,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"title",children:"Title *"}),e.jsx(Be,{id:"title",value:h.title,onChange:he=>f({...h,title:he.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Ig,{content:h.description,onChange:he=>f({...h,description:he}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Video Type"}),e.jsxs(er,{value:h.video_type,onValueChange:he=>{f({...h,video_type:he,video_url:""}),ne(null)},disabled:de,children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:dEt.map(he=>e.jsx(Et,{value:he.value,children:he.label},he.value))})]})]}),h.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(je,{children:["Upload Video File ",!i&&"*"]}),i&&h.video_url&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Current video: ",e.jsx("a",{href:h.video_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"View"})]}),!i&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{type:"file",accept:"video/*",onChange:he=>{var et;const We=(et=he.target.files)==null?void 0:et[0];We&&ne(We)},disabled:de}),J&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Wn,{className:"h-4 w-4"}),J.name," (",(J.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(Us,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(rl,{value:ie,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[ie,"%"]})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(Be,{id:"video_url",value:h.video_url,onChange:he=>f({...h,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(je,{htmlFor:"duration",children:"Duration"}),e.jsx(Be,{id:"duration",value:h.duration,onChange:he=>f({...h,duration:he.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Be,{id:"publish_date",type:"date",value:h.publish_date,onChange:he=>f({...h,publish_date:he.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Category"}),W?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:$,onChange:he=>V(he.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(Y,{type:"button",size:"sm",onClick:()=>$.trim()&&ye.mutate($.trim()),disabled:ye.isPending,children:"Add"}),e.jsx(Y,{type:"button",size:"sm",variant:"ghost",onClick:()=>{G(!1),V("")},children:e.jsx(Xr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(er,{value:h.category_id,onValueChange:he=>f({...h,category_id:he}),children:[e.jsx(Qs,{className:"flex-1",children:e.jsx(tr,{placeholder:"Select category"})}),e.jsx(Js,{children:ge.map(he=>e.jsx(Et,{value:he.id,children:he.name},he.id))})]}),e.jsx(Y,{type:"button",variant:"outline",size:"sm",onClick:()=>G(!0),children:e.jsx(ar,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{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(Be,{type:"file",accept:"image/*",onChange:Ue,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(je,{children:"Resource Files"}),e.jsx(Y,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(ji,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:De,className:"hidden"})]})})]}),(M.length>0||w.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[M.map(he=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:he.title}),e.jsx(ct,{variant:"outline",className:"text-xs",children:he.file_type}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>wt(he.id),className:"text-destructive hover:text-destructive",children:e.jsx(Xr,{className:"h-4 w-4"})})]},he.id)),w.map((he,We)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Be,{value:he.title,onChange:et=>{const Ye=[...w];Ye[We].title=et.target.value,k(Ye)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(ct,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>Ge(We),className:"text-destructive hover:text-destructive",children:e.jsx(Xr,{className:"h-4 w-4"})})]},We))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(tHe,{selectedTemplateIds:L,onChange:B}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{id:"is_published",checked:h.is_published,onCheckedChange:he=>f({...h,is_published:he})}),e.jsx(je,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(Hn,{children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:de,children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:Se.isPending||de,children:de?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):Se.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:ve?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"})}):Te.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Wn,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Category"}),e.jsx(Ct,{children:"Duration"}),e.jsx(Ct,{children:"Resources"}),e.jsx(Ct,{children:"Publish Date"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(Bn,{children:Te.map(he=>e.jsxs(ws,{children:[e.jsx(ot,{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(Wn,{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(ot,{children:he.category?e.jsx(ct,{variant:"outline",children:he.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ot,{children:he.duration||"-"}),e.jsx(ot,{children:he.resources&&he.resources.length>0?e.jsxs(ct,{variant:"secondary",children:[he.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ot,{children:new Date(he.publish_date).toLocaleDateString()}),e.jsx(ot,{children:e.jsx(ln,{checked:he.is_published,onCheckedChange:We=>Ae.mutate({id:he.id,is_published:We})})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>He(he),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>Ke.mutate(he.id),className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},he.id))})]})})})]})})};function hEt(){var Se,Ke,Ae;const t=vs(),[s,r]=Oc(),[n,a]=T.useState(!1),[o,l]=T.useState(null),[i,d]=T.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[h,f]=T.useState(null),[g,v]=T.useState(""),[_,j]=T.useState([]),[w,k]=T.useState([]),[M,S]=T.useState([]),[E,D]=T.useState(null),{data:L,isLoading:B}=zt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Ee,error:He}=await Z.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(He)throw He;return Ee}}),{data:$}=zt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Ee,error:He}=await Z.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(He)throw He;return Ee}}),{data:V}=zt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Ee,error:He}=await Z.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(He)throw He;return Ee}});T.useEffect(()=>{const Ee=s.get("edit");if(Ee&&L&&L.length>0&&$&&V){const He=L.find(Ue=>Ue.id===Ee);He&&(G(He),r({},{replace:!0}))}},[L,$,V,s]);const W=()=>{d({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),f(null),v(""),j([]),k([]),S([]),l(null)},G=async Ee=>{l(Ee),d({name:Ee.name,description:Ee.description||"",publish_date:Ee.publish_date.split("T")[0],is_published:Ee.is_published}),v(Ee.featured_image_url||"");const He=($==null?void 0:$.filter(Ge=>Ge.kit_id===Ee.id))||[];j(He.map(Ge=>({id:Ge.id,name:Ge.name,file_url:Ge.file_url,file_type:Ge.file_type,file_size:Ge.file_size,sort_order:Ge.sort_order})));const Ue=(V==null?void 0:V.filter(Ge=>Ge.kit_id===Ee.id))||[];k(Ue.map(Ge=>({id:Ge.id,title:Ge.title,canva_share_link:Ge.canva_share_link,sort_order:Ge.sort_order})));const{data:De}=await Z.from("resource_kit_templates").select("template_id").eq("kit_id",Ee.id);S((De||[]).map(Ge=>Ge.template_id)),a(!0)},J=Ee=>{var Ue;const He=(Ue=Ee.target.files)==null?void 0:Ue[0];He&&(f(He),v(URL.createObjectURL(He)))},ne=()=>{j([..._,{name:"",file_url:"",sort_order:_.length}])},ie=Ee=>{j(_.filter((He,Ue)=>Ue!==Ee))},ee=(Ee,He,Ue)=>{const De=[..._];De[Ee]={...De[Ee],[He]:Ue},j(De)},de=()=>{k([...w,{title:"",canva_share_link:"",sort_order:w.length}])},oe=Ee=>{k(w.filter((He,Ue)=>Ue!==Ee))},ue=(Ee,He,Ue)=>{const De=[...w];De[Ee]={...De[Ee],[He]:Ue},k(De)},ce=(Ee,He)=>{var De;const Ue=(De=He.target.files)==null?void 0:De[0];if(Ue){const Ge=[..._],wt=Ue.name.replace(/\.[^/.]+$/,"");Ge[Ee]={...Ge[Ee],file:Ue,file_type:Ue.type,file_size:Ue.size,name:Ge[Ee].name||wt},j(Ge)}},ge=Wt({mutationFn:async()=>{let Ee=(o==null?void 0:o.featured_image_url)||null;if(h){const wt=h.name.split(".").pop(),Ie=`${Date.now()}.${wt}`,{error:st}=await Z.storage.from("resource-kits").upload(`featured/${Ie}`,h);if(st)throw st;const{data:he}=Z.storage.from("resource-kits").getPublicUrl(`featured/${Ie}`);Ee=he.publicUrl}const He={name:i.name,description:i.description||null,featured_image_url:Ee,publish_date:i.publish_date,is_published:i.is_published};let Ue;const De=!o,Ge=(o==null?void 0:o.is_published)||!1;if(o){const{error:wt}=await Z.from("resource_kits").update(He).eq("id",o.id);if(wt)throw wt;Ue=o.id;const Ie=($==null?void 0:$.filter(ke=>ke.kit_id===o.id).map(ke=>ke.id))||[],st=_.filter(ke=>ke.id).map(ke=>ke.id),he=Ie.filter(ke=>!st.includes(ke));he.length>0&&await Z.from("resource_kit_files").delete().in("id",he);const We=(V==null?void 0:V.filter(ke=>ke.kit_id===o.id).map(ke=>ke.id))||[],et=w.filter(ke=>ke.id).map(ke=>ke.id),Ye=We.filter(ke=>!et.includes(ke));Ye.length>0&&await Z.from("resource_kit_links").delete().in("id",Ye)}else{const{data:wt,error:Ie}=await Z.from("resource_kits").insert(He).select().single();if(Ie)throw Ie;Ue=wt.id}for(let wt=0;wt<_.length;wt++){const Ie=_[wt];let st=Ie.file_url;if(Ie.file){const he=Ie.file.name.split(".").pop(),We=`${Date.now()}-${wt}.${he}`,{error:et}=await Z.storage.from("resource-kits").upload(`files/${We}`,Ie.file);if(et)throw et;const{data:Ye}=Z.storage.from("resource-kits").getPublicUrl(`files/${We}`);st=Ye.publicUrl}Ie.id?await Z.from("resource_kit_files").update({name:Ie.name,file_url:st,file_type:Ie.file_type,file_size:Ie.file_size,sort_order:wt}).eq("id",Ie.id):st&&Ie.name&&await Z.from("resource_kit_files").insert({kit_id:Ue,name:Ie.name,file_url:st,file_type:Ie.file_type,file_size:Ie.file_size,sort_order:wt})}for(let wt=0;wt0){const{error:wt}=await Z.from("resource_kit_templates").insert(M.map(Ie=>({kit_id:Ue,template_id:Ie})));if(wt)throw wt}return{kitId:Ue,kitName:i.name,isNewKit:De,wasPublished:Ge,isPublished:i.is_published}},onSuccess:Ee=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),be.success(o?"Resource kit updated":"Resource kit created"),Ee.isPublished&&(Ee.isNewKit||!Ee.wasPublished)&&iEt(Ee.kitName,Ee.kitId),a(!1),W()},onError:Ee=>{be.error("Failed to save resource kit: "+Ee.message)}}),Te=Wt({mutationFn:async Ee=>{const{error:He}=await Z.from("resource_kits").delete().eq("id",Ee);if(He)throw He},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),be.success("Resource kit deleted")},onError:Ee=>{be.error("Failed to delete: "+Ee.message)}}),ve=Ee=>{if(Ee.preventDefault(),!i.name){be.error("Please enter a name");return}ge.mutate()},ye=Ee=>($==null?void 0:$.filter(He=>He.kit_id===Ee).length)||0;return e.jsx(Vs,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.length)||0})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.filter(Ee=>Ee.is_published).length)||0})})]})]}),e.jsxs(Y,{onClick:()=>{W(),a(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Files"}),e.jsx(Ct,{children:"Publish Date"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:B?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(ws,{children:e.jsx(ot,{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(Ee=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ee.featured_image_url?e.jsx("img",{src:Ee.featured_image_url,alt:Ee.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(mc,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ee.name}),Ee.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ee.description})]})]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"}),ye(Ee.id)]})}),e.jsx(ot,{children:Bs(new Date(Ee.publish_date),"MMM d, yyyy")}),e.jsx(ot,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ee.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Ee.is_published?"Published":"Draft"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{const He=($==null?void 0:$.filter(De=>De.kit_id===Ee.id))||[],Ue=(V==null?void 0:V.filter(De=>De.kit_id===Ee.id))||[];D({...Ee,files:He,links:Ue})},children:e.jsx(wi,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>G(Ee),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&Te.mutate(Ee.id)},children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},Ee.id))})]})})}),e.jsx(js,{open:n,onOpenChange:a,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:ve,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{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(mc,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Be,{type:"file",accept:"image/*",onChange:J})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"name",children:"Name *"}),e.jsx(Be,{id:"name",value:i.name,onChange:Ee=>d({...i,name:Ee.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Ig,{content:i.description,onChange:Ee=>d({...i,description:Ee}),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(je,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Be,{id:"publish_date",type:"date",value:i.publish_date,onChange:Ee=>d({...i,publish_date:Ee.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(ln,{checked:i.is_published,onCheckedChange:Ee=>d({...i,is_published:Ee})}),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(je,{children:"Resource Files"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:ne,children:[e.jsx(ar,{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((Ee,He)=>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 ",He+1]}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ie(He),children:e.jsx(Xr,{className:"h-4 w-4"})})]}),e.jsx(Be,{placeholder:"File name (e.g., Getting Started Guide)",value:Ee.name,onChange:Ue=>ee(He,"name",Ue.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{type:"file",onChange:Ue=>ce(He,Ue),className:"flex-1"}),Ee.file_url&&!Ee.file&&e.jsx("a",{href:Ee.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Ee.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},He))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(je,{children:"Canva Links"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:de,children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),w.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No Canva links added yet. Click "Add Canva Link" to include templates.'}):e.jsx("div",{className:"space-y-3",children:w.map((Ee,He)=>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 ",He+1]}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>oe(He),children:e.jsx(Xr,{className:"h-4 w-4"})})]}),e.jsx(Be,{placeholder:"Link title (e.g., Social Media Post Template)",value:Ee.title,onChange:Ue=>ue(He,"title",Ue.target.value)}),e.jsx(Be,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Ee.canva_share_link,onChange:Ue=>ue(He,"canva_share_link",Ue.target.value)})]},He))})]}),e.jsx(tHe,{selectedTemplateIds:M,onChange:S}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:ge.isPending,children:ge.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(js,{open:!!E,onOpenChange:()=>D(null),children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:E==null?void 0:E.name})}),e.jsxs("div",{className:"space-y-4",children:[(E==null?void 0:E.featured_image_url)&&e.jsx("img",{src:E.featured_image_url,alt:E.name,className:"w-full h-48 object-cover rounded-lg"}),(E==null?void 0:E.description)&&e.jsx("p",{className:"text-muted-foreground",children:E.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((Se=E==null?void 0:E.files)==null?void 0:Se.length)||0,")"]}),((Ke=E==null?void 0:E.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:(Ae=E==null?void 0:E.files)==null?void 0:Ae.map(Ee=>e.jsxs("a",{href:Ee.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(Yn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ee.name})]},Ee.id))})]}),(E==null?void 0:E.links)&&E.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",E.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:E.links.map(Ee=>e.jsxs("a",{href:Ee.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(Ro,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ee.title})]},Ee.id))})]})]})]})})]})})}const mEt=()=>{const{user:t}=Ys(),{toast:s}=Sa(),r=vs(),[n,a]=T.useState(!1),[o,l]=T.useState(null),[i,d]=T.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[h,f]=T.useState(null),[g,v]=T.useState(""),{data:_=[],isLoading:j}=zt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:V,error:W}=await Z.from("social_swag").select("*").order("publish_date",{ascending:!1});if(W)throw W;const{data:G,error:J}=await Z.from("social_swag_links").select("*").order("sort_order");if(J)throw J;return V.map(ie=>({...ie,links:(G==null?void 0:G.filter(ee=>ee.swag_id===ie.id))||[]}))}}),w=Wt({mutationFn:async V=>{let W=V.existingImageUrl;if(V.image){const de=V.image.name.split(".").pop(),oe=`${Date.now()}-${Math.random().toString(36).substring(7)}.${de}`,{error:ue}=await Z.storage.from("template-previews").upload(oe,V.image);if(ue)throw ue;const{data:ce}=Z.storage.from("template-previews").getPublicUrl(oe);W=ce.publicUrl}const G={title:V.item.title,description:V.item.description||null,preview_image_url:W,publish_date:V.item.publish_date?new Date(V.item.publish_date).toISOString():new Date().toISOString(),is_published:V.item.is_published,created_by:t==null?void 0:t.id};let J=V.itemId;const ne=!J,ie=(o==null?void 0:o.is_published)||!1;if(J){const{error:de}=await Z.from("social_swag").update(G).eq("id",J);if(de)throw de;await Z.from("social_swag_links").delete().eq("swag_id",J)}else{const{data:de,error:oe}=await Z.from("social_swag").insert(G).select().single();if(oe)throw oe;J=de.id}const ee=V.item.links.filter(de=>de.title.trim()&&de.canva_share_link.trim());if(ee.length>0){const de=ee.map((ue,ce)=>({swag_id:J,title:ue.title.trim(),canva_share_link:ue.canva_share_link.trim(),sort_order:ce})),{error:oe}=await Z.from("social_swag_links").insert(de);if(oe)throw oe}return{itemId:J,itemTitle:V.item.title,isNewItem:ne,wasPublished:ie,isPublished:V.item.is_published}},onSuccess:V=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),V.isPublished&&(V.isNewItem||!V.wasPublished)&&Bge(V.itemTitle,V.itemId),a(!1),M()},onError:V=>{s({title:"Error saving item",description:V.message,variant:"destructive"})}}),k=Wt({mutationFn:async V=>{const{error:W}=await Z.from("social_swag").delete().eq("id",V);if(W)throw W},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:V=>{s({title:"Error deleting item",description:V.message,variant:"destructive"})}}),M=()=>{d({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),f(null),v(""),l(null)},S=V=>{l(V),d({title:V.title,description:V.description||"",publish_date:V.publish_date?new Date(V.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:V.is_published,links:V.links&&V.links.length>0?V.links.map(W=>({id:W.id,title:W.title,canva_share_link:W.canva_share_link,sort_order:W.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),v(V.preview_image_url||""),a(!0)},E=V=>{var G;const W=(G=V.target.files)==null?void 0:G[0];W&&(f(W),v(URL.createObjectURL(W)))},D=()=>{d({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},L=V=>{if(i.links.length<=1)return;const W=i.links.filter((G,J)=>J!==V);d({...i,links:W})},B=(V,W,G)=>{const J=[...i.links];J[V]={...J[V],[W]:G},d({...i,links:J})},$=V=>{if(V.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}w.mutate({item:i,image:h,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Vs,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(V=>V.is_published).length})})]})]}),e.jsxs(js,{open:n,onOpenChange:V=>{a(V),V||M()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{htmlFor:"title",children:"Title *"}),e.jsx(Be,{id:"title",value:i.title,onChange:V=>d({...i,title:V.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Ig,{content:i.description,onChange:V=>d({...i,description:V}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Be,{id:"publish_date",type:"date",value:i.publish_date,onChange:V=>d({...i,publish_date:V.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ln,{id:"is_published",checked:i.is_published,onCheckedChange:V=>d({...i,is_published:V})}),e.jsx(je,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{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(Y,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{f(null),v("")},children:e.jsx(Xr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(fl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Be,{type:"file",accept:"image/*",onChange:E,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{children:"Canva Links"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:D,children:[e.jsx(ar,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((V,W)=>e.jsx(Oe,{children:e.jsxs($e,{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 ",W+1]}),i.links.length>1&&e.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>L(W),children:e.jsx(Xr,{className:"h-3 w-3"})})]}),e.jsx(Be,{placeholder:"Link title (e.g., Instagram Post)",value:V.title,onChange:G=>B(W,"title",G.target.value)}),e.jsx(Be,{placeholder:"Canva share link",value:V.canva_share_link,onChange:G=>B(W,"canva_share_link",G.target.value)})]})},W))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:j?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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-16",children:"Preview"}),e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Links"}),e.jsx(Ct,{children:"Publish Date"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:_.map(V=>{var W;return e.jsxs(ws,{children:[e.jsx(ot,{children:V.preview_image_url?e.jsx("img",{src:V.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(fl,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(ot,{className:"font-medium",children:V.title}),e.jsxs(ot,{children:[((W=V.links)==null?void 0:W.length)||0," links"]}),e.jsx(ot,{children:new Date(V.publish_date).toLocaleDateString()}),e.jsx(ot,{children:e.jsx(ct,{variant:V.is_published?"default":"secondary",children:V.is_published?"Published":"Draft"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${V.id}`,"_blank"),children:e.jsx(wi,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>S(V),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&k.mutate(V.id)},children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},V.id)})})]})})})]})})};function pEt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const Ioe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Z3(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function R_e(t){return"nodeType"in t}function gm(t){var s,r;return t?Z3(t)?t:R_e(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function F_e(t){const{Document:s}=gm(t);return t instanceof s}function J6(t){return Z3(t)?!1:t instanceof gm(t).HTMLElement}function sHe(t){return t instanceof gm(t).SVGElement}function Y3(t){return t?Z3(t)?t.document:R_e(t)?F_e(t)?t:J6(t)||sHe(t)?t.ownerDocument:document:document:document}const Ux=Ioe?T.useLayoutEffect:T.useEffect;function z_e(t){const s=T.useRef(t);return Ux(()=>{s.current=t}),T.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=T.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function jP(t,s){s===void 0&&(s=[t]);const r=T.useRef(t);return Ux(()=>{r.current!==t&&(r.current=t)},s),r}function eL(t,s){const r=T.useRef();return T.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function zne(t){const s=z_e(t),r=T.useRef(null),n=T.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function $ge(t){const s=T.useRef();return T.useEffect(()=>{s.current=t},[t]),s.current}let zhe={};function tL(t,s){return T.useMemo(()=>{if(s)return s;const r=zhe[t]==null?0:zhe[t]+1;return zhe[t]=r,t+"-"+r},[t,s])}function rHe(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,h]of i){const f=o[d];f!=null&&(o[d]=f+t*h)}return o},{...s})}}const a5=rHe(1),kP=rHe(-1);function gEt(t){return"clientX"in t&&"clientY"in t}function B_e(t){if(!t)return!1;const{KeyboardEvent:s}=gm(t.target);return s&&t instanceof s}function xEt(t){if(!t)return!1;const{TouchEvent:s}=gm(t.target);return s&&t instanceof s}function Uge(t){if(xEt(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 gEt(t)?{x:t.clientX,y:t.clientY}:null}const NP=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[NP.Translate.toString(t),NP.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),fMe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function yEt(t){return t.matches(fMe)?t:t.querySelector(fMe)}const vEt={display:"none"};function _Et(t){let{id:s,value:r}=t;return lt.createElement("div",{id:s,style:vEt},r)}function bEt(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 lt.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function wEt(){const[t,s]=T.useState("");return{announce:T.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const nHe=T.createContext(null);function jEt(t){const s=T.useContext(nHe);T.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function kEt(){const[t]=T.useState(()=>new Set),s=T.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[T.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 NEt={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. `},SEt={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 CEt(t){let{announcements:s=SEt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=NEt}=t;const{announce:o,announcement:l}=wEt(),i=tL("DndLiveRegion"),[d,h]=T.useState(!1);if(T.useEffect(()=>{h(!0)},[]),jEt(T.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 f=lt.createElement(lt.Fragment,null,lt.createElement(_Et,{id:n,value:a.draggable}),lt.createElement(bEt,{id:i,announcement:l}));return r?Qh.createPortal(f,r):f}var kd;(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"})(kd||(kd={}));function Bne(){}function gMe(t,s){return T.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function MEt(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const Mg=Object.freeze({x:0,y:0});function aHe(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function iHe(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function TEt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function xMe(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 oHe(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function yMe(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 AEt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=yMe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const h=aHe(yMe(d),a);o.push({id:i,data:{droppableContainer:l,value:h}})}}return o.sort(iHe)},EEt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=xMe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const h=xMe(d),f=a.reduce((v,_,j)=>v+aHe(h[j],_),0),g=Number((f/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:g}})}}return o.sort(iHe)};function IEt(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=IEt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(TEt)};function LEt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function lHe(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:Mg}function DEt(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 OEt=DEt(1);function REt(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 FEt(t,s,r){const n=REt(s);if(!n)return t;const{scaleX:a,scaleY:o,x:l,y:i}=n,d=t.left-l-(1-a)*parseFloat(r),h=t.top-i-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),f=a?t.width/a:t.width,g=o?t.height/o:t.height;return{width:f,height:g,top:h,right:d+f,bottom:h+g,left:d}}const zEt={ignoreTransform:!1};function X3(t,s){s===void 0&&(s=zEt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:h,transformOrigin:f}=gm(t).getComputedStyle(t);h&&(r=FEt(r,h,f))}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 vMe(t){return X3(t,{ignoreTransform:!0})}function BEt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function $Et(t,s){return s===void 0&&(s=gm(t).getComputedStyle(t)),s.position==="fixed"}function UEt(t,s){s===void 0&&(s=gm(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 Poe(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(F_e(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!J6(a)||sHe(a)||r.includes(a))return r;const o=gm(t).getComputedStyle(a);return a!==t&&UEt(a,o)&&r.push(a),$Et(a,o)?r:n(a.parentNode)}return t?n(t):r}function cHe(t){const[s]=Poe(t,1);return s??null}function Bhe(t){return!Ioe||!t?null:Z3(t)?t:R_e(t)?F_e(t)||t===Y3(t).scrollingElement?window:J6(t)?t:null:null}function dHe(t){return Z3(t)?t.scrollX:t.scrollLeft}function uHe(t){return Z3(t)?t.scrollY:t.scrollTop}function qge(t){return{x:dHe(t),y:uHe(t)}}var Gd;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Gd||(Gd={}));function hHe(t){return!Ioe||!t?!1:t===document.scrollingElement}function mHe(t){const s={x:0,y:0},r=hHe(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 qEt={x:.2,y:.2};function VEt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=qEt);const{isTop:h,isBottom:f,isLeft:g,isRight:v}=mHe(t),_={x:0,y:0},j={x:0,y:0},w={height:s.height*a.y,width:s.width*a.x};return!h&&o<=s.top+w.height?(_.y=Gd.Backward,j.y=n*Math.abs((s.top+w.height-o)/w.height)):!f&&d>=s.bottom-w.height&&(_.y=Gd.Forward,j.y=n*Math.abs((s.bottom-w.height-d)/w.height)),!v&&i>=s.right-w.width?(_.x=Gd.Forward,j.x=n*Math.abs((s.right-w.width-i)/w.width)):!g&&l<=s.left+w.width&&(_.x=Gd.Backward,j.x=n*Math.abs((s.left+w.width-l)/w.width)),{direction:_,speed:j}}function HEt(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 pHe(t){return t.reduce((s,r)=>a5(s,qge(r)),Mg)}function WEt(t){return t.reduce((s,r)=>s+dHe(r),0)}function GEt(t){return t.reduce((s,r)=>s+uHe(r),0)}function KEt(t,s){if(s===void 0&&(s=X3),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);cHe(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const ZEt=[["x",["left","right"],WEt],["y",["top","bottom"],GEt]];class $_e{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=Poe(r),a=pHe(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of ZEt)for(const d of l)Object.defineProperty(this,d,{get:()=>{const h=i(n),f=a[o]-h;return this.rect[d]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class yI{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 YEt(t){const{EventTarget:s}=gm(t);return t instanceof s?t:Y3(t)}function $he(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 Lp;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Lp||(Lp={}));function _Me(t){t.preventDefault()}function XEt(t){t.stopPropagation()}var mo;(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"})(mo||(mo={}));const fHe={start:[mo.Space,mo.Enter],cancel:[mo.Esc],end:[mo.Space,mo.Enter,mo.Tab]},QEt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case mo.Right:return{...r,x:r.x+25};case mo.Left:return{...r,x:r.x-25};case mo.Down:return{...r,y:r.y+25};case mo.Up:return{...r,y:r.y-25}}};class U_e{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 yI(Y3(r)),this.windowListeners=new yI(gm(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Lp.Resize,this.handleCancel),this.windowListeners.add(Lp.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Lp.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&KEt(n),r(Mg)}handleKeyDown(s){if(B_e(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=fHe,coordinateGetter:l=QEt,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:h}=n.current,f=h?{x:h.left,y:h.top}:Mg;this.referenceCoordinates||(this.referenceCoordinates=f);const g=l(s,{active:r,context:n.current,currentCoordinates:f});if(g){const v=kP(g,f),_={x:0,y:0},{scrollableAncestors:j}=n.current;for(const w of j){const k=s.code,{isTop:M,isRight:S,isLeft:E,isBottom:D,maxScroll:L,minScroll:B}=mHe(w),$=HEt(w),V={x:Math.min(k===mo.Right?$.right-$.width/2:$.right,Math.max(k===mo.Right?$.left:$.left+$.width/2,g.x)),y:Math.min(k===mo.Down?$.bottom-$.height/2:$.bottom,Math.max(k===mo.Down?$.top:$.top+$.height/2,g.y))},W=k===mo.Right&&!S||k===mo.Left&&!E,G=k===mo.Down&&!D||k===mo.Up&&!M;if(W&&V.x!==g.x){const J=w.scrollLeft+v.x,ne=k===mo.Right&&J<=L.x||k===mo.Left&&J>=B.x;if(ne&&!v.y){w.scrollTo({left:J,behavior:i});return}ne?_.x=w.scrollLeft-J:_.x=k===mo.Right?w.scrollLeft-L.x:w.scrollLeft-B.x,_.x&&w.scrollBy({left:-_.x,behavior:i});break}else if(G&&V.y!==g.y){const J=w.scrollTop+v.y,ne=k===mo.Down&&J<=L.y||k===mo.Up&&J>=B.y;if(ne&&!v.x){w.scrollTo({top:J,behavior:i});return}ne?_.y=w.scrollTop-J:_.y=k===mo.Down?w.scrollTop-L.y:w.scrollTop-B.y,_.y&&w.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,a5(kP(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()}}U_e.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=fHe,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 bMe(t){return!!(t&&"distance"in t)}function wMe(t){return!!(t&&"delay"in t)}class q_e{constructor(s,r,n){var a;n===void 0&&(n=YEt(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=Y3(l),this.documentListeners=new yI(this.document),this.listeners=new yI(n),this.windowListeners=new yI(gm(l)),this.initialCoordinates=(a=Uge(o))!=null?a:Mg,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(Lp.Resize,this.handleCancel),this.windowListeners.add(Lp.DragStart,_Me),this.windowListeners.add(Lp.VisibilityChange,this.handleCancel),this.windowListeners.add(Lp.ContextMenu,_Me),this.documentListeners.add(Lp.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(wMe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(bMe(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(Lp.Click,XEt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Lp.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=Uge(s))!=null?r:Mg,h=kP(a,d);if(!n&&i){if(bMe(i)){if(i.tolerance!=null&&$he(h,i.tolerance))return this.handleCancel();if($he(h,i.distance))return this.handleStart()}if(wMe(i)&&$he(h,i.tolerance))return this.handleCancel();this.handlePending(i,h);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===mo.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const JEt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class V_e extends q_e{constructor(s){const{event:r}=s,n=Y3(r.target);super(s,JEt,n)}}V_e.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 eIt={move:{name:"mousemove"},end:{name:"mouseup"}};var Vge;(function(t){t[t.RightClick=2]="RightClick"})(Vge||(Vge={}));class tIt extends q_e{constructor(s){super(s,eIt,Y3(s.event.target))}}tIt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===Vge.RightClick?!1:(n==null||n({event:r}),!0)}}];const Uhe={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class sIt extends q_e{constructor(s){super(s,Uhe)}static setup(){return window.addEventListener(Uhe.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Uhe.move.name,s)};function s(){}}}sIt.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 vI;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(vI||(vI={}));var $ne;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})($ne||($ne={}));function rIt(t){let{acceleration:s,activator:r=vI.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=$ne.TreeOrder,pointerCoordinates:d,scrollableAncestors:h,scrollableAncestorRects:f,delta:g,threshold:v}=t;const _=aIt({delta:g,disabled:!o}),[j,w]=fEt(),k=T.useRef({x:0,y:0}),M=T.useRef({x:0,y:0}),S=T.useMemo(()=>{switch(r){case vI.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case vI.DraggableRect:return a}},[r,a,d]),E=T.useRef(null),D=T.useCallback(()=>{const B=E.current;if(!B)return;const $=k.current.x*M.current.x,V=k.current.y*M.current.y;B.scrollBy($,V)},[]),L=T.useMemo(()=>i===$ne.TreeOrder?[...h].reverse():h,[i,h]);T.useEffect(()=>{if(!o||!h.length||!S){w();return}for(const B of L){if((n==null?void 0:n(B))===!1)continue;const $=h.indexOf(B),V=f[$];if(!V)continue;const{direction:W,speed:G}=VEt(B,V,S,s,v);for(const J of["x","y"])_[J][W[J]]||(G[J]=0,W[J]=0);if(G.x>0||G.y>0){w(),E.current=B,j(D,l),k.current=G,M.current=W;return}}k.current={x:0,y:0},M.current={x:0,y:0},w()},[s,D,n,w,o,l,JSON.stringify(S),JSON.stringify(_),j,h,L,f,JSON.stringify(v)])}const nIt={x:{[Gd.Backward]:!1,[Gd.Forward]:!1},y:{[Gd.Backward]:!1,[Gd.Forward]:!1}};function aIt(t){let{delta:s,disabled:r}=t;const n=$ge(s);return eL(a=>{if(r||!n||!a)return nIt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Gd.Backward]:a.x[Gd.Backward]||o.x===-1,[Gd.Forward]:a.x[Gd.Forward]||o.x===1},y:{[Gd.Backward]:a.y[Gd.Backward]||o.y===-1,[Gd.Forward]:a.y[Gd.Forward]||o.y===1}}},[r,s,n])}function iIt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return eL(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function oIt(t,s){return T.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 SP;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(SP||(SP={}));var Hge;(function(t){t.Optimized="optimized"})(Hge||(Hge={}));const jMe=new Map;function lIt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=T.useState(null),{frequency:i,measure:d,strategy:h}=a,f=T.useRef(t),g=k(),v=jP(g),_=T.useCallback(function(M){M===void 0&&(M=[]),!v.current&&l(S=>S===null?M:S.concat(M.filter(E=>!S.includes(E))))},[v]),j=T.useRef(null),w=eL(M=>{if(g&&!r)return jMe;if(!M||M===jMe||f.current!==t||o!=null){const S=new Map;for(let E of t){if(!E)continue;if(o&&o.length>0&&!o.includes(E.id)&&E.rect.current){S.set(E.id,E.rect.current);continue}const D=E.node.current,L=D?new $_e(d(D),D):null;E.rect.current=L,L&&S.set(E.id,L)}return S}return M},[t,o,r,g,d]);return T.useEffect(()=>{f.current=t},[t]),T.useEffect(()=>{g||_()},[r,g]),T.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),T.useEffect(()=>{g||typeof i!="number"||j.current!==null||(j.current=setTimeout(()=>{_(),j.current=null},i))},[i,g,_,...n]),{droppableRects:w,measureDroppableContainers:_,measuringScheduled:o!=null};function k(){switch(h){case SP.Always:return!1;case SP.BeforeDragging:return r;default:return!r}}}function gHe(t,s){return eL(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function cIt(t,s){return gHe(t,s)}function dIt(t){let{callback:s,disabled:r}=t;const n=z_e(s),a=T.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return T.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Loe(t){let{callback:s,disabled:r}=t;const n=z_e(s),a=T.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return T.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function uIt(t){return new $_e(X3(t),t)}function kMe(t,s,r){s===void 0&&(s=uIt);const[n,a]=T.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var h;return(h=d??r)!=null?h:null}const f=s(t);return JSON.stringify(d)===JSON.stringify(f)?d:f})}const l=dIt({callback(d){if(t)for(const h of d){const{type:f,target:g}=h;if(f==="childList"&&g instanceof HTMLElement&&g.contains(t)){o();break}}}}),i=Loe({callback:o});return Ux(()=>{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 hIt(t){const s=gHe(t);return lHe(t,s)}const NMe=[];function mIt(t){const s=T.useRef(t),r=eL(n=>t?n&&n!==NMe&&t&&s.current&&t.parentNode===s.current.parentNode?n:Poe(t):NMe,[t]);return T.useEffect(()=>{s.current=t},[t]),r}function pIt(t){const[s,r]=T.useState(null),n=T.useRef(t),a=T.useCallback(o=>{const l=Bhe(o.target);l&&r(i=>i?(i.set(l,qge(l)),new Map(i)):null)},[]);return T.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const h=Bhe(d);return h?(h.addEventListener("scroll",a,{passive:!0}),[h,qge(h)]):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 h=Bhe(d);h==null||h.removeEventListener("scroll",a)})}},[a,t]),T.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>a5(o,l),Mg):pHe(t):Mg,[t,s])}function SMe(t,s){s===void 0&&(s=[]);const r=T.useRef(null);return T.useEffect(()=>{r.current=null},s),T.useEffect(()=>{const n=t!==Mg;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?kP(t,r.current):Mg}function fIt(t){T.useEffect(()=>{if(!Ioe)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 gIt(t,s){return T.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function xHe(t){return T.useMemo(()=>t?BEt(t):null,[t])}const CMe=[];function xIt(t,s){s===void 0&&(s=X3);const[r]=t,n=xHe(r?gm(r):null),[a,o]=T.useState(CMe);function l(){o(()=>t.length?t.map(d=>hHe(d)?n:new $_e(s(d),d)):CMe)}const i=Loe({callback:l});return Ux(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function yIt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return J6(s)?s:t}function vIt(t){let{measure:s}=t;const[r,n]=T.useState(null),a=T.useCallback(h=>{for(const{target:f}of h)if(J6(f)){n(g=>{const v=s(f);return g?{...g,width:v.width,height:v.height}:v});break}},[s]),o=Loe({callback:a}),l=T.useCallback(h=>{const f=yIt(h);o==null||o.disconnect(),f&&(o==null||o.observe(f)),n(f?s(f):null)},[s,o]),[i,d]=zne(l);return T.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const _It=[{sensor:V_e,options:{}},{sensor:U_e,options:{}}],bIt={current:{}},Lse={draggable:{measure:vMe},droppable:{measure:vMe,strategy:SP.WhileDragging,frequency:Hge.Optimized},dragOverlay:{measure:X3}};class _I 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 wIt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new _I,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Bne},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Lse,measureDroppableContainers:Bne,windowRect:null,measuringScheduled:!1},jIt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Bne,draggableNodes:new Map,over:null,measureDroppableContainers:Bne},Doe=T.createContext(jIt),yHe=T.createContext(wIt);function kIt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new _I}}}function NIt(t,s){switch(s.type){case kd.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case kd.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 kd.DragEnd:case kd.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case kd.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new _I(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case kd.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 _I(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case kd.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new _I(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function SIt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=T.useContext(Doe),o=$ge(n),l=$ge(r==null?void 0:r.id);return T.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!B_e(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:d,node:h}=i;if(!d.current&&!h.current)return;requestAnimationFrame(()=>{for(const f of[d.current,h.current]){if(!f)continue;const g=yEt(f);if(g){g.focus();break}}})}},[n,s,a,l,o]),null}function CIt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function MIt(t){return T.useMemo(()=>({draggable:{...Lse.draggable,...t==null?void 0:t.draggable},droppable:{...Lse.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Lse.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 TIt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=T.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;Ux(()=>{if(!l&&!i||!s){o.current=!1;return}if(o.current||!n)return;const h=s==null?void 0:s.node.current;if(!h||h.isConnected===!1)return;const f=r(h),g=lHe(f,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=cHe(h);v&&v.scrollBy({top:g.y,left:g.x})}},[s,l,i,n,r])}const vHe=T.createContext({...Mg,scaleX:1,scaleY:1});var zv;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(zv||(zv={}));const AIt=T.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:h,sensors:f=_It,collisionDetection:g=PEt,measuring:v,modifiers:_,...j}=s;const w=T.useReducer(NIt,void 0,kIt),[k,M]=w,[S,E]=kEt(),[D,L]=T.useState(zv.Uninitialized),B=D===zv.Initialized,{draggable:{active:$,nodes:V,translate:W},droppable:{containers:G}}=k,J=$!=null?V.get($):null,ne=T.useRef({initial:null,translated:null}),ie=T.useMemo(()=>{var Ia;return $!=null?{id:$,data:(Ia=J==null?void 0:J.data)!=null?Ia:bIt,rect:ne}:null},[$,J]),ee=T.useRef(null),[de,oe]=T.useState(null),[ue,ce]=T.useState(null),ge=jP(j,Object.values(j)),Te=tL("DndDescribedBy",l),ve=T.useMemo(()=>G.getEnabled(),[G]),ye=MIt(v),{droppableRects:Se,measureDroppableContainers:Ke,measuringScheduled:Ae}=lIt(ve,{dragging:B,dependencies:[W.x,W.y],config:ye.droppable}),Ee=iIt(V,$),He=T.useMemo(()=>ue?Uge(ue):null,[ue]),Ue=go(),De=cIt(Ee,ye.draggable.measure);TIt({activeNode:$!=null?V.get($):null,config:Ue.layoutShiftCompensation,initialRect:De,measure:ye.draggable.measure});const Ge=kMe(Ee,ye.draggable.measure,De),wt=kMe(Ee?Ee.parentElement:null),Ie=T.useRef({activatorEvent:null,active:null,activeNode:Ee,collisionRect:null,collisions:null,droppableRects:Se,draggableNodes:V,draggingNode:null,draggingNodeRect:null,droppableContainers:G,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),st=G.getNodeFor((r=Ie.current.over)==null?void 0:r.id),he=vIt({measure:ye.dragOverlay.measure}),We=(n=he.nodeRef.current)!=null?n:Ee,et=B?(a=he.rect)!=null?a:Ge:null,Ye=!!(he.nodeRef.current&&he.rect),ke=hIt(Ye?null:Ge),at=xHe(We?gm(We):null),Fe=mIt(B?st??Ee:null),it=xIt(Fe),dt=CIt(_,{transform:{x:W.x-ke.x,y:W.y-ke.y,scaleX:1,scaleY:1},activatorEvent:ue,active:ie,activeNodeRect:Ge,containerNodeRect:wt,draggingNodeRect:et,over:Ie.current.over,overlayNodeRect:he.rect,scrollableAncestors:Fe,scrollableAncestorRects:it,windowRect:at}),tt=He?a5(He,W):null,ut=pIt(Fe),xt=SMe(ut),_t=SMe(ut,[Ge]),qe=a5(dt,xt),Lt=et?OEt(et,dt):null,Rt=ie&&Lt?g({active:ie,collisionRect:Lt,droppableRects:Se,droppableContainers:ve,pointerCoordinates:tt}):null,Kt=oHe(Rt,"id"),[Xt,ss]=T.useState(null),fs=Ye?dt:a5(dt,_t),fr=LEt(fs,(o=Xt==null?void 0:Xt.rect)!=null?o:null,Ge),yt=T.useRef(null),bs=T.useCallback((Ia,nn)=>{let{sensor:Qt,options:lr}=nn;if(ee.current==null)return;const Vr=V.get(ee.current);if(!Vr)return;const Pr=Ia.nativeEvent,on=new Qt({active:ee.current,activeNode:Vr,event:Pr,options:lr,context:Ie,onAbort(ka){if(!V.get(ka))return;const{onDragAbort:li}=ge.current,Or={id:ka};li==null||li(Or),S({type:"onDragAbort",event:Or})},onPending(ka,zi,li,Or){if(!V.get(ka))return;const{onDragPending:Rc}=ge.current,Co={id:ka,constraint:zi,initialCoordinates:li,offset:Or};Rc==null||Rc(Co),S({type:"onDragPending",event:Co})},onStart(ka){const zi=ee.current;if(zi==null)return;const li=V.get(zi);if(!li)return;const{onDragStart:Or}=ge.current,Oi={activatorEvent:Pr,active:{id:zi,data:li.data,rect:ne}};Qh.unstable_batchedUpdates(()=>{Or==null||Or(Oi),L(zv.Initializing),M({type:kd.DragStart,initialCoordinates:ka,active:zi}),S({type:"onDragStart",event:Oi}),oe(yt.current),ce(Pr)})},onMove(ka){M({type:kd.DragMove,coordinates:ka})},onEnd:cs(kd.DragEnd),onCancel:cs(kd.DragCancel)});yt.current=on;function cs(ka){return async function(){const{active:li,collisions:Or,over:Oi,scrollAdjustedTranslate:Rc}=Ie.current;let Co=null;if(li&&Rc){const{cancelDrop:Fc}=ge.current;Co={activatorEvent:Pr,active:li,collisions:Or,delta:Rc,over:Oi},ka===kd.DragEnd&&typeof Fc=="function"&&await Promise.resolve(Fc(Co))&&(ka=kd.DragCancel)}ee.current=null,Qh.unstable_batchedUpdates(()=>{M({type:ka}),L(zv.Uninitialized),ss(null),oe(null),ce(null),yt.current=null;const Fc=ka===kd.DragEnd?"onDragEnd":"onDragCancel";if(Co){const rt=ge.current[Fc];rt==null||rt(Co),S({type:Fc,event:Co})}})}}},[V]),gr=T.useCallback((Ia,nn)=>(Qt,lr)=>{const Vr=Qt.nativeEvent,Pr=V.get(lr);if(ee.current!==null||!Pr||Vr.dndKit||Vr.defaultPrevented)return;const on={active:Pr};Ia(Qt,nn.options,on)===!0&&(Vr.dndKit={capturedBy:nn.sensor},ee.current=lr,bs(Qt,nn))},[V,bs]),Br=oIt(f,gr);fIt(f),Ux(()=>{Ge&&D===zv.Initializing&&L(zv.Initialized)},[Ge,D]),T.useEffect(()=>{const{onDragMove:Ia}=ge.current,{active:nn,activatorEvent:Qt,collisions:lr,over:Vr}=Ie.current;if(!nn||!Qt)return;const Pr={active:nn,activatorEvent:Qt,collisions:lr,delta:{x:qe.x,y:qe.y},over:Vr};Qh.unstable_batchedUpdates(()=>{Ia==null||Ia(Pr),S({type:"onDragMove",event:Pr})})},[qe.x,qe.y]),T.useEffect(()=>{const{active:Ia,activatorEvent:nn,collisions:Qt,droppableContainers:lr,scrollAdjustedTranslate:Vr}=Ie.current;if(!Ia||ee.current==null||!nn||!Vr)return;const{onDragOver:Pr}=ge.current,on=lr.get(Kt),cs=on&&on.rect.current?{id:on.id,rect:on.rect.current,data:on.data,disabled:on.disabled}:null,ka={active:Ia,activatorEvent:nn,collisions:Qt,delta:{x:Vr.x,y:Vr.y},over:cs};Qh.unstable_batchedUpdates(()=>{ss(cs),Pr==null||Pr(ka),S({type:"onDragOver",event:ka})})},[Kt]),Ux(()=>{Ie.current={activatorEvent:ue,active:ie,activeNode:Ee,collisionRect:Lt,collisions:Rt,droppableRects:Se,draggableNodes:V,draggingNode:We,draggingNodeRect:et,droppableContainers:G,over:Xt,scrollableAncestors:Fe,scrollAdjustedTranslate:qe},ne.current={initial:et,translated:Lt}},[ie,Ee,Rt,Lt,V,We,et,Se,G,Xt,Fe,qe]),rIt({...Ue,delta:W,draggingRect:Lt,pointerCoordinates:tt,scrollableAncestors:Fe,scrollableAncestorRects:it});const na=T.useMemo(()=>({active:ie,activeNode:Ee,activeNodeRect:Ge,activatorEvent:ue,collisions:Rt,containerNodeRect:wt,dragOverlay:he,draggableNodes:V,droppableContainers:G,droppableRects:Se,over:Xt,measureDroppableContainers:Ke,scrollableAncestors:Fe,scrollableAncestorRects:it,measuringConfiguration:ye,measuringScheduled:Ae,windowRect:at}),[ie,Ee,Ge,ue,Rt,wt,he,V,G,Se,Xt,Ke,Fe,it,ye,Ae,at]),za=T.useMemo(()=>({activatorEvent:ue,activators:Br,active:ie,activeNodeRect:Ge,ariaDescribedById:{draggable:Te},dispatch:M,draggableNodes:V,over:Xt,measureDroppableContainers:Ke}),[ue,Br,ie,Ge,M,Te,V,Xt,Ke]);return lt.createElement(nHe.Provider,{value:E},lt.createElement(Doe.Provider,{value:za},lt.createElement(yHe.Provider,{value:na},lt.createElement(vHe.Provider,{value:fr},h)),lt.createElement(SIt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),lt.createElement(CEt,{...i,hiddenTextDescribedById:Te}));function go(){const Ia=(de==null?void 0:de.autoScrollEnabled)===!1,nn=typeof d=="object"?d.enabled===!1:d===!1,Qt=B&&!Ia&&!nn;return typeof d=="object"?{...d,enabled:Qt}:{enabled:Qt}}}),EIt=T.createContext(null),MMe="button",IIt="Draggable";function PIt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=tL(IIt),{activators:l,activatorEvent:i,active:d,activeNodeRect:h,ariaDescribedById:f,draggableNodes:g,over:v}=T.useContext(Doe),{role:_=MMe,roleDescription:j="draggable",tabIndex:w=0}=a??{},k=(d==null?void 0:d.id)===s,M=T.useContext(k?vHe:EIt),[S,E]=zne(),[D,L]=zne(),B=gIt(l,s),$=jP(r);Ux(()=>(g.set(s,{id:s,key:o,node:S,activatorNode:D,data:$}),()=>{const W=g.get(s);W&&W.key===o&&g.delete(s)}),[g,s]);const V=T.useMemo(()=>({role:_,tabIndex:w,"aria-disabled":n,"aria-pressed":k&&_===MMe?!0:void 0,"aria-roledescription":j,"aria-describedby":f.draggable}),[n,_,w,k,j,f.draggable]);return{active:d,activatorEvent:i,activeNodeRect:h,attributes:V,isDragging:k,listeners:n?void 0:B,node:S,over:v,setNodeRef:E,setActivatorNodeRef:L,transform:M}}function LIt(){return T.useContext(yHe)}const DIt="Droppable",OIt={timeout:25};function RIt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=tL(DIt),{active:l,dispatch:i,over:d,measureDroppableContainers:h}=T.useContext(Doe),f=T.useRef({disabled:r}),g=T.useRef(!1),v=T.useRef(null),_=T.useRef(null),{disabled:j,updateMeasurementsFor:w,timeout:k}={...OIt,...a},M=jP(w??n),S=T.useCallback(()=>{if(!g.current){g.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{h(Array.isArray(M.current)?M.current:[M.current]),_.current=null},k)},[k]),E=Loe({callback:S,disabled:j||!l}),D=T.useCallback((V,W)=>{E&&(W&&(E.unobserve(W),g.current=!1),V&&E.observe(V))},[E]),[L,B]=zne(D),$=jP(s);return T.useEffect(()=>{!E||!L.current||(E.disconnect(),g.current=!1,E.observe(L.current))},[L,E]),T.useEffect(()=>(i({type:kd.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:v,data:$}}),()=>i({type:kd.UnregisterDroppable,key:o,id:n})),[n]),T.useEffect(()=>{r!==f.current.disabled&&(i({type:kd.SetDroppableDisabled,id:n,key:o,disabled:r}),f.current.disabled=r)},[n,o,r,i]),{active:l,rect:v,isOver:(d==null?void 0:d.id)===n,node:L,over:d,setNodeRef:B}}function H_e(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function FIt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function m8(t){return t!==null&&t>=0}function zIt(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let r=0;r{let{rects:s,activeIndex:r,overIndex:n,index:a}=t;const o=H_e(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}},_He="Sortable",bHe=lt.createContext({activeIndex:-1,containerId:_He,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:W_e,disabled:{draggable:!1,droppable:!1}});function $It(t){let{children:s,id:r,items:n,strategy:a=W_e,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:d,over:h,measureDroppableContainers:f}=LIt(),g=tL(_He,r),v=i.rect!==null,_=T.useMemo(()=>n.map(B=>typeof B=="object"&&"id"in B?B.id:B),[n]),j=l!=null,w=l?_.indexOf(l.id):-1,k=h?_.indexOf(h.id):-1,M=T.useRef(_),S=!zIt(_,M.current),E=k!==-1&&w===-1||S,D=BIt(o);Ux(()=>{S&&j&&f(_)},[S,_,j,f]),T.useEffect(()=>{M.current=_},[_]);const L=T.useMemo(()=>({activeIndex:w,containerId:g,disabled:D,disableTransforms:E,items:_,overIndex:k,useDragOverlay:v,sortedRects:FIt(_,d),strategy:a}),[w,g,D.draggable,D.droppable,E,_,k,d,v,a]);return lt.createElement(bHe.Provider,{value:L},s)}const UIt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return H_e(r,n,a).indexOf(s)},qIt=t=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:d,transition:h}=t;return!h||!n||i!==o&&a===l?!1:r?!0:l!==a&&s===d},VIt={duration:200,easing:"ease"},wHe="transform",HIt=NP.Transition.toString({property:wHe,duration:0,easing:"linear"}),WIt={roleDescription:"sortable"};function GIt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=T.useState(null),i=T.useRef(r);return Ux(()=>{if(!s&&r!==i.current&&n.current){const d=a.current;if(d){const h=X3(n.current,{ignoreTransform:!0}),f={x:d.left-h.left,y:d.top-h.top,scaleX:d.width/h.width,scaleY:d.height/h.height};(f.x||f.y)&&l(f)}}r!==i.current&&(i.current=r)},[s,r,n,a]),T.useEffect(()=>{o&&l(null)},[o]),o}function KIt(t){let{animateLayoutChanges:s=qIt,attributes:r,disabled:n,data:a,getNewIndex:o=UIt,id:l,strategy:i,resizeObserverConfig:d,transition:h=VIt}=t;const{items:f,containerId:g,activeIndex:v,disabled:_,disableTransforms:j,sortedRects:w,overIndex:k,useDragOverlay:M,strategy:S}=T.useContext(bHe),E=ZIt(n,_),D=f.indexOf(l),L=T.useMemo(()=>({sortable:{containerId:g,index:D,items:f},...a}),[g,a,D,f]),B=T.useMemo(()=>f.slice(f.indexOf(l)),[f,l]),{rect:$,node:V,isOver:W,setNodeRef:G}=RIt({id:l,data:L,disabled:E.droppable,resizeObserverConfig:{updateMeasurementsFor:B,...d}}),{active:J,activatorEvent:ne,activeNodeRect:ie,attributes:ee,setNodeRef:de,listeners:oe,isDragging:ue,over:ce,setActivatorNodeRef:ge,transform:Te}=PIt({id:l,data:L,attributes:{...WIt,...r},disabled:E.draggable}),ve=pEt(G,de),ye=!!J,Se=ye&&!j&&m8(v)&&m8(k),Ke=!M&&ue,Ae=Ke&&Se?Te:null,He=Se?Ae??(i??S)({rects:w,activeNodeRect:ie,activeIndex:v,overIndex:k,index:D}):null,Ue=m8(v)&&m8(k)?o({id:l,items:f,activeIndex:v,overIndex:k}):D,De=J==null?void 0:J.id,Ge=T.useRef({activeId:De,items:f,newIndex:Ue,containerId:g}),wt=f!==Ge.current.items,Ie=s({active:J,containerId:g,isDragging:ue,isSorting:ye,id:l,index:D,items:f,newIndex:Ge.current.newIndex,previousItems:Ge.current.items,previousContainerId:Ge.current.containerId,transition:h,wasDragging:Ge.current.activeId!=null}),st=GIt({disabled:!Ie,index:D,node:V,rect:$});return T.useEffect(()=>{ye&&Ge.current.newIndex!==Ue&&(Ge.current.newIndex=Ue),g!==Ge.current.containerId&&(Ge.current.containerId=g),f!==Ge.current.items&&(Ge.current.items=f)},[ye,Ue,g,f]),T.useEffect(()=>{if(De===Ge.current.activeId)return;if(De!=null&&Ge.current.activeId==null){Ge.current.activeId=De;return}const We=setTimeout(()=>{Ge.current.activeId=De},50);return()=>clearTimeout(We)},[De]),{active:J,activeIndex:v,attributes:ee,data:L,rect:$,index:D,newIndex:Ue,items:f,isOver:W,isSorting:ye,isDragging:ue,listeners:oe,node:V,overIndex:k,over:ce,setNodeRef:ve,setActivatorNodeRef:ge,setDroppableNodeRef:G,setDraggableNodeRef:de,transform:st??He,transition:he()};function he(){if(st||wt&&Ge.current.newIndex===D)return HIt;if(!(Ke&&!B_e(ne)||!h)&&(ye||Ie))return NP.Transition.toString({...h,property:wHe})}}function ZIt(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 Une(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 YIt=[mo.Down,mo.Right,mo.Up,mo.Left],XIt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(YIt.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 mo.Down:n.topv.top&&d.push(g);break;case mo.Left:n.left>v.left&&d.push(g);break;case mo.Right:n.left1&&(f=h[1].id),f!=null){const g=o.get(r.id),v=o.get(f),_=v?a.get(v.id):null,j=v==null?void 0:v.node.current;if(j&&_&&g&&v){const k=Poe(j).some((B,$)=>i[$]!==B),M=jHe(g,v),S=QIt(g,v),E=k||!M?{x:0,y:0}:{x:S?n.width-_.width:0,y:S?n.height-_.height:0},D={x:_.left,y:_.top};return E.x&&E.y?D:kP(D,E)}}}};function jHe(t,s){return!Une(t)||!Une(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function QIt(t,s){return!Une(t)||!Une(s)||!jHe(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(Xa,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(ct,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(xn,{className:"h-2.5 w-2.5"}),Bs(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs($e,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",size:"sm",className:$t("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(xn,{className:"h-3 w-3"}),t.post_date?Bs(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(nl,{className:"w-auto p-0",align:"start",children:[e.jsx(Qp,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:g=>n(t.id,g?Bs(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(Y,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const ePt=()=>{const t=vs(),[s,r]=T.useState("all"),[n,a]=T.useState(!1),[o,l]=T.useState(Bs(new Date,"yyyy-MM")),[i,d]=T.useState([]),[h,f]=T.useState(!1),[g,v]=T.useState(null),[_,j]=T.useState(null),[w,k]=T.useState(""),[M,S]=T.useState(null),[E,D]=T.useState(!1),[L,B]=T.useState(!1),[$,V]=T.useState(Bs(new Date,"yyyy-MM")),[W,G]=T.useState(null),[J,ne]=T.useState(""),[ie,ee]=T.useState(""),[de,oe]=T.useState(""),[ue,ce]=T.useState(!1),ge=MEt(gMe(V_e,{activationConstraint:{distance:5}}),gMe(U_e,{coordinateGetter:XIt})),{data:Te=[],isLoading:ve}=zt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:tt,error:ut}=await Z.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ut)throw ut;return tt}}),{data:ye=[]}=zt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:tt,error:ut}=await Z.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ut)throw ut;return tt}}),{data:Se=[]}=zt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:tt,error:ut}=await Z.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ut)throw ut;return tt}}),Ke=[...new Set(Te.map(tt=>tt.month))].sort((tt,ut)=>ut.localeCompare(tt)),Ae=s==="all"?Te:Te.filter(tt=>tt.month===s),Ee=tt=>{const ut=r1e(tt,"yyyy-MM",new Date);return Bs(ut,"MMMM yyyy")},He=tt=>{j(tt),k(tt.caption),S(tt.post_date)},Ue=async()=>{if(_){D(!0);try{const{error:tt}=await Z.from("social_swag_2").update({caption:w,post_date:M}).eq("id",_.id);if(tt)throw tt;be.success("Image updated"),j(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{be.error("Failed to update image")}finally{D(!1)}}},De=async tt=>{const{active:ut,over:xt}=tt;if(!xt||ut.id===xt.id)return;const _t=Ae,qe=_t.findIndex(Kt=>Kt.id===ut.id),Lt=_t.findIndex(Kt=>Kt.id===xt.id);if(qe===-1||Lt===-1)return;const Rt=H_e(_t,qe,Lt);t.setQueryData(["admin-social-swag-2"],Kt=>{if(!Kt)return Kt;const Xt={};return Rt.forEach((ss,fs)=>{Xt[ss.id]=fs}),Kt.map(ss=>Xt[ss.id]!==void 0?{...ss,sort_order:Xt[ss.id]}:ss).sort((ss,fs)=>ss.month!==fs.month?fs.month.localeCompare(ss.month):ss.sort_order-fs.sort_order)});try{await Promise.all(Rt.map((Kt,Xt)=>Z.from("social_swag_2").update({sort_order:Xt}).eq("id",Kt.id)))}catch{be.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Ge=tt=>{const xt=Array.from(tt.target.files||[]).slice(0,16-i.length).map(_t=>({file:_t,preview:URL.createObjectURL(_t),caption:""}));d(_t=>[..._t,...xt].slice(0,16))},wt=tt=>{d(ut=>{const xt=[...ut];return URL.revokeObjectURL(xt[tt].preview),xt.splice(tt,1),xt})},Ie=(tt,ut)=>{d(xt=>{const _t=[...xt];return _t[tt]={..._t[tt],caption:ut},_t})},st=async()=>{if(i.length===0){be.error("Please add at least one image");return}if(i.filter(ut=>!ut.caption.trim()).length>0){be.error("Please add captions to all images");return}f(!0);try{for(let ut=0;ut{const ut=tt.image_url.split("/social-swag-2/");ut[1]&&await Z.storage.from("social-swag-2").remove([ut[1]]);const{error:xt}=await Z.from("social_swag_2").delete().eq("id",tt.id);if(xt)throw xt},onSuccess:()=>{be.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>be.error("Failed to delete image")}),We=Wt({mutationFn:async({id:tt,postDate:ut})=>{const{error:xt}=await Z.from("social_swag_2").update({post_date:ut}).eq("id",tt);if(xt)throw xt},onSuccess:()=>{be.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>be.error("Failed to update post date")}),et=Wt({mutationFn:async({month:tt,link:ut})=>{const{error:xt}=await Z.from("social_swag_2_months").upsert({month:tt,canva_link:ut||null},{onConflict:"month"});if(xt)throw xt},onSuccess:()=>{be.success("Canva link updated"),v(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>be.error("Failed to update Canva link")}),Ye=tt=>{var ut;return((ut=ye.find(xt=>xt.month===tt))==null?void 0:ut.canva_link)||""},ke=tt=>Se.find(ut=>ut.month===tt)||null,at=tt=>{var xt;const ut=(xt=tt.target.files)==null?void 0:xt[0];ut&&(G(ut),ne(URL.createObjectURL(ut)))},Fe=()=>{J&&URL.revokeObjectURL(J),G(null),ne(""),ee(""),oe("")},it=async()=>{if(!W){be.error("Please select an image");return}ce(!0);try{const tt=W.name.split(".").pop(),ut=`reels/${$}-${Date.now()}.${tt}`,{error:xt}=await Z.storage.from("social-swag-2").upload(ut,W);if(xt)throw xt;const{data:{publicUrl:_t}}=Z.storage.from("social-swag-2").getPublicUrl(ut),{error:qe}=await Z.from("social_swag_2_reels").upsert({month:$,image_url:_t,canva_link:de||null,caption:ie||null},{onConflict:"month"});if(qe)throw qe;be.success("Reel uploaded successfully!"),Bge(`${Ee($)} Reel`,"social-swag-2"),Fe(),B(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(tt){console.error("Reel upload error:",tt),be.error("Failed to upload reel")}finally{ce(!1)}},dt=Wt({mutationFn:async tt=>{const ut=tt.image_url.split("/social-swag-2/");ut[1]&&await Z.storage.from("social-swag-2").remove([ut[1]]);const{error:xt}=await Z.from("social_swag_2_reels").delete().eq("id",tt.id);if(xt)throw xt},onSuccess:()=>{be.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>be.error("Failed to delete reel")});return e.jsxs(Vs,{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(js,{open:n,onOpenChange:a,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(_s,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Month"}),e.jsx(Be,{type:"month",value:o,onChange:tt=>l(tt.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{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:Ge,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(ji,{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((tt,ut)=>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:tt.preview,alt:`Upload ${ut+1}`,className:"w-full h-full object-cover"}),e.jsx(Y,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>wt(ut),children:e.jsx(Xr,{className:"h-3 w-3"})})]}),e.jsx(Rr,{placeholder:"Caption...",value:tt.caption,onChange:xt=>Ie(ut,xt.target.value),className:"text-xs h-20"})]},ut))}),e.jsx(Y,{onClick:st,disabled:h||i.length===0,className:"w-full gap-2",children:h?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ji,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(js,{open:L,onOpenChange:tt=>{B(tt),tt||Fe()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:"gap-2",children:[e.jsx(Wd,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(_s,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Month"}),e.jsx(Be,{type:"month",value:$,onChange:tt=>V(tt.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Reel Preview Image"}),J?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:J,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(Y,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(J),G(null),ne("")},children:e.jsx(Xr,{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:at,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(Wd,{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(je,{children:"Canva Download Link"}),e.jsx(Be,{value:de,onChange:tt=>oe(tt.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Caption"}),e.jsx(Rr,{value:ie,onChange:tt=>ee(tt.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(Y,{onClick:it,disabled:ue||!W,className:"w-full gap-2",children:ue?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ji,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Te.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Oe,{children:e.jsxs($e,{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(Qa,{value:s,onValueChange:r,children:e.jsxs(Ga,{children:[e.jsx(Fs,{value:"all",children:"All"}),Ke.map(tt=>e.jsx(Fs,{value:tt,children:Ee(tt)},tt))]})}),s!=="all"&&e.jsx(Oe,{children:e.jsx($e,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Ro,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(je,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Ee(s)]}),(g==null?void 0:g.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Be,{value:g.link,onChange:tt=>v({...g,link:tt.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(Y,{size:"sm",onClick:()=>et.mutate(g),children:"Save"}),e.jsx(Y,{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:Ye(s)||"No link set"}),e.jsx(Y,{size:"sm",variant:"outline",onClick:()=>v({month:s,link:Ye(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Oe,{children:e.jsx($e,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(Wd,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(je,{className:"text-sm text-muted-foreground",children:["Reel for ",Ee(s)]}),(()=>{const tt=ke(s);return tt?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:tt.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:tt.caption||"No caption"}),tt.canva_link&&e.jsx("a",{href:tt.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>dt.mutate(tt),children:e.jsx(Ir,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),ve?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):Ae.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(fl,{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(AIt,{sensors:ge,collisionDetection:AEt,onDragEnd:De,children:e.jsx($It,{items:Ae.map(tt=>tt.id),strategy:W_e,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Ae.map(tt=>e.jsx(JIt,{item:tt,onEdit:He,onDelete:ut=>he.mutate(ut),onDateChange:(ut,xt)=>We.mutate({id:ut,postDate:xt})},tt.id))})})})]}),e.jsx(js,{open:!!_,onOpenChange:tt=>{tt||j(null)},children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{children:"Caption"}),e.jsx(Rr,{value:w,onChange:tt=>k(tt.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("flex-1 justify-start gap-2 font-normal",!M&&"text-muted-foreground"),children:[e.jsx(xn,{className:"h-4 w-4"}),M?Bs(new Date(M+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{mode:"single",selected:M?new Date(M+"T00:00:00"):void 0,onSelect:tt=>S(tt?Bs(tt,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),M&&e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>S(null),children:e.jsx(Xr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>j(null),children:"Cancel"}),e.jsx(Y,{onClick:Ue,disabled:E,className:"gap-2",children:E?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},tPt=()=>{const{toast:t}=Sa(),s=vs(),[r,n]=T.useState("categories"),[a,o]=T.useState(!1),[l,i]=T.useState(null),[d,h]=T.useState({name:"",description:"",icon:""}),[f,g]=T.useState(!1),[v,_]=T.useState(null),[j,w]=T.useState({name:"",description:"",icon:""}),[k,M]=T.useState(!1),[S,E]=T.useState(null),[D,L]=T.useState(""),{data:B=[],isLoading:$}=zt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:De,error:Ge}=await Z.from("community_categories").select("*").order("sort_order");if(Ge)throw Ge;return De}}),{data:V=[],isLoading:W}=zt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:De,error:Ge}=await Z.from("community_private_groups").select("*").order("sort_order");if(Ge)throw Ge;return De}}),{data:G=[]}=zt({queryKey:["admin-group-members",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:De,error:Ge}=await Z.from("community_private_group_members").select("*").eq("group_id",S.id);if(Ge)throw Ge;return De},enabled:!!S}),{data:J=[]}=zt({queryKey:["admin-all-profiles"],queryFn:async()=>{let Ge=[],wt=0,Ie=!0;for(;Ie;){const{data:st,error:he}=await Z.from("profiles").select("id, name, email, brokerage_id").order("name").range(wt,wt+1e3-1);if(he)throw he;st&&st.length>0?(Ge=[...Ge,...st],wt+=1e3,Ie=st.length===1e3):Ie=!1}return Ge}}),{data:ne=[]}=zt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:De,error:Ge}=await Z.from("brokerages").select("*").order("name");if(Ge)throw Ge;return De}}),ie=Wt({mutationFn:async De=>{if(De.id){const{error:Ge}=await Z.from("community_categories").update({name:De.name,description:De.description||null,icon:De.icon||null}).eq("id",De.id);if(Ge)throw Ge}else{const Ge=Math.max(...B.map(Ie=>Ie.sort_order),0),{error:wt}=await Z.from("community_categories").insert({name:De.name,description:De.description||null,icon:De.icon||null,sort_order:Ge+1});if(wt)throw wt}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),h({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:De=>{t({title:"Error",description:De.message,variant:"destructive"})}}),ee=Wt({mutationFn:async De=>{const{error:Ge}=await Z.from("community_categories").delete().eq("id",De);if(Ge)throw Ge},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),de=Wt({mutationFn:async({id:De,direction:Ge})=>{const wt=B.findIndex(Ie=>Ie.id===De);if(Ge==="up"&&wt>0){const Ie=B[wt-1],st=B[wt];await Z.from("community_categories").update({sort_order:st.sort_order}).eq("id",Ie.id),await Z.from("community_categories").update({sort_order:Ie.sort_order}).eq("id",st.id)}else if(Ge==="down"&&wts.invalidateQueries({queryKey:["admin-community-categories"]})}),oe=Wt({mutationFn:async De=>{if(De.id){const{error:Ge}=await Z.from("community_private_groups").update({name:De.name,description:De.description||null,icon:De.icon||null}).eq("id",De.id);if(Ge)throw Ge}else{const Ge=Math.max(...V.map(Ie=>Ie.sort_order),0),{error:wt}=await Z.from("community_private_groups").insert({name:De.name,description:De.description||null,icon:De.icon||null,sort_order:Ge+1});if(wt)throw wt}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),g(!1),_(null),w({name:"",description:"",icon:""}),t({title:v?"Private group updated!":"Private group created!"})},onError:De=>{t({title:"Error",description:De.message,variant:"destructive"})}}),ue=Wt({mutationFn:async De=>{const{error:Ge}=await Z.from("community_private_groups").delete().eq("id",De);if(Ge)throw Ge},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),ce=Wt({mutationFn:async({id:De,direction:Ge})=>{const wt=V.findIndex(Ie=>Ie.id===De);if(Ge==="up"&&wt>0){const Ie=V[wt-1],st=V[wt];await Z.from("community_private_groups").update({sort_order:st.sort_order}).eq("id",Ie.id),await Z.from("community_private_groups").update({sort_order:Ie.sort_order}).eq("id",st.id)}else if(Ge==="down"&&wts.invalidateQueries({queryKey:["admin-private-groups"]})}),ge=Wt({mutationFn:async({groupId:De,userId:Ge,isMember:wt})=>{if(wt){const{error:Ie}=await Z.from("community_private_group_members").delete().eq("group_id",De).eq("user_id",Ge);if(Ie)throw Ie}else{const{error:Ie}=await Z.from("community_private_group_members").insert({group_id:De,user_id:Ge});if(Ie)throw Ie}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),Te=Wt({mutationFn:async({groupId:De,brokerageId:Ge,isMember:wt})=>{if(wt){const{error:Ie}=await Z.from("community_private_group_members").delete().eq("group_id",De).eq("brokerage_id",Ge);if(Ie)throw Ie}else{const{error:Ie}=await Z.from("community_private_group_members").insert({group_id:De,brokerage_id:Ge});if(Ie)throw Ie}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ve=De=>{i(De),h({name:De.name,description:De.description||"",icon:De.icon||""}),o(!0)},ye=()=>{i(null),h({name:"",description:"",icon:""}),o(!0)},Se=De=>{_(De),w({name:De.name,description:De.description||"",icon:De.icon||""}),g(!0)},Ke=()=>{_(null),w({name:"",description:"",icon:""}),g(!0)},Ae=De=>{E(De),L(""),M(!0)},Ee=De=>G.some(Ge=>Ge.user_id===De),He=De=>G.some(Ge=>Ge.brokerage_id===De),Ue=J.filter(De=>De.name.toLowerCase().includes(D.toLowerCase())||De.email.toLowerCase().includes(D.toLowerCase()));return e.jsx(Vs,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(Qa,{value:r,onValueChange:n,children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"categories",children:"Public Categories"}),e.jsxs(Fs,{value:"private-groups",children:[e.jsx(zu,{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(Y,{onClick:ye,children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-[50px]",children:"Order"}),e.jsx(Ct,{className:"w-[80px]",children:"Icon"}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Bn,{children:$?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):B.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):B.map((De,Ge)=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ge===0,onClick:()=>de.mutate({id:De.id,direction:"up"}),children:"↑"}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ge===B.length-1,onClick:()=>de.mutate({id:De.id,direction:"down"}),children:"↓"})]})}),e.jsx(ot,{className:"text-2xl",children:De.icon||"📁"}),e.jsx(ot,{className:"font-medium",children:De.name}),e.jsx(ot,{className:"text-muted-foreground",children:De.description||"—"}),e.jsx(ot,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>ve(De),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&ee.mutate(De.id)},children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},De.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(Ya,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(Y,{onClick:Ke,children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-[50px]",children:"Order"}),e.jsx(Ct,{className:"w-[80px]",children:"Icon"}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{className:"w-[120px]",children:"Members"}),e.jsx(Ct,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Bn,{children:W?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):V.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):V.map((De,Ge)=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ge===0,onClick:()=>ce.mutate({id:De.id,direction:"up"}),children:"↑"}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ge===V.length-1,onClick:()=>ce.mutate({id:De.id,direction:"down"}),children:"↓"})]})}),e.jsx(ot,{className:"text-2xl",children:De.icon||"🔒"}),e.jsx(ot,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[De.name,De.brokerage_id?e.jsxs(ct,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(Ya,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(ct,{variant:"secondary",className:"text-xs",children:[e.jsx(zu,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(ot,{className:"text-muted-foreground",children:De.description||"—"}),e.jsx(ot,{children:e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>Ae(De),children:[e.jsx(br,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex gap-1",children:[!De.brokerage_id&&e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>Se(De),children:e.jsx(Xa,{className:"h-4 w-4"})}),!De.brokerage_id&&e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&ue.mutate(De.id)},children:e.jsx(Ir,{className:"h-4 w-4"})}),De.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},De.id))})]})})})]})]}),e.jsx(js,{open:a,onOpenChange:o,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{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(Be,{value:d.icon,onChange:De=>h(Ge=>({...Ge,icon:De.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Be,{value:d.name,onChange:De=>h(Ge=>({...Ge,name:De.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Rr,{value:d.description,onChange:De=>h(Ge=>({...Ge,description:De.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(Y,{onClick:()=>ie.mutate({...d,id:l==null?void 0:l.id}),disabled:!d.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(js,{open:f,onOpenChange:g,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{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(Be,{value:j.icon,onChange:De=>w(Ge=>({...Ge,icon:De.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Be,{value:j.name,onChange:De=>w(Ge=>({...Ge,name:De.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(Rr,{value:j.description,onChange:De=>w(Ge=>({...Ge,description:De.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),e.jsx(Y,{onClick:()=>oe.mutate({...j,id:v==null?void 0:v.id}),disabled:!j.name.trim(),children:v?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(js,{open:k,onOpenChange:M,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:["Manage Members: ",S==null?void 0:S.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Qa,{defaultValue:"brokerages",children:[e.jsxs(Ga,{className:"w-full",children:[e.jsx(Fs,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(Fs,{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(po,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[ne.map(De=>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(Do,{checked:He(De.id),onCheckedChange:()=>{S&&Te.mutate({groupId:S.id,brokerageId:De.id,isMember:He(De.id)})}}),e.jsx("span",{className:"font-medium",children:De.name})]}),e.jsxs(ct,{variant:"secondary",children:[J.filter(Ge=>Ge.brokerage_id===De.id).length," agents"]})]},De.id)),ne.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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search users...",value:D,onChange:De=>L(De.target.value),className:"pl-9"})]}),e.jsx(po,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Ue.map(De=>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(Do,{checked:Ee(De.id),onCheckedChange:()=>{S&&ge.mutate({groupId:S.id,userId:De.id,isMember:Ee(De.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:De.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:De.email})]})]})},De.id)),Ue.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(Y,{onClick:()=>M(!1),children:"Done"})})]})]})})]})})},TMe=t=>{switch(t){case"academy_video":return e.jsx(Kl,{className:"h-3 w-3"});case"template":return e.jsx(Yn,{className:"h-3 w-3"});case"toolbox":return e.jsx(mc,{className:"h-3 w-3"});case"newsletter":return e.jsx(r0,{className:"h-3 w-3"});case"social_swag":return e.jsx(Sn,{className:"h-3 w-3"});default:return e.jsx(bn,{className:"h-3 w-3"})}},sPt=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}},rPt=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}},nPt=()=>{const{toast:t}=Sa(),[s,r]=T.useState([]),[n,a]=T.useState([]),[o,l]=T.useState([]),[i,d]=T.useState(!0),[h,f]=T.useState(""),[g,v]=T.useState(null),[_,j]=T.useState([]),[w,k]=T.useState([]);T.useEffect(()=>{M()},[]);const M=async()=>{try{d(!0);const{data:L,error:B}=await Z.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(B)throw B;const{data:$,error:V}=await Z.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(V)throw V;const W=[...new Set(($==null?void 0:$.map(oe=>oe.user_id))||[])],{data:G}=await Z.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",W),J=new Map((G==null?void 0:G.map(oe=>[oe.id,oe]))||[]),ne=(L==null?void 0:L.map(oe=>{var ue,ce,ge,Te;return{id:oe.id,user_id:oe.user_id,app_name:oe.app_name,launched_at:oe.launched_at,user_name:((ue=oe.profiles)==null?void 0:ue.name)||"Unknown",user_email:((ce=oe.profiles)==null?void 0:ce.email)||"Unknown",brokerage_name:((Te=(ge=oe.profiles)==null?void 0:ge.brokerages)==null?void 0:Te.name)||null}}))||[],ie=($==null?void 0:$.map(oe=>{var ce;const ue=J.get(oe.user_id);return{id:oe.id,user_id:oe.user_id,resource_type:oe.resource_type,resource_id:oe.resource_id,resource_title:oe.resource_title,action_type:oe.action_type,created_at:oe.created_at,user_name:(ue==null?void 0:ue.name)||"Unknown",user_email:(ue==null?void 0:ue.email)||"Unknown",brokerage_name:((ce=ue==null?void 0:ue.brokerages)==null?void 0:ce.name)||null}}))||[];r(ne),a(ie);const ee=new Map;ne.forEach(oe=>{if(!ee.has(oe.user_id))ee.set(oe.user_id,{user_id:oe.user_id,user_name:oe.user_name,user_email:oe.user_email,brokerage_name:oe.brokerage_name,last_activity_type:"app",last_activity_name:oe.app_name,last_activity_at:oe.launched_at,total_app_launches:1,total_content_views:0});else{const ue=ee.get(oe.user_id);ue.total_app_launches++,new Date(oe.launched_at)>new Date(ue.last_activity_at)&&(ue.last_activity_type="app",ue.last_activity_name=oe.app_name,ue.last_activity_at=oe.launched_at)}}),ie.forEach(oe=>{if(!ee.has(oe.user_id))ee.set(oe.user_id,{user_id:oe.user_id,user_name:oe.user_name,user_email:oe.user_email,brokerage_name:oe.brokerage_name,last_activity_type:oe.resource_type,last_activity_name:oe.resource_title,last_activity_at:oe.created_at,total_app_launches:0,total_content_views:1});else{const ue=ee.get(oe.user_id);ue.total_content_views++,new Date(oe.created_at)>new Date(ue.last_activity_at)&&(ue.last_activity_type=oe.resource_type,ue.last_activity_name=oe.resource_title,ue.last_activity_at=oe.created_at)}});const de=Array.from(ee.values()).sort((oe,ue)=>new Date(ue.last_activity_at).getTime()-new Date(oe.last_activity_at).getTime());l(de)}catch(L){console.error("Error loading activity:",L),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},S=L=>{v({id:L.user_id,name:L.user_name,email:L.user_email});const B=s.filter(V=>V.user_id===L.user_id),$=n.filter(V=>V.user_id===L.user_id);j(B),k($)},E=()=>{v(null),j([]),k([])},D=o.filter(L=>{var $;if(!h)return!0;const B=h.toLowerCase();return L.user_name.toLowerCase().includes(B)||L.user_email.toLowerCase().includes(B)||(($=L.brokerage_name)==null?void 0:$.toLowerCase().includes(B))});return i?e.jsx(Oe,{children:e.jsx($e,{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(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"User Activity"}),e.jsx(Tr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs($e,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name, email, or brokerage...",value:h,onChange:L=>f(L.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"User"}),e.jsx(Ct,{children:"Brokerage"}),e.jsx(Ct,{children:"Last Activity"}),e.jsx(Ct,{children:"Last Active"}),e.jsx(Ct,{className:"text-right",children:"Apps"}),e.jsx(Ct,{className:"text-right",children:"Content"})]})}),e.jsx(Bn,{children:D.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):D.map(L=>e.jsxs(ws,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>S(L),children:[e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:L.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:L.user_email})]})}),e.jsx(ot,{children:L.brokerage_name?e.jsx(ct,{variant:"outline",children:L.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ot,{children:e.jsx("div",{className:"flex items-center gap-2",children:L.last_activity_type==="app"?e.jsxs(ct,{variant:"secondary",children:[e.jsx(bn,{className:"h-3 w-3 mr-1"}),L.last_activity_name]}):e.jsxs(ct,{variant:"outline",className:"flex items-center gap-1",children:[TMe(L.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:L.last_activity_name})]})})}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:_u(new Date(L.last_activity_at),{addSuffix:!0})}),e.jsx(ot,{className:"text-right",children:e.jsx(ct,{variant:"outline",children:L.total_app_launches})}),e.jsx(ot,{className:"text-right",children:e.jsx(ct,{variant:"outline",children:L.total_content_views})})]},L.user_id))})]})})]})]}),e.jsx(js,{open:!!g,onOpenChange:L=>!L&&E(),children:e.jsxs(_s,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{children:[g==null?void 0:g.name,"'s Activity"]}),e.jsx(en,{children:g==null?void 0:g.email})]}),e.jsxs(Qa,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-2",children:[e.jsxs(Fs,{value:"content",children:["Content (",w.length,")"]}),e.jsxs(Fs,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Type"}),e.jsx(Ct,{children:"Resource"}),e.jsx(Ct,{children:"Action"}),e.jsx(Ct,{children:"Time"})]})}),e.jsx(Bn,{children:w.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):w.map(L=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs(ct,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[TMe(L.resource_type),sPt(L.resource_type)]})}),e.jsx(ot,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:L.resource_title})}),e.jsx(ot,{children:e.jsx(ct,{variant:"secondary",children:rPt(L.action_type)})}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:_u(new Date(L.created_at),{addSuffix:!0})})]},L.id))})]})})}),e.jsx(Zs,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"App"}),e.jsx(Ct,{children:"Time"})]})}),e.jsx(Bn,{children:_.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(L=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsx(ct,{variant:"secondary",children:L.app_name})}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:_u(new Date(L.launched_at),{addSuffix:!0})})]},L.id))})]})})})]})]})})]})},aPt=()=>{const{toast:t}=Sa(),[s,r]=T.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=T.useState(!0);T.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await Z.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await Z.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),d=(l||0)-(i||0),{count:h}=await Z.from("brokerages").select("*",{count:"exact",head:!0}),{count:f}=await Z.from("activity_logs").select("*",{count:"exact",head:!0}),g=new Date;g.setDate(g.getDate()-7);const{count:v}=await Z.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",g.toISOString()),_=new Date;_.setMonth(_.getMonth()-1);const{count:j}=await Z.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",_.toISOString()),{data:w}=await Z.from("activity_logs").select("user_id").gte("launched_at",g.toISOString()),k=new Set(w==null?void 0:w.map(M=>M.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:d,totalBrokerages:h||0,totalLaunches:f||0,launchesThisWeek:v||0,launchesThisMonth:j||0,uniqueActiveThisWeek:k})}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(Oe,{children:e.jsx($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(br,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(ca,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(Ya,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(wx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(wx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(wx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Jd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},AMe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},EMe={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 kHe({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=T.useState([]),[a,o]=T.useState(!0),[l,i]=T.useState(""),[d,h]=T.useState("all");T.useEffect(()=>{f()},[s]);const f=async()=>{o(!0);try{let M=[];if(t&&s){const{data:W}=await Z.from("profiles").select("id").eq("brokerage_id",s);if(M=(W==null?void 0:W.map(G=>G.id))||[],M.length===0){n([]),o(!1);return}}let S=Z.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&M.length>0&&(S=S.or(`sender_id.in.(${M.join(",")}),recipient_id.in.(${M.join(",")})`));const{data:E,error:D}=await S;if(D)throw D;const L=new Set;E==null||E.forEach(W=>{L.add(W.sender_id),L.add(W.recipient_id)});const{data:B}=await Z.from("profiles").select("id, name, email").in("id",Array.from(L)),$=new Map((B==null?void 0:B.map(W=>[W.id,W]))||[]),V=(E==null?void 0:E.map(W=>({...W,sender:$.get(W.sender_id),recipient:$.get(W.recipient_id)})))||[];n(V)}catch(M){console.error("Error loading shares:",M)}finally{o(!1)}},g=r.filter(M=>{var D,L;const S=l===""||M.resource_title.toLowerCase().includes(l.toLowerCase())||((D=M.sender)==null?void 0:D.name.toLowerCase().includes(l.toLowerCase()))||((L=M.recipient)==null?void 0:L.name.toLowerCase().includes(l.toLowerCase())),E=d==="all"||M.resource_type===d;return S&&E}),v=r.length,_=new Set(r.map(M=>M.sender_id)).size,j=new Set(r.map(M=>M.recipient_id)).size,w=r.length>0?Math.round(r.filter(M=>M.is_read).length/r.length*100):0,k=r.reduce((M,S)=>(M[S.resource_type]=(M[S.resource_type]||0)+1,M),{});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((M,S)=>e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(ys,{className:"h-4 w-20"})}),e.jsx($e,{children:e.jsx(ys,{className:"h-8 w-16"})})]},S))}),e.jsx(Oe,{children:e.jsx($e,{className:"p-6",children:e.jsx(ys,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(Kc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:v})})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(br,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:_})})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Jd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:j})})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx($e,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[w,"%"]})})]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx($e,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(k).map(([M,S])=>e.jsxs(ct,{variant:"secondary",className:EMe[M],children:[AMe[M],": ",S]},M)),Object.keys(k).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Share History"}),e.jsxs(Tr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs($e,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:M=>i(M.target.value),className:"pl-9"})]}),e.jsxs(er,{value:d,onValueChange:h,children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{placeholder:"Resource type"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Types"}),e.jsx(Et,{value:"event",children:"Events"}),e.jsx(Et,{value:"template",children:"Templates"}),e.jsx(Et,{value:"academy_video",children:"Academy Videos"}),e.jsx(Et,{value:"resource_kit",children:"Resource Kits"}),e.jsx(Et,{value:"newsletter",children:"Newsletters"}),e.jsx(Et,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(po,{className:"h-[400px]",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Resource"}),e.jsx(Ct,{children:"Type"}),e.jsx(Ct,{children:"Sender"}),e.jsx(Ct,{children:"Recipient"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{children:"Date"})]})}),e.jsx(Bn,{children:g.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):g.map(M=>{var S,E;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium max-w-[200px] truncate",children:M.resource_title}),e.jsx(ot,{children:e.jsx(ct,{variant:"secondary",className:EMe[M.resource_type],children:AMe[M.resource_type]})}),e.jsx(ot,{children:((S=M.sender)==null?void 0:S.name)||"Unknown"}),e.jsx(ot,{children:((E=M.recipient)==null?void 0:E.name)||"Unknown"}),e.jsx(ot,{children:e.jsx(ct,{variant:M.is_read?"default":"outline",children:M.is_read?"Read":"Unread"})}),e.jsx(ot,{className:"text-muted-foreground",children:Bs(new Date(M.created_at),"MMM d, yyyy")})]},M.id)})})]})})]})]})]})}const iPt=()=>e.jsx(Vs,{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(Qa,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"analytics",children:"Analytics"}),e.jsx(Fs,{value:"activity",children:"Activity"}),e.jsx(Fs,{value:"shares",children:"Shares"})]}),e.jsx(Zs,{value:"analytics",className:"space-y-4",children:e.jsx(aPt,{})}),e.jsx(Zs,{value:"activity",className:"space-y-4",children:e.jsx(nPt,{})}),e.jsx(Zs,{value:"shares",className:"space-y-4",children:e.jsx(kHe,{})})]})]})});function oPt(){const t=vs(),[s,r]=T.useState(!1),[n,a]=T.useState(null),[o,l]=T.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=T.useState(null),[h,f]=T.useState(""),[g,v]=T.useState([]),[_,j]=T.useState([]),[w,k]=T.useState([]),[M,S]=T.useState(!1),[E,D]=T.useState(null),[L,B]=T.useState(""),{data:$,isLoading:V}=zt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:Ie,error:st}=await Z.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(st)throw st;return Ie}}),{data:W}=zt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:Ie,error:st}=await Z.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(st)throw st;return Ie}}),{data:G}=zt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:Ie,error:st}=await Z.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(st)throw st;return Ie}}),{data:J}=zt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:Ie,error:st}=await Z.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(st)throw st;return Ie}}),{data:ne,isLoading:ie}=zt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:Ie,error:st}=await Z.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(st)throw st;return Ie}}),ee=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),d(null),f(""),v([]),j([]),k([]),a(null),B("")},de=Ie=>{a(Ie),l({title:Ie.title,description:Ie.description||"",publish_date:Ie.publish_date.split("T")[0],is_published:Ie.is_published,category_id:Ie.category_id||""}),f(Ie.preview_image_url||""),B("");const st=(W==null?void 0:W.filter(et=>et.resource_id===Ie.id))||[];v(st.map(et=>({id:et.id,name:et.name,file_url:et.file_url,file_size:et.file_size,sort_order:et.sort_order})));const he=(G==null?void 0:G.filter(et=>et.resource_id===Ie.id))||[];j(he.map(et=>({id:et.id,title:et.title,video_url:et.video_url,sort_order:et.sort_order})));const We=(J==null?void 0:J.filter(et=>et.resource_id===Ie.id))||[];k(We.map(et=>({id:et.id,title:et.title,canva_share_link:et.canva_share_link,sort_order:et.sort_order}))),r(!0)},oe=Ie=>{var he;const st=(he=Ie.target.files)==null?void 0:he[0];st&&(d(st),f(URL.createObjectURL(st)))},ue=()=>{v([...g,{name:"",file_url:"",sort_order:g.length}])},ce=Ie=>{v(g.filter((st,he)=>he!==Ie))},ge=(Ie,st,he)=>{const We=[...g];if(st==="file"&&he instanceof File){const et=he.name.replace(/\.[^/.]+$/,"");We[Ie]={...We[Ie],file:he,file_size:he.size,name:We[Ie].name||et}}else We[Ie]={...We[Ie],[st]:he};v(We)},Te=()=>{j([..._,{title:"",video_url:"",sort_order:_.length}])},ve=Ie=>{j(_.filter((st,he)=>he!==Ie))},ye=(Ie,st,he)=>{const We=[..._];st==="file"&&he instanceof File?We[Ie]={...We[Ie],file:he}:We[Ie]={...We[Ie],[st]:he},j(We)},Se=()=>{k([...w,{title:"",canva_share_link:"",sort_order:w.length}])},Ke=Ie=>{k(w.filter((st,he)=>he!==Ie))},Ae=(Ie,st,he)=>{const We=[...w];We[Ie]={...We[Ie],[st]:he},k(We)},Ee=async(Ie,st)=>{try{const he=await Z.functions.invoke("bunny-upload",{body:{action:"create",title:Ie.name}});if(he.error)throw he.error;const{videoId:We,uploadUrl:et,libraryId:Ye}=he.data,ke=await Z.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:We,libraryId:Ye}});if(ke.error)throw ke.error;const{uploadUrl:at,apiKey:Fe}=ke.data,it=new XMLHttpRequest;return it.open("PUT",at,!0),it.setRequestHeader("AccessKey",Fe),it.upload.onprogress=dt=>{if(dt.lengthComputable){const tt=Math.round(dt.loaded/dt.total*100),ut=[..._];ut[st]={...ut[st],uploadProgress:tt},j(ut)}},await new Promise((dt,tt)=>{it.onload=()=>it.status>=200&&it.status<300?dt():tt(new Error("Upload failed")),it.onerror=()=>tt(new Error("Upload failed")),it.send(Ie)}),`https://iframe.mediadelivery.net/embed/${Ye}/${We}`}catch(he){throw console.error("Bunny upload error:",he),he}},He=Wt({mutationFn:async Ie=>{const{data:st,error:he}=await Z.from("brokerage_resource_categories").insert({name:Ie,sort_order:(ne==null?void 0:ne.length)||0}).select().single();if(he)throw he;return st},onSuccess:Ie=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:Ie.id}),B(""),be.success("Category created")},onError:Ie=>{be.error("Failed to create category: "+Ie.message)}}),Ue=Wt({mutationFn:async()=>{S(!0);let Ie=(n==null?void 0:n.preview_image_url)||null;if(i){const We=i.name.split(".").pop(),et=`${Date.now()}.${We}`,{error:Ye}=await Z.storage.from("brokerage-resources").upload(`previews/${et}`,i);if(Ye)throw Ye;const{data:ke}=Z.storage.from("brokerage-resources").getPublicUrl(`previews/${et}`);Ie=ke.publicUrl}const st={title:o.title,description:o.description||null,preview_image_url:Ie,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let he;if(n){const{error:We}=await Z.from("brokerage_resources").update(st).eq("id",n.id);if(We)throw We;he=n.id;const et=(W==null?void 0:W.filter(xt=>xt.resource_id===n.id).map(xt=>xt.id))||[],Ye=g.filter(xt=>xt.id).map(xt=>xt.id),ke=et.filter(xt=>!Ye.includes(xt));ke.length>0&&await Z.from("brokerage_resource_pdfs").delete().in("id",ke);const at=(G==null?void 0:G.filter(xt=>xt.resource_id===n.id).map(xt=>xt.id))||[],Fe=_.filter(xt=>xt.id).map(xt=>xt.id),it=at.filter(xt=>!Fe.includes(xt));it.length>0&&await Z.from("brokerage_resource_videos").delete().in("id",it);const dt=(J==null?void 0:J.filter(xt=>xt.resource_id===n.id).map(xt=>xt.id))||[],tt=w.filter(xt=>xt.id).map(xt=>xt.id),ut=dt.filter(xt=>!tt.includes(xt));ut.length>0&&await Z.from("brokerage_resource_links").delete().in("id",ut)}else{const{data:We,error:et}=await Z.from("brokerage_resources").insert(st).select().single();if(et)throw et;he=We.id}for(let We=0;We{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),be.success(n?"Resource updated":"Resource created"),r(!1),ee(),S(!1)},onError:Ie=>{be.error("Failed to save resource: "+Ie.message),S(!1)}}),De=Wt({mutationFn:async Ie=>{const{error:st}=await Z.from("brokerage_resources").delete().eq("id",Ie);if(st)throw st},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),be.success("Resource deleted")},onError:Ie=>{be.error("Failed to delete: "+Ie.message)}}),Ge=Ie=>{if(Ie.preventDefault(),!o.title){be.error("Please enter a title");return}Ue.mutate()},wt=Ie=>{const st=(W==null?void 0:W.filter(et=>et.resource_id===Ie).length)||0,he=(G==null?void 0:G.filter(et=>et.resource_id===Ie).length)||0,We=(J==null?void 0:J.filter(et=>et.resource_id===Ie).length)||0;return{pdfCount:st,videoCount:he,linkCount:We}};return e.jsx(Vs,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.length)||0})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.filter(Ie=>Ie.is_published).length)||0})})]})]}),e.jsxs(Y,{onClick:()=>{ee(),r(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Category"}),e.jsx(Ct,{children:"Content"}),e.jsx(Ct,{children:"Publish Date"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:V?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):($==null?void 0:$.length)===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):$==null?void 0:$.map(Ie=>{const{pdfCount:st,videoCount:he,linkCount:We}=wt(Ie.id),et=ne==null?void 0:ne.find(Ye=>Ye.id===Ie.category_id);return e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ie.preview_image_url?e.jsx("img",{src:Ie.preview_image_url,alt:Ie.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(Fu,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ie.title}),Ie.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ie.description})]})]})}),e.jsx(ot,{children:et?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:et.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ot,{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(Yn,{className:"h-3.5 w-3.5"}),st]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wn,{className:"h-3.5 w-3.5"}),he]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ro,{className:"h-3.5 w-3.5"}),We]})]})}),e.jsx(ot,{children:Bs(new Date(Ie.publish_date),"MMM d, yyyy")}),e.jsx(ot,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ie.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Ie.is_published?"Published":"Draft"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{const Ye=(W==null?void 0:W.filter(Fe=>Fe.resource_id===Ie.id))||[],ke=(G==null?void 0:G.filter(Fe=>Fe.resource_id===Ie.id))||[],at=(J==null?void 0:J.filter(Fe=>Fe.resource_id===Ie.id))||[];D({...Ie,pdfs:Ye,videos:ke,links:at})},children:e.jsx(wi,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>de(Ie),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&De.mutate(Ie.id)},children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},Ie.id)})})]})})}),e.jsx(js,{open:s,onOpenChange:r,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Ge,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[h?e.jsx("img",{src:h,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(Fu,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Be,{type:"file",accept:"image/*",onChange:oe})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"title",children:"Title *"}),e.jsx(Be,{id:"title",value:o.title,onChange:Ie=>l({...o,title:Ie.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{className:"flex items-center gap-2",children:[e.jsx(Kp,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(er,{value:o.category_id,onValueChange:Ie=>l({...o,category_id:Ie}),children:[e.jsx(Qs,{className:"flex-1",children:e.jsx(tr,{placeholder:"Select a category"})}),e.jsx(Js,{children:ne==null?void 0:ne.map(Ie=>e.jsx(Et,{value:Ie.id,children:Ie.name},Ie.id))})]}),o.category_id&&e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Xr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{placeholder:"Or create new category...",value:L,onChange:Ie=>B(Ie.target.value),className:"flex-1"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||He.isPending,onClick:()=>He.mutate(L.trim()),children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Ig,{content:o.description,onChange:Ie=>l({...o,description:Ie}),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(je,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Be,{id:"publish_date",type:"date",value:o.publish_date,onChange:Ie=>l({...o,publish_date:Ie.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(ln,{checked:o.is_published,onCheckedChange:Ie=>l({...o,is_published:Ie})}),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(je,{className:"flex items-center gap-2",children:[e.jsx(Yn,{className:"h-4 w-4"}),"PDF Documents (",g.length,")"]}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:ue,children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),g.map((Ie,st)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Be,{placeholder:"PDF Name",value:Ie.name,onChange:he=>ge(st,"name",he.target.value),className:"flex-1"}),e.jsx(Be,{type:"file",accept:".pdf",onChange:he=>{var et;const We=(et=he.target.files)==null?void 0:et[0];We&&ge(st,"file",We)},className:"flex-1"}),Ie.file_url&&!Ie.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>ce(st),children:e.jsx(Xr,{className:"h-4 w-4"})})]},st))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(je,{className:"flex items-center gap-2",children:[e.jsx(Wn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:Te,children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((Ie,st)=>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(Be,{placeholder:"Video Title",value:Ie.title,onChange:he=>ye(st,"title",he.target.value),className:"flex-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>ve(st),children:e.jsx(Xr,{className:"h-4 w-4"})})]}),e.jsx(Be,{type:"file",accept:"video/*",onChange:he=>{var et;const We=(et=he.target.files)==null?void 0:et[0];We&&ye(st,"file",We)}}),Ie.uploadProgress!==void 0&&Ie.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:`${Ie.uploadProgress}%`}})}),Ie.video_url&&!Ie.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},st))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(je,{className:"flex items-center gap-2",children:[e.jsx(Ro,{className:"h-4 w-4"}),"Canva Links (",w.length,")"]}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:Se,children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),w.map((Ie,st)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Be,{placeholder:"Link Title",value:Ie.title,onChange:he=>Ae(st,"title",he.target.value),className:"flex-1"}),e.jsx(Be,{placeholder:"Canva Share Link",value:Ie.canva_share_link,onChange:he=>Ae(st,"canva_share_link",he.target.value),className:"flex-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ke(st),children:e.jsx(Xr,{className:"h-4 w-4"})})]},st))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:Ue.isPending||M,children:Ue.isPending||M?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(js,{open:!!E,onOpenChange:()=>D(null),children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:E==null?void 0:E.title})}),E&&e.jsxs("div",{className:"space-y-4",children:[E.preview_image_url&&e.jsx("img",{src:E.preview_image_url,alt:E.title,className:"w-full h-48 object-cover rounded-lg"}),E.description&&e.jsx("p",{className:"text-muted-foreground",children:E.description}),E.pdfs&&E.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Yn,{className:"h-4 w-4"}),"PDF Documents (",E.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:E.pdfs.map(Ie=>e.jsx("a",{href:Ie.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Ie.name},Ie.id))})]}),E.videos&&E.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Wn,{className:"h-4 w-4"}),"Videos (",E.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:E.videos.map(Ie=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:Ie.title})},Ie.id))})]}),E.links&&E.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ro,{className:"h-4 w-4"}),"Canva Links (",E.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:E.links.map(Ie=>e.jsx("a",{href:Ie.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Ie.title},Ie.id))})]})]})]})})]})})}const NHe=[{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 lPt(){const[t,s]=T.useState([]),[r,n]=T.useState(!0),[a,o]=T.useState(!1),[l,i]=T.useState(!1),[d,h]=T.useState(null),[f,g]=T.useState(!1),[v,_]=T.useState(!1),[j,w]=T.useState(""),[k,M]=T.useState(""),[S,E]=T.useState(""),[D,L]=T.useState(""),[B,$]=T.useState("Learn More"),[V,W]=T.useState("top"),[G,J]=T.useState(""),[ne,ie]=T.useState(!0),[ee,de]=T.useState(""),[oe,ue]=T.useState("");T.useEffect(()=>{ce()},[]);const ce=async()=>{try{const{data:He,error:Ue}=await Z.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Ue)throw Ue;s(He||[])}catch(He){be.error("Failed to load banners: "+He.message)}finally{n(!1)}},ge=()=>{w(""),M(""),E(""),L(""),$("Learn More"),W("top"),J(""),ie(!0),de(""),ue(""),h(null)},Te=He=>{h(He),w(He.title),M(He.description||""),E(He.image_url),L(He.link_url||""),$(He.link_text||"Learn More"),W(He.placement),J(He.section_after||""),ie(He.is_active),de(He.start_date?Bs(new Date(He.start_date),"yyyy-MM-dd'T'HH:mm"):""),ue(He.end_date?Bs(new Date(He.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ve=async He=>{var De;const Ue=(De=He.target.files)==null?void 0:De[0];if(Ue){g(!0);try{const Ge=Ue.name.split(".").pop(),wt=`${Date.now()}.${Ge}`,{error:Ie}=await Z.storage.from("banner-images").upload(wt,Ue);if(Ie)throw Ie;const{data:{publicUrl:st}}=Z.storage.from("banner-images").getPublicUrl(wt);E(st),be.success("Image uploaded successfully")}catch(Ge){be.error("Failed to upload image: "+Ge.message)}finally{g(!1)}}},ye=async()=>{if(!j.trim()||!S){be.error("Please fill in required fields (title and image)");return}_(!0);try{const He={title:j.trim(),description:k.trim()||null,image_url:S,link_url:D.trim()||null,link_text:B.trim()||"Learn More",placement:V,section_after:V==="between"?G:null,is_active:ne,start_date:ee?new Date(ee).toISOString():null,end_date:oe?new Date(oe).toISOString():null};if(d){const{error:Ue}=await Z.from("dashboard_banners").update(He).eq("id",d.id);if(Ue)throw Ue;be.success("Banner updated successfully")}else{const Ue=t.filter(Ge=>Ge.placement===V).length,{error:De}=await Z.from("dashboard_banners").insert({...He,sort_order:Ue});if(De)throw De;be.success("Banner created successfully")}o(!1),ge(),ce()}catch(He){be.error("Failed to save banner: "+He.message)}finally{_(!1)}},Se=async()=>{if(d)try{const{error:He}=await Z.from("dashboard_banners").delete().eq("id",d.id);if(He)throw He;be.success("Banner deleted successfully"),i(!1),h(null),ce()}catch(He){be.error("Failed to delete banner: "+He.message)}},Ke=async He=>{try{const{error:Ue}=await Z.from("dashboard_banners").update({is_active:!He.is_active}).eq("id",He.id);if(Ue)throw Ue;be.success(He.is_active?"Banner deactivated":"Banner activated"),ce()}catch(Ue){be.error("Failed to update banner: "+Ue.message)}},Ae=t.filter(He=>He.placement==="top"),Ee=t.filter(He=>He.placement==="between");return r?e.jsx(Vs,{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(Vs,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(fl,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(Tr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(js,{open:a&&V==="top",onOpenChange:He=>{He||ge(),o(He),He&&W("top")},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{onClick:()=>{ge(),W("top")},children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{children:[d?"Edit":"Create"," Banner"]}),e.jsx(en,{children:"Configure the banner's content and display settings"})]}),e.jsx(IMe,{title:j,setTitle:w,description:k,setDescription:M,imageUrl:S,linkUrl:D,setLinkUrl:L,linkText:B,setLinkText:$,placement:V,setPlacement:W,sectionAfter:G,setSectionAfter:J,isActive:ne,setIsActive:ie,startDate:ee,setStartDate:de,endDate:oe,setEndDate:ue,handleImageUpload:ve,uploading:f,showPlacementOptions:!1}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>{o(!1),ge()},children:"Cancel"}),e.jsx(Y,{onClick:ye,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx($e,{children:Ae.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:Ae.map(He=>e.jsx(PMe,{banner:He,onEdit:()=>Te(He),onDelete:()=>{h(He),i(!0)},onToggleActive:()=>Ke(He)},He.id))})})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(fl,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(Tr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(js,{open:a&&V==="between",onOpenChange:He=>{He||ge(),o(He),He&&W("between")},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{onClick:()=>{ge(),W("between")},children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{children:[d?"Edit":"Create"," Section Banner"]}),e.jsx(en,{children:"Configure where this banner appears between sections"})]}),e.jsx(IMe,{title:j,setTitle:w,description:k,setDescription:M,imageUrl:S,linkUrl:D,setLinkUrl:L,linkText:B,setLinkText:$,placement:V,setPlacement:W,sectionAfter:G,setSectionAfter:J,isActive:ne,setIsActive:ie,startDate:ee,setStartDate:de,endDate:oe,setEndDate:ue,handleImageUpload:ve,uploading:f,showPlacementOptions:!0}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>{o(!1),ge()},children:"Cancel"}),e.jsx(Y,{onClick:ye,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx($e,{children:Ee.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:Ee.map(He=>e.jsx(PMe,{banner:He,onEdit:()=>Te(He),onDelete:()=>{h(He),i(!0)},onToggleActive:()=>Ke(He),showSection:!0},He.id))})})]})]}),e.jsx(js,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Delete Banner"}),e.jsxs(en,{children:['Are you sure you want to delete "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(Y,{variant:"destructive",onClick:Se,children:"Delete"})]})]})})]})}function IMe({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:h,setPlacement:f,sectionAfter:g,setSectionAfter:v,isActive:_,setIsActive:j,startDate:w,setStartDate:k,endDate:M,setEndDate:S,handleImageUpload:E,uploading:D,showPlacementOptions:L}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"title",children:"Title *"}),e.jsx(Be,{id:"title",placeholder:"Banner headline...",value:t,onChange:B=>s(B.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",placeholder:"Optional banner description...",value:r,onChange:B=>n(B.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Be,{type:"file",accept:"image/*",onChange:E,disabled:D,className:"flex-1"}),D&&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(je,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(Be,{id:"linkUrl",placeholder:"https://...",value:o,onChange:B=>l(B.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"linkText",children:"Button Text"}),e.jsx(Be,{id:"linkText",placeholder:"Learn More",value:i,onChange:B=>d(B.target.value)})]})]}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Placement"}),e.jsxs(er,{value:g,onValueChange:v,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select section placement..."})}),e.jsx(Js,{children:NHe.map(B=>e.jsx(Et,{value:B.value,children:B.label},B.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(Be,{id:"startDate",type:"datetime-local",value:w,onChange:B=>k(B.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(Be,{id:"endDate",type:"datetime-local",value:M,onChange:B=>S(B.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(ln,{id:"isActive",checked:_,onCheckedChange:j}),e.jsx(je,{htmlFor:"isActive",children:"Active"})]})})]})}function PMe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=NHe.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(lm,{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(ct,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(ct,{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(Y,{variant:"ghost",size:"icon",children:e.jsx(bn,{className:"h-4 w-4"})})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(wi,{className:"h-4 w-4"}):e.jsx(Wp,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})]})}const p8={open:{label:"Open",icon:ca,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Gl,color:"bg-blue-500"},resolved:{label:"Resolved",icon:yi,color:"bg-green-500"},closed:{label:"Closed",icon:Cc,color:"bg-muted-foreground"}},LMe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function cPt(){var B,$;const{user:t}=Ys(),s=vs(),[r,n]=T.useState(null),[a,o]=T.useState(""),[l,i]=T.useState("all"),[d,h]=T.useState("all"),[f,g]=T.useState(!1),{data:v=[],isLoading:_}=zt({queryKey:["admin-support-tickets",l,d],queryFn:async()=>{let V=Z.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(V=V.eq("status",l)),d!=="all"&&(V=V.eq("category",d));const{data:W,error:G}=await V;if(G)throw G;return W}}),{data:j=[]}=zt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:V,error:W}=await Z.from("user_roles").select("user_id").eq("role","admin");if(W)throw W;const G=V.map(oe=>oe.user_id),{data:J,error:ne}=await Z.from("profiles").select("id, name, email").in("id",G);if(ne)throw ne;const{data:ie,error:ee}=await Z.from("support_notification_settings").select("user_id, receive_notifications");if(ee)throw ee;const de=new Map((ie==null?void 0:ie.map(oe=>[oe.user_id,oe.receive_notifications]))||[]);return J.map(oe=>({...oe,receives_notifications:de.get(oe.id)||!1}))}}),{data:w=[]}=zt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:V,error:W}=await Z.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(W)throw W;return V},enabled:!!r}),k=Wt({mutationFn:async({userId:V,enabled:W})=>{const{data:G}=await Z.from("support_notification_settings").select("id").eq("user_id",V).maybeSingle();if(G){const{error:J}=await Z.from("support_notification_settings").update({receive_notifications:W}).eq("user_id",V);if(J)throw J}else{const{error:J}=await Z.from("support_notification_settings").insert({user_id:V,receive_notifications:W});if(J)throw J}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),be.success("Notification settings updated")},onError:()=>{be.error("Failed to update settings")}}),M=Wt({mutationFn:async({ticketId:V,status:W})=>{const{error:G}=await Z.from("support_tickets").update({status:W}).eq("id",V);if(G)throw G},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),be.success("Status updated")},onError:()=>{be.error("Failed to update status")}}),S=Wt({mutationFn:async({ticketId:V,assignedTo:W})=>{const{error:G}=await Z.from("support_tickets").update({assigned_to:W}).eq("id",V);if(G)throw G},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),be.success("Ticket assigned")},onError:()=>{be.error("Failed to assign ticket")}}),E=Wt({mutationFn:async V=>{var G,J;if(!r||!t)throw new Error("Missing data");const{error:W}=await Z.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:V,is_admin_reply:!0});if(W)throw W;try{await Z.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:V,userEmail:(G=r.profiles)==null?void 0:G.email,userName:(J=r.profiles)==null?void 0:J.name}})}catch(ne){console.error("Failed to send reply notification:",ne)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),be.success("Reply sent!")},onError:()=>{be.error("Failed to send reply")}}),D=()=>{a.trim()&&E.mutate(a)};T.useEffect(()=>{const V=Z.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{Z.removeChannel(V)}},[s]);const L=v.filter(V=>V.status==="open").length;return r?(p8[r.status].icon,e.jsx(Vs,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(bi,{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(ct,{variant:"secondary",children:LMe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((B=r.profiles)==null?void 0:B.name)||"Unknown"," (",($=r.profiles)==null?void 0:$.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm",children:"Status"})}),e.jsx($e,{children:e.jsxs(er,{value:r.status,onValueChange:V=>{M.mutate({ticketId:r.id,status:V}),n({...r,status:V})},children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"open",children:"Open"}),e.jsx(Et,{value:"in_progress",children:"In Progress"}),e.jsx(Et,{value:"resolved",children:"Resolved"}),e.jsx(Et,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm",children:"Assigned To"})}),e.jsx($e,{children:e.jsxs(er,{value:r.assigned_to||"unassigned",onValueChange:V=>{const W=V==="unassigned"?null:V;S.mutate({ticketId:r.id,assignedTo:W}),n({...r,assigned_to:W})},children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Unassigned"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"unassigned",children:"Unassigned"}),j.map(V=>e.jsx(Et,{value:V.id,children:V.name},V.id))]})]})})]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Tr,{children:["Created on ",Bs(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx($e,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Conversation"})}),e.jsxs($e,{children:[e.jsx(po,{className:"h-[300px] pr-4",children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:w.map(V=>{var W,G;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?`${((W=V.profiles)==null?void 0:W.name)||"Admin"} (Support)`:((G=V.profiles)==null?void 0:G.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Bs(new Date(V.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:V.content})]},V.id)})})}),e.jsx(ud,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Rr,{placeholder:"Type your reply...",value:a,onChange:V=>o(V.target.value),className:"min-h-[80px]"}),e.jsx(Y,{onClick:D,disabled:!a.trim()||E.isPending,className:"self-end",children:e.jsx(Wa,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Vs,{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(ct,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(js,{open:f,onOpenChange:g,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{variant:"outline",children:[e.jsx(Ic,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Email Notification Settings"}),e.jsx(en,{children:"Choose which admins receive email notifications for new support tickets."})]}),e.jsx("div",{className:"space-y-4 mt-4",children:j.map(V=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Wo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:V.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[V.receives_notifications?e.jsx(dg,{className:"h-4 w-4 text-primary"}):e.jsx(xk,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ln,{checked:V.receives_notifications,onCheckedChange:W=>k.mutate({userId:V.id,enabled:W})})]})]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(Qa,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(Ga,{children:[e.jsx(Fs,{value:"all",children:"All"}),e.jsx(Fs,{value:"open",children:"Open"}),e.jsx(Fs,{value:"in_progress",children:"In Progress"}),e.jsx(Fs,{value:"resolved",children:"Resolved"}),e.jsx(Fs,{value:"closed",children:"Closed"})]})}),e.jsxs(er,{value:d,onValueChange:h,children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{placeholder:"All Categories"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Categories"}),e.jsx(Et,{value:"general",children:"General Support"}),e.jsx(Et,{value:"technology",children:"Technology Support"}),e.jsx(Et,{value:"crm",children:"CRM Support"}),e.jsx(Et,{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(Oe,{children:e.jsxs($e,{className:"text-center py-12",children:[e.jsx(Gl,{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(V=>{var G,J;const W=p8[V.status].icon;return e.jsx(Oe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(V),children:e.jsx($e,{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:V.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(ct,{variant:"outline",className:"text-xs",children:LMe[V.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(G=V.profiles)==null?void 0:G.name," • ",Bs(new Date(V.created_at),"MMM d, yyyy")]}),V.assigned_to&&e.jsxs(ct,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Wo,{className:"h-3 w-3"}),((J=j.find(ne=>ne.id===V.assigned_to))==null?void 0:J.name)||"Assigned"]})]})]}),e.jsxs(ct,{className:p8[V.status].color,children:[e.jsx(W,{className:"h-3 w-3 mr-1"}),p8[V.status].label]})]})})},V.id)})})})]})]})})}const dPt=wu.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 uPt({content:t,onChange:s,variables:r}){const n=dqe({extensions:[gqe,Sqe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Cqe.configure({types:["heading","paragraph"]}),Mqe,dPt],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});T.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(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(S4,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(P4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(dm,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(O4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(j4,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(w4,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(k4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(Ro,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(vk,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(H4,{className:"h-4 w-4"})}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(q4,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsxs(Y,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(JE,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(ju,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Va,{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(lqe,{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(ct,{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 hPt(){const t=vs(),[s,r]=T.useState(null),[n,a]=T.useState(null),[o,l]=T.useState(""),[i,d]=T.useState(""),[h,f]=T.useState(""),[g,v]=T.useState(!0),[_,j]=T.useState("visual"),{data:w,isLoading:k}=zt({queryKey:["email-templates"],queryFn:async()=>{const{data:L,error:B}=await Z.from("email_templates").select("*").order("name");if(B)throw B;return L.map($=>({...$,available_variables:$.available_variables||[]}))}}),M=Wt({mutationFn:async L=>{const{error:B}=await Z.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(B)throw B},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),be.success("Email template updated successfully"),r(null)},onError:L=>{be.error("Failed to update template: "+L.message)}}),S=L=>{r(L),l(L.subject),d(L.body_html),f(L.description||""),v(L.is_active),j("visual")},E=()=>{s&&M.mutate({id:s.id,subject:o,body_html:i,description:h,is_active:g})},D=(L,B)=>{let $=L;return B.forEach(V=>{const W=`{{${V.key}}}`,G=`[${V.label}]`;$=$.replace(new RegExp(W.replace(/[{}]/g,"\\$&"),"g"),G)}),$};return s?e.jsxs(Vs,{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(Y,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(bi,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(Y,{variant:"outline",onClick:()=>a(s),children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(Y,{onClick:E,disabled:M.isPending,children:[e.jsx(um,{className:"h-4 w-4 mr-2"}),M.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"h-5 w-5"}),s.name]}),e.jsxs(Tr,{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(je,{htmlFor:"active-toggle",children:"Active"}),e.jsx(ln,{id:"active-toggle",checked:g,onCheckedChange:v})]})]})}),e.jsxs($e,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",value:h,onChange:L=>f(L.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"subject",children:"Email Subject"}),e.jsx(Be,{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(je,{children:"Email Body"}),e.jsx(Qa,{value:_,onValueChange:L=>j(L),children:e.jsxs(Ga,{className:"h-8",children:[e.jsxs(Fs,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(Ck,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(Fs,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(vk,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(uPt,{content:i,onChange:d,variables:s.available_variables}):e.jsx(Rr,{value:i,onChange:L=>d(L.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(js,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Email Preview"}),e.jsxs(en,{children:["Subject: ",o.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:D(i,s.available_variables)}})})]})})]}):e.jsx(Vs,{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"})]}),k?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,B)=>e.jsx(Oe,{children:e.jsxs(Ht,{children:[e.jsx(ys,{className:"h-5 w-48"}),e.jsx(ys,{className:"h-4 w-96"})]})},B))}):e.jsx("div",{className:"grid gap-4",children:w==null?void 0:w.map(L=>e.jsxs(Oe,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Ht,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Gt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(zr,{className:"h-5 w-5 text-muted-foreground"}),L.name,!L.is_active&&e.jsx(ct,{variant:"secondary",children:"Inactive"})]}),e.jsx(Tr,{children:L.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>a(L),children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(Y,{size:"sm",onClick:()=>S(L),children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx($e,{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(B=>e.jsx(ct,{variant:"outline",className:"font-mono text-xs",children:`{{${B.key}}}`},B.key))})]})]})})]},L.id))}),e.jsx(js,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(en,{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:D(n.body_html,n.available_variables)}})})]})})]})})}function mPt(){const t=vs(),[s,r]=T.useState("templates"),[n,a]=T.useState(null),[o,l]=T.useState(null),[i,d]=T.useState(!1),[h,f]=T.useState(!1),[g,v]=T.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,j]=T.useState({name:"",description:"",icon:"📧"}),{data:w=[]}=zt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:G,error:J}=await Z.from("email_template_categories").select("*").order("sort_order");if(J)throw J;return G}}),{data:k=[],isLoading:M}=zt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:G,error:J}=await Z.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(J)throw J;return G}}),S=Wt({mutationFn:async G=>{const J={title:G.title,subject:G.subject,body:G.body,description:G.description||null,tone:G.tone||null,category_id:G.category_id||null,is_active:G.is_active};if(G.id){const{error:ne}=await Z.from("agent_email_templates").update(J).eq("id",G.id);if(ne)throw ne}else{const{error:ne}=await Z.from("agent_email_templates").insert(J);if(ne)throw ne}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),d(!1),be.success(n?"Template updated":"Template created")},onError:()=>be.error("Failed to save template")}),E=Wt({mutationFn:async G=>{const{error:J}=await Z.from("agent_email_templates").delete().eq("id",G);if(J)throw J},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),be.success("Template deleted")}}),D=Wt({mutationFn:async G=>{const J={name:G.name,description:G.description||null,icon:G.icon};if(G.id){const{error:ne}=await Z.from("email_template_categories").update(J).eq("id",G.id);if(ne)throw ne}else{const ne=w.length>0?Math.max(...w.map(ee=>ee.sort_order))+1:0,{error:ie}=await Z.from("email_template_categories").insert({...J,sort_order:ne});if(ie)throw ie}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),f(!1),be.success(o?"Category updated":"Category created")},onError:()=>be.error("Failed to save category")}),L=Wt({mutationFn:async G=>{const{error:J}=await Z.from("email_template_categories").delete().eq("id",G);if(J)throw J},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),be.success("Category deleted")}}),B=()=>{a(null),v({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),d(!0)},$=G=>{a(G),v({title:G.title,subject:G.subject,body:G.body,description:G.description||"",tone:G.tone||"",category_id:G.category_id||"",is_active:G.is_active}),d(!0)},V=()=>{l(null),j({name:"",description:"",icon:"📧"}),f(!0)},W=G=>{l(G),j({name:G.name,description:G.description||"",icon:G.icon}),f(!0)};return e.jsx(Vs,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(Yu,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(Qa,{value:s,onValueChange:r,children:[e.jsxs(Ga,{children:[e.jsxs(Fs,{value:"templates",className:"gap-2",children:[e.jsx(zr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(Fs,{value:"categories",className:"gap-2",children:[e.jsx(om,{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(Y,{onClick:B,className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Template"}),e.jsx(Ct,{className:"hidden md:table-cell",children:"Category"}),e.jsx(Ct,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:M?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8",children:e.jsx(Us,{className:"h-6 w-6 animate-spin mx-auto"})})}):k.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):k.map(G=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:G.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:G.subject})]})}),e.jsx(ot,{className:"hidden md:table-cell",children:G.category?e.jsxs(ct,{variant:"outline",className:"gap-1",children:[G.category.icon," ",G.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ot,{className:"hidden md:table-cell",children:G.tone?e.jsx(ct,{variant:"secondary",children:G.tone}):"—"}),e.jsx(ot,{children:e.jsx(ct,{variant:G.is_active?"default":"secondary",children:G.is_active?"Active":"Inactive"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>$(G),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&E.mutate(G.id)},children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},G.id))})]})})})]}),e.jsxs(Zs,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(Y,{onClick:V,className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w.map(G=>e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:G.icon})," ",G.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>W(G),children:e.jsx(Xa,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&L.mutate(G.id)},children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs($e,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:G.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[k.filter(J=>J.category_id===G.id).length," templates"]})]})]},G.id))})]})]}),e.jsx(js,{open:i,onOpenChange:d,children:e.jsxs(_s,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{children:"Title"}),e.jsx(Be,{value:g.title,onChange:G=>v(J=>({...J,title:G.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{children:"Category"}),e.jsxs(er,{value:g.category_id,onValueChange:G=>v(J=>({...J,category_id:G})),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select category"})}),e.jsx(Js,{children:w.map(G=>e.jsxs(Et,{value:G.id,children:[G.icon," ",G.name]},G.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{children:"Subject Line"}),e.jsx(Be,{value:g.subject,onChange:G=>v(J=>({...J,subject:G.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(je,{children:"Email Body"}),e.jsx(Rr,{value:g.body,onChange:G=>v(J=>({...J,body:G.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(je,{children:"Description (internal)"}),e.jsx(Be,{value:g.description,onChange:G=>v(J=>({...J,description:G.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{children:"Tone"}),e.jsx(Be,{value:g.tone,onChange:G=>v(J=>({...J,tone:G.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{checked:g.is_active,onCheckedChange:G=>v(J=>({...J,is_active:G}))}),e.jsx(je,{children:"Active"})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(Y,{onClick:()=>S.mutate({...g,id:n==null?void 0:n.id}),disabled:S.isPending||!g.title||!g.subject||!g.body,children:[S.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(js,{open:h,onOpenChange:f,children:e.jsxs(_s,{className:"sm:max-w-[450px]",children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{children:"Icon"}),e.jsx(Be,{value:_.icon,onChange:G=>j(J=>({...J,icon:G.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{children:"Name"}),e.jsx(Be,{value:_.name,onChange:G=>j(J=>({...J,name:G.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{children:"Description"}),e.jsx(Be,{value:_.description,onChange:G=>j(J=>({...J,description:G.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsxs(Y,{onClick:()=>D.mutate({..._,id:o==null?void 0:o.id}),disabled:D.isPending||!_.name,children:[D.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const pPt=({brokerageId:t})=>{var Co,Fc;const{toast:s}=Sa(),[r,n]=T.useState([]),[a,o]=T.useState(!0),[l,i]=T.useState(""),[d,h]=T.useState("all"),[f,g]=T.useState(new Set),[v,_]=T.useState(!1),[j,w]=T.useState({}),[k,M]=T.useState(!1),[S,E]=T.useState(!1),[D,L]=T.useState({email:"",name:"",password:"",phone:""}),[B,$]=T.useState(!1),[V,W]=T.useState(null),[G,J]=T.useState(!1),[ne,ie]=T.useState(!1),[ee,de]=T.useState(!1),[oe,ue]=T.useState(""),[ce,ge]=T.useState(!1),[Te,ve]=T.useState([]),[ye,Se]=T.useState(!1),[Ke,Ae]=T.useState(!1),[Ee,He]=T.useState(null),[Ue,De]=T.useState({name:"",phone:"",email:""}),[Ge,wt]=T.useState(!1),[Ie,st]=T.useState(!1),[he,We]=T.useState(null),[et,Ye]=T.useState("asc"),[ke,at]=T.useState(!1),[Fe,it]=T.useState(null),[dt,tt]=T.useState(!1),[ut,xt]=T.useState(null),[_t,qe]=T.useState(""),[Lt,Rt]=T.useState(!1),[Kt,Xt]=T.useState(null);T.useEffect(()=>{fs(),ss()},[t]);const ss=async()=>{try{const{data:rt,error:_e}=await Z.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(_e)throw _e;ve((rt==null?void 0:rt.map(Pe=>Pe.user_id))||[])}catch(rt){console.error("Error loading brokerage managers:",rt)}},fs=async()=>{try{o(!0);const{data:rt,error:_e}=await Z.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(_e)throw _e;const Pe=rt.agents||[];if(n(Pe),Pe.length>0){const Qe=Pe.map(kt=>kt.id),{data:Tt}=await Z.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",Qe);if(Tt&&Tt.length>0){const kt=Tt.map(Ft=>Ft.assistant_id),{data:Dt}=await Z.from("profiles").select("id, name, email").in("id",kt),Zt={};for(const Ft of Tt){const Jt=Dt==null?void 0:Dt.find(Ss=>Ss.id===Ft.assistant_id);Jt&&(Zt[Ft.agent_id]={name:Jt.name||"",email:Jt.email||""})}w(Zt)}else w({})}}catch(rt){console.error("Error loading agents:",rt),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{o(!1)}},fr=async()=>{if(!D.email||!D.name||!D.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}E(!0);try{const{data:{session:rt}}=await Z.auth.getSession(),_e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt==null?void 0:rt.access_token}`},body:JSON.stringify({...D,brokerageId:t})}),Pe=await _e.json();if(!_e.ok)throw new Error(Pe.error||"Failed to create agent");s({title:"Success",description:`Agent ${D.email} created successfully`}),L({email:"",name:"",password:"",phone:""}),M(!1),fs()}catch(rt){console.error("Error creating agent:",rt),s({title:"Error",description:rt.message||"Failed to create agent",variant:"destructive"})}finally{E(!1)}},yt=async rt=>{try{const{data:{session:_e}}=await Z.auth.getSession(),Pe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_e==null?void 0:_e.access_token}`},body:JSON.stringify({userId:rt})}),Qe=await Pe.json();if(!Pe.ok)throw new Error(Qe.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(_e){console.error("Error resending welcome email:",_e),s({title:"Error",description:_e.message||"Failed to resend welcome email",variant:"destructive"})}},bs=async(rt,_e)=>{try{const{error:Pe}=await Z.functions.invoke("send-password-reset",{body:{email:rt,redirectTo:window.location.origin}});if(Pe)throw Pe;s({title:"Password Reset Sent",description:`Password reset email sent to ${_e}`})}catch(Pe){console.error("Error sending password reset:",Pe),s({title:"Error",description:Pe.message||"Failed to send password reset email",variant:"destructive"})}},gr=rt=>{W(rt),$(!0)},Br=rt=>{He(rt),De({name:rt.name,phone:rt.phone||"",email:rt.email}),Ae(!0)},na=async()=>{if(!Ee)return;if(!Ue.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const rt=Ue.email.trim().toLowerCase()!==Ee.email.toLowerCase();wt(!0);try{if(rt){if(!Ue.email.trim())throw new Error("Email is required");st(!0);const{data:{session:Pe}}=await Z.auth.getSession(),Qe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Pe==null?void 0:Pe.access_token}`},body:JSON.stringify({agentId:Ee.id,newEmail:Ue.email.trim(),brokerageId:t})}),Tt=await Qe.json();if(st(!1),!Qe.ok)throw new Error(Tt.error||"Failed to update email")}const{error:_e}=await Z.from("profiles").update({name:Ue.name.trim(),phone:Ue.phone.trim()||null}).eq("id",Ee.id);if(_e)throw _e;s({title:"Success",description:"Agent profile updated successfully"}),Ae(!1),He(null),fs()}catch(_e){console.error("Error updating agent:",_e),s({title:"Error",description:_e.message||"Failed to update agent",variant:"destructive"})}finally{wt(!1),st(!1)}},za=async()=>{if(!oe){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}ge(!0);try{const{data:{session:rt}}=await Z.auth.getSession(),_e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt==null?void 0:rt.access_token}`},body:JSON.stringify({userId:oe,role:"brokerage_manager",action:"add",brokerageId:t})}),Pe=await _e.json();if(!_e.ok)throw new Error(Pe.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),de(!1),ue(""),ss()}catch(rt){console.error("Error adding brokerage manager:",rt),s({title:"Error",description:rt.message||"Failed to add brokerage manager",variant:"destructive"})}finally{ge(!1)}},go=async rt=>{try{const{data:{session:_e}}=await Z.auth.getSession(),Pe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_e==null?void 0:_e.access_token}`},body:JSON.stringify({userId:rt,role:"brokerage_manager",action:"remove",brokerageId:t})}),Qe=await Pe.json();if(!Pe.ok)throw new Error(Qe.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),ss()}catch(_e){console.error("Error removing brokerage manager:",_e),s({title:"Error",description:_e.message||"Failed to remove brokerage manager",variant:"destructive"})}},Ia=rt=>Te.includes(rt),nn=rt=>{xt(rt),qe(""),tt(!0)},Qt=async()=>{if(!(!ut||!_t)){if(_t.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}Rt(!0);try{const{data:{session:rt}}=await Z.auth.getSession(),_e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt==null?void 0:rt.access_token}`},body:JSON.stringify({agentId:ut.id,brokerageId:t,action:"set_password",newPassword:_t})}),Pe=await _e.json();if(!_e.ok)throw new Error(Pe.error||"Failed to set password");s({title:"Success",description:`Password set for ${ut.name}`}),tt(!1),xt(null),qe("")}catch(rt){console.error("Error setting password:",rt),s({title:"Error",description:rt.message||"Failed to set password",variant:"destructive"})}finally{Rt(!1)}}},lr=async rt=>{Xt(rt.id);try{const{data:{session:_e}}=await Z.auth.getSession(),Pe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_e==null?void 0:_e.access_token}`},body:JSON.stringify({agentId:rt.id,brokerageId:t,action:"claim_account"})}),Qe=await Pe.json();if(!Pe.ok)throw new Error(Qe.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${rt.name}`}),fs()}catch(_e){console.error("Error claiming account:",_e),s({title:"Error",description:_e.message||"Failed to claim account",variant:"destructive"})}finally{Xt(null)}},Vr=async()=>{if(V){J(!0);try{const{data:{session:rt}}=await Z.auth.getSession(),_e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt==null?void 0:rt.access_token}`},body:JSON.stringify({userId:V.id,brokerageId:t})}),Pe=await _e.json();if(!_e.ok)throw new Error(Pe.error||"Failed to remove agent");s({title:"Success",description:`${V.name} has been removed from your brokerage`}),$(!1),W(null),fs()}catch(rt){console.error("Error removing agent:",rt),s({title:"Error",description:rt.message||"Failed to remove agent",variant:"destructive"})}finally{J(!1)}}},Pr=rt=>{const _e=rt.trim().split(" ");return _e.length>1?_e[_e.length-1].toLowerCase():rt.toLowerCase()},on=rt=>{he===rt?Ye(et==="asc"?"desc":"asc"):(We(rt),Ye("asc"))},cs=rt=>he!==rt?e.jsx(Hp,{className:"ml-1 h-4 w-4"}):et==="asc"?e.jsx(Wm,{className:"ml-1 h-4 w-4"}):e.jsx(jx,{className:"ml-1 h-4 w-4"}),ka=r.filter(rt=>{if(d==="active"&&!rt.claimed||d==="pending"&&rt.claimed)return!1;if(!l)return!0;const _e=l.toLowerCase();return rt.name.toLowerCase().includes(_e)||rt.email.toLowerCase().includes(_e)}),zi=[...ka].sort((rt,_e)=>{if(!he)return 0;let Pe=0;return he==="name"?Pe=Pr(rt.name).localeCompare(Pr(_e.name)):he==="status"&&(Pe=rt.claimed===_e.claimed?0:rt.claimed?-1:1),et==="asc"?Pe:-Pe});ka.filter(rt=>rt.claimed&&!Ia(rt.id));const li=rt=>{g(_e=>{const Pe=new Set(_e);return Pe.has(rt)?Pe.delete(rt):Pe.add(rt),Pe})},Or=()=>{f.size===zi.length?g(new Set):g(new Set(zi.map(rt=>rt.id)))},Oi=()=>{g(new Set)},Rc=async()=>{const rt=Array.from(f);if(rt.length===0)return;_(!0);let _e=0,Pe=0;try{const{data:{session:Qe}}=await Z.auth.getSession();for(const Tt of rt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qe==null?void 0:Qe.access_token}`},body:JSON.stringify({userId:Tt})})).ok?_e++:Pe++}catch{Pe++}_e>0?s({title:"Success",description:`Welcome emails sent to ${_e} agent${_e>1?"s":""}${Pe>0?` (${Pe} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),Oi()}catch(Qe){console.error("Error bulk sending welcome emails:",Qe),s({title:"Error",description:Qe.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return a?e.jsx(Oe,{children:e.jsx($e,{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(Oe,{children:[e.jsx(Ht,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Agents"}),e.jsx(Tr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Y,{variant:"outline",onClick:()=>de(!0),children:[e.jsx(Bu,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(Y,{variant:"outline",onClick:()=>ie(!0),children:[e.jsx(Qy,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(Y,{onClick:()=>M(!0),children:[e.jsx(Zc,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs($e,{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(On,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search agents...",value:l,onChange:rt=>i(rt.target.value),className:"pl-9"})]}),e.jsxs(er,{value:d,onValueChange:rt=>h(rt),children:[e.jsx(Qs,{className:"w-[160px]",children:e.jsx(tr,{placeholder:"Filter by status"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Agents"}),e.jsx(Et,{value:"active",children:"Active"}),e.jsx(Et,{value:"pending",children:"Pending"})]})]})]}),f.size>0&&e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/50 p-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[f.size," agent",f.size>1?"s":""," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(Y,{size:"sm",variant:"outline",onClick:Rc,disabled:v,children:[e.jsx(zr,{className:"mr-2 h-4 w-4"}),v?"Sending...":"Resend Welcome Email"]}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:Oi,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-[40px]",children:e.jsx(Do,{checked:zi.length>0&&f.size===zi.length,onCheckedChange:Or,"aria-label":"Select all"})}),e.jsx(Ct,{children:e.jsxs(Y,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>on("name"),children:["Name (Last)",cs("name")]})}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:e.jsxs(Y,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>on("status"),children:["Status",cs("status")]})}),e.jsx(Ct,{children:"Actions"})]})}),e.jsx(Bn,{children:zi.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):zi.map(rt=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsx(Do,{checked:f.has(rt.id),onCheckedChange:()=>li(rt.id),"aria-label":`Select ${rt.name}`})}),e.jsx(ot,{className:"font-medium",children:rt.name}),e.jsx(ot,{children:rt.email}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[rt.claimed?e.jsx(ct,{variant:"default",children:"Active"}):e.jsx(ct,{variant:"secondary",children:"Pending"}),Ia(rt.id)&&e.jsxs(ct,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(VE,{className:"mr-1 h-3 w-3"}),"Manager"]}),j[rt.id]&&e.jsxs(ct,{variant:"outline",className:"text-xs",children:[e.jsx(br,{className:"mr-1 h-3 w-3"}),"Asst: ",j[rt.id].name||j[rt.id].email]})]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>{it(rt),at(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(md,{className:"h-4 w-4"})}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>Br(rt),title:"Edit agent",children:e.jsx(Xa,{className:"h-4 w-4"})}),!rt.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>yt(rt.id),title:"Resend welcome email",children:e.jsx(zr,{className:"h-4 w-4"})}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>lr(rt),title:"Claim account for agent",disabled:Kt===rt.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(Lk,{className:"h-4 w-4"})})]}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>nn(rt),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(zu,{className:"h-4 w-4"})}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>bs(rt.email,rt.name),title:"Send password reset email",children:e.jsx(kk,{className:"h-4 w-4"})}),Ia(rt.id)&&e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>go(rt.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(Bu,{className:"h-4 w-4"})}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>gr(rt),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},rt.id))})]})})]})]}),e.jsx(js,{open:k,onOpenChange:M,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Add New Agent"}),e.jsx(en,{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(je,{htmlFor:"name",children:"Name"}),e.jsx(Be,{id:"name",value:D.name,onChange:rt=>L({...D,name:rt.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"email",children:"Email"}),e.jsx(Be,{id:"email",type:"email",value:D.email,onChange:rt=>L({...D,email:rt.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Be,{id:"phone",type:"tel",value:D.phone,onChange:rt=>L({...D,phone:rt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"password",children:"Temporary Password"}),e.jsx(Be,{id:"password",type:"password",value:D.password,onChange:rt=>L({...D,password:rt.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),e.jsx(Y,{onClick:fr,disabled:S,children:S?"Creating...":"Create Agent"})]})]})}),e.jsx(js,{open:B,onOpenChange:$,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Remove Agent"}),e.jsxs(en,{children:["Are you sure you want to remove ",e.jsx("strong",{children:V==null?void 0:V.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(Y,{variant:"destructive",onClick:Vr,disabled:G,children:G?"Removing...":"Remove Agent"})]})]})}),e.jsx(KVe,{open:ne,onOpenChange:ie,fixedBrokerageId:t,onSuccess:fs}),e.jsx(js,{open:ee,onOpenChange:de,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Add Brokerage Manager"}),e.jsx(en,{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(je,{children:"Select Agent"}),e.jsxs(_l,{open:ye,onOpenChange:Se,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":ye,className:"w-full justify-between",children:[oe?((Co=r.find(rt=>rt.id===oe))==null?void 0:Co.name)+" ("+((Fc=r.find(rt=>rt.id===oe))==null?void 0:Fc.email)+")":"Select an agent to promote...",e.jsx(mg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(nl,{className:"w-full p-0",align:"start",children:e.jsxs(wg,{children:[e.jsx(jg,{placeholder:"Search by name or email..."}),e.jsxs(kg,{className:"max-h-[200px]",children:[e.jsx(Ng,{children:"No eligible agents found."}),e.jsx(Sg,{children:r.filter(rt=>!Ia(rt.id)).map(rt=>e.jsxs(Vm,{value:`${rt.name} ${rt.email}`,onSelect:()=>{ue(rt.id),Se(!1)},children:[e.jsx(ma,{className:`mr-2 h-4 w-4 ${oe===rt.id?"opacity-100":"opacity-0"}`}),rt.name," (",rt.email,")"]},rt.id))})]})]})})]}),r.filter(rt=>!Ia(rt.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>de(!1),children:"Cancel"}),e.jsx(Y,{onClick:za,disabled:ce||!oe,children:ce?"Adding...":"Add as Manager"})]})]})}),e.jsx(js,{open:Ke,onOpenChange:Ae,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Edit Agent"}),e.jsxs(en,{children:["Update profile information for ",Ee==null?void 0:Ee.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"edit-name",children:"Name"}),e.jsx(Be,{id:"edit-name",value:Ue.name,onChange:rt=>De({...Ue,name:rt.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"edit-email",children:"Email"}),e.jsx(Be,{id:"edit-email",type:"email",value:Ue.email,onChange:rt=>De({...Ue,email:rt.target.value}),placeholder:"agent@example.com"}),Ue.email.trim().toLowerCase()!==(Ee==null?void 0:Ee.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(je,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Be,{id:"edit-phone",type:"tel",value:Ue.phone,onChange:rt=>De({...Ue,phone:rt.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>Ae(!1),children:"Cancel"}),e.jsx(Y,{onClick:na,disabled:Ge||Ie,children:Ie?"Updating email...":Ge?"Saving...":"Save Changes"})]})]})}),Fe&&e.jsx(ZVe,{open:ke,onOpenChange:rt=>{at(rt),rt||it(null)},userId:Fe.id,userName:Fe.name}),e.jsx(js,{open:dt,onOpenChange:tt,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Set Password"}),e.jsxs(en,{children:["Set a new password for ",ut==null?void 0:ut.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(je,{htmlFor:"new-password",children:"New Password"}),e.jsx(Be,{id:"new-password",type:"password",value:_t,onChange:rt=>qe(rt.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(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>tt(!1),children:"Cancel"}),e.jsx(Y,{onClick:Qt,disabled:Lt||!_t||_t.length<6,children:Lt?"Setting...":"Set Password"})]})]})})]})},fPt={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},gPt={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},xPt=t=>{switch(t){case"academy_video":return e.jsx(Wn,{className:"h-4 w-4"});case"template":return e.jsx(Yn,{className:"h-4 w-4"});case"toolbox":return e.jsx(Yn,{className:"h-4 w-4"});case"newsletter":return e.jsx(r0,{className:"h-4 w-4"});case"social_swag":return e.jsx(Sn,{className:"h-4 w-4"});case"event":return e.jsx(xn,{className:"h-4 w-4"});default:return e.jsx(bn,{className:"h-4 w-4"})}},yPt=({brokerageId:t})=>{const{toast:s}=Sa(),[r,n]=T.useState([]),[a,o]=T.useState([]),[l,i]=T.useState([]),[d,h]=T.useState(!0),[f,g]=T.useState(null);T.useEffect(()=>{v()},[t]);const v=async()=>{try{h(!0);const{data:w,error:k}=await Z.from("profiles").select("id, name, email").eq("brokerage_id",t);if(k)throw k;const M=w.map(J=>J.id),S=new Map(w.map(J=>[J.id,J]));if(M.length===0){n([]),o([]),i([]);return}const{data:E,error:D}=await Z.from("activity_logs").select("*").in("user_id",M).order("launched_at",{ascending:!1});if(D)throw D;const L=E.map(J=>{var ne,ie;return{id:J.id,user_id:J.user_id,app_name:J.app_name,launched_at:J.launched_at,user_name:((ne=S.get(J.user_id))==null?void 0:ne.name)||"Unknown",user_email:((ie=S.get(J.user_id))==null?void 0:ie.email)||"Unknown"}});n(L);const{data:B,error:$}=await Z.from("content_engagement_logs").select("*").in("user_id",M).order("created_at",{ascending:!1});if($)throw $;const V=(B||[]).map(J=>{var ne,ie;return{id:J.id,user_id:J.user_id,resource_type:J.resource_type,resource_id:J.resource_id,resource_title:J.resource_title,action_type:J.action_type,created_at:J.created_at,user_name:((ne=S.get(J.user_id))==null?void 0:ne.name)||"Unknown",user_email:((ie=S.get(J.user_id))==null?void 0:ie.email)||"Unknown"}});o(V);const W=new Map;w.forEach(J=>{W.set(J.id,{user_id:J.id,user_name:J.name,user_email:J.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(J=>{const ne=W.get(J.user_id);ne&&(ne.app_launches++,(!ne.last_activity||new Date(J.launched_at)>new Date(ne.last_activity))&&(ne.last_activity=J.launched_at))}),V.forEach(J=>{const ne=W.get(J.user_id);ne&&(ne.content_views++,(!ne.last_activity||new Date(J.created_at)>new Date(ne.last_activity))&&(ne.last_activity=J.created_at))});const G=Array.from(W.values()).filter(J=>J.app_launches>0||J.content_views>0).sort((J,ne)=>new Date(ne.last_activity).getTime()-new Date(J.last_activity).getTime());i(G)}catch(w){console.error("Error loading activity:",w),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{h(!1)}},_=w=>r.filter(k=>k.user_id===w),j=w=>a.filter(k=>k.user_id===w);return d?e.jsx(Oe,{children:e.jsx($e,{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(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Agent Activity"}),e.jsx(Tr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx($e,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{className:"text-center",children:"App Launches"}),e.jsx(Ct,{className:"text-center",children:"Content Views"}),e.jsx(Ct,{children:"Last Active"})]})}),e.jsx(Bn,{children:l.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(w=>e.jsxs(ws,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>g({id:w.user_id,name:w.user_name,email:w.user_email}),children:[e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:w.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:w.user_email})]})}),e.jsx(ot,{className:"text-center",children:e.jsxs(ct,{variant:"outline",className:"gap-1",children:[e.jsx(Kl,{className:"h-3 w-3"}),w.app_launches]})}),e.jsx(ot,{className:"text-center",children:e.jsxs(ct,{variant:"secondary",className:"gap-1",children:[e.jsx(Yn,{className:"h-3 w-3"}),w.content_views]})}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:w.last_activity&&_u(new Date(w.last_activity),{addSuffix:!0})})]},w.user_id))})]})})})]}),e.jsx(js,{open:!!f,onOpenChange:w=>!w&&g(null),children:e.jsxs(_s,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(en,{children:f==null?void 0:f.email})]}),e.jsxs(Qa,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-2",children:[e.jsx(Fs,{value:"content",children:"Content Engagement"}),e.jsx(Fs,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Resource"}),e.jsx(Ct,{children:"Type"}),e.jsx(Ct,{children:"Action"}),e.jsx(Ct,{children:"Time"})]})}),e.jsx(Bn,{children:f&&j(f.id).length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):f&&j(f.id).map(w=>e.jsxs(ws,{children:[e.jsx(ot,{className:"max-w-[200px] truncate font-medium",children:w.resource_title}),e.jsx(ot,{children:e.jsxs(ct,{variant:"outline",className:"gap-1",children:[xPt(w.resource_type),fPt[w.resource_type]||w.resource_type]})}),e.jsx(ot,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:gPt[w.action_type]||w.action_type})}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:_u(new Date(w.created_at),{addSuffix:!0})})]},w.id))})]})})}),e.jsx(Zs,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"App"}),e.jsx(Ct,{children:"Time"})]})}),e.jsx(Bn,{children:f&&_(f.id).length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):f&&_(f.id).map(w=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsx(ct,{variant:"outline",children:w.app_name})}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:_u(new Date(w.launched_at),{addSuffix:!0})})]},w.id))})]})})})]})]})})]})},vPt=({brokerageId:t})=>{const{toast:s}=Sa(),[r,n]=T.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=T.useState(!0);T.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:d}=await Z.from("profiles").select("id").eq("brokerage_id",t);if(d)throw d;const h=i.map(L=>L.id),f=h.length;if(h.length===0){o(!1);return}const{data:g,error:v}=await Z.from("profiles").select("id, email").in("id",h);if(v)throw v;const{count:_}=await Z.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),j=_||0,w=f-j,{count:k}=await Z.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",h),M=new Date;M.setDate(M.getDate()-7);const{count:S}=await Z.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",h).gte("launched_at",M.toISOString()),E=new Date;E.setMonth(E.getMonth()-1);const{count:D}=await Z.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",h).gte("launched_at",E.toISOString());n({totalAgents:f,activeAgents:j,pendingAgents:w,totalLaunches:k||0,launchesThisWeek:S||0,launchesThisMonth:D||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(Oe,{children:e.jsx($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(br,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(yi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(ca,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(wx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(wx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(wx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs($e,{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"})]})]})]})},_Pt=({brokerageId:t})=>{const[s,r]=T.useState([]),[n,a]=T.useState(!0),[o,l]=T.useState(!1),[i,d]=T.useState(!1),[h,f]=T.useState({description:"",maxUses:""});T.useEffect(()=>{g()},[t]);const g=async()=>{try{const{data:M,error:S}=await Z.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;r(M||[])}catch(M){console.error("Error loading invite codes:",M),be.error("Failed to load invite links")}finally{a(!1)}},v=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const M=v(),{error:S}=await Z.from("invite_codes").insert({code:M,description:h.description||null,max_uses:h.maxUses?parseInt(h.maxUses):null,brokerage_id:t,is_active:!0});if(S)throw S;be.success("Invite link created!"),d(!1),f({description:"",maxUses:""}),g()}catch(M){console.error("Error creating invite code:",M),be.error("Failed to create invite link")}finally{l(!1)}},j=async M=>{try{const{error:S}=await Z.from("invite_codes").delete().eq("id",M);if(S)throw S;be.success("Invite link deleted"),r(s.filter(E=>E.id!==M))}catch(S){console.error("Error deleting invite code:",S),be.error("Failed to delete invite link")}},w=async(M,S)=>{try{const{error:E}=await Z.from("invite_codes").update({is_active:!S}).eq("id",M);if(E)throw E;r(s.map(D=>D.id===M?{...D,is_active:!S}:D)),be.success(`Invite link ${S?"deactivated":"activated"}`)}catch(E){console.error("Error toggling invite code:",E),be.error("Failed to update invite link")}},k=M=>{const S=`${window.location.origin}/join?code=${M}`;navigator.clipboard.writeText(S),be.success("Link copied to clipboard!")};return n?e.jsx(Oe,{children:e.jsx($e,{className:"flex items-center justify-center py-8",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Ro,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(Tr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(js,{open:i,onOpenChange:d,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{size:"sm",children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Create Invite Link"}),e.jsx(en,{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(je,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Be,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:h.description,onChange:M=>f({...h,description:M.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(Be,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:h.maxUses,onChange:M=>f({...h,maxUses:M.target.value})})]}),e.jsx(Y,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx($e,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ro,{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(M=>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:M.code}),e.jsx(ct,{variant:M.is_active?"default":"secondary",children:M.is_active?"Active":"Inactive"})]}),M.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:M.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[M.uses_count," uses",M.max_uses&&` / ${M.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>k(M.code),title:"Copy link",children:e.jsx(Di,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>w(M.id,M.is_active),title:M.is_active?"Deactivate":"Activate",children:M.is_active?"Disable":"Enable"}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>j(M.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(Ir,{className:"h-4 w-4"})})]})]},M.id))})})]})},bPt=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=T.useState(""),[h,f]=T.useState([]),[g,v]=T.useState(""),[_,j]=T.useState(!1),w=D=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(D),k=()=>{const D=i.trim().toLowerCase();if(D&&w(D)&&!h.includes(D)){if(h.length>=10){be.error("Maximum 10 emails per invite");return}f([...h,D]),d("")}else D&&!w(D)?be.error("Please enter a valid email address"):h.includes(D)&&be.error("Email already added")},M=D=>{f(h.filter(L=>L!==D))},S=D=>{(D.key==="Enter"||D.key===",")&&(D.preventDefault(),k())},E=async()=>{if(h.length===0){be.error("Please add at least one email address");return}j(!0);try{const{data:D,error:L}=await Z.functions.invoke("send-referral-invite",{body:{emails:h,personalMessage:g.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(L)throw L;D.successCount===D.totalCount?be.success(`${D.successCount} invite${D.successCount>1?"s":""} sent successfully!`):be.warning(`${D.successCount} of ${D.totalCount} invites sent. Some failed.`),f([]),v(""),s(!1),l==null||l()}catch(D){console.error("Error sending invites:",D),be.error("Failed to send invites. Please try again.")}finally{j(!1)}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[550px]",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(en,{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(oo,{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(je,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:D=>d(D.target.value),onKeyDown:S,onBlur:k}),e.jsx(Y,{type:"button",variant:"secondary",onClick:k,children:"Add"})]}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:h.map(D=>e.jsxs(ct,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[D,e.jsx("button",{type:"button",onClick:()=>M(D),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Xr,{className:"h-3 w-3"})})]},D))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Rr,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:g,onChange:D=>v(D.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(Sn,{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(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Y,{onClick:E,disabled:h.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(Wa,{className:"h-4 w-4 mr-2"}),"Send ",h.length>0&&`(${h.length})`," Invite",h.length!==1?"s":""]})})]})]})})},wPt=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=T.useState([]),[a,o]=T.useState(!0);T.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:d,error:h}=await Z.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(h)throw h;n(d||[])}catch(d){console.error("Error fetching invites:",d)}finally{o(!1)}},i=d=>{switch(d){case"signed_up":return e.jsxs(ct,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(yi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(ct,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(Cc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(ct,{variant:"secondary",className:"gap-1",children:[e.jsx(ca,{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(zr,{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 ",Bs(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},jPt=()=>{const{brokerageId:t,user:s}=Ys(),[r,n]=T.useState(null),[a,o]=T.useState(""),[l,i]=T.useState(""),[d,h]=T.useState([]),[f,g]=T.useState(!0),[v,_]=T.useState(!1),[j,w]=T.useState(0);T.useEffect(()=>{t&&k()},[t]);const k=async()=>{try{const[B,$]=await Promise.all([Z.from("brokerages").select("name").eq("id",t).single(),s?Z.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);B.data&&o(B.data.name),$.data&&i($.data.name||"A LevelUp Member");const{data:V}=await Z.from("referral_codes").select("code").eq("brokerage_id",t).single();if(V)n(V.code);else{const G=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await Z.from("referral_codes").insert({brokerage_id:t,code:G}),n(G)}const{data:W}=await Z.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});h(W||[])}catch(B){console.error("Error fetching referral data:",B)}finally{g(!1)}},M=()=>{const B=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(B),be.success("Referral link copied to clipboard!")},S=d.filter(B=>B.status==="qualified").length,E=d.filter(B=>B.status==="pending").length,D=S*25,L=Math.max(0,Math.ceil((299-D)/25));return f?null:e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{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(oo,{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:["$",D]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),D>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(yi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),L>0&&D<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"})]}),D>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(Sn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs($e,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(Y,{onClick:()=>_(!0),className:"w-full",size:"lg",children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(Y,{onClick:M,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(Di,{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(Ad,{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:["$",D]}),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(br,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(ca,{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:E}),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(wPt,{brokerageId:t,refreshTrigger:j}),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(B=>{var $,V;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:(($=B.referred_brokerage)==null?void 0:$.name)||((V=B.referred_user)==null?void 0:V.email)||"Pending setup"}),e.jsxs(ct,{variant:B.status==="qualified"?"default":B.status==="pending"?"secondary":"destructive",className:B.status==="qualified"?"bg-green-600":"",children:[B.status==="qualified"&&e.jsx(yi,{className:"h-3 w-3 mr-1"}),B.status]})]},B.id)})]})]})]}),e.jsx(bPt,{open:v,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>w(B=>B+1)})]})},kPt=({brokerageId:t})=>{const s=Yr(),{teams:r,isLoading:n}=CN(t),{data:a,isLoading:o}=zt({queryKey:["team-aggregate-stats",t,r.map(f=>f.id)],queryFn:async()=>{if(r.length===0)return[];const f=r.map(B=>B.id),{data:g}=await Z.from("team_members").select("team_id, user_id, role").in("team_id",f);if(!g||g.length===0)return r.map(B=>({team_id:B.id,team_name:B.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const v=g.map(B=>B.user_id),_=g.filter(B=>B.role==="team_leader").map(B=>B.user_id),{data:j}=await Z.from("profiles").select("id, name, avatar_url").in("id",_),w=new Map((j||[]).map(B=>[B.id,B])),{data:k}=await Z.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",v),{data:M}=await Z.from("deal_pipeline").select("owner_user_id").in("owner_user_id",v),{data:S}=await Z.from("agent_videos").select("owner_user_id").in("owner_user_id",v).eq("is_deleted",!1),E=new Map;(k||[]).forEach(B=>{E.set(B.owner_user_id,(E.get(B.owner_user_id)||0)+1)});const D=new Map;(M||[]).forEach(B=>{D.set(B.owner_user_id,(D.get(B.owner_user_id)||0)+1)});const L=new Map;return(S||[]).forEach(B=>{L.set(B.owner_user_id,(L.get(B.owner_user_id)||0)+1)}),r.map(B=>{const $=g.filter(ee=>ee.team_id===B.id),V=$.find(ee=>ee.role==="team_leader"),W=V?w.get(V.user_id):null,G=$.map(ee=>ee.user_id),J=G.reduce((ee,de)=>ee+(E.get(de)||0),0),ne=G.reduce((ee,de)=>ee+(D.get(de)||0),0),ie=G.reduce((ee,de)=>ee+(L.get(de)||0),0);return{team_id:B.id,team_name:B.name,member_count:$.length,leader_name:(W==null?void 0:W.name)||null,leader_avatar:(W==null?void 0:W.avatar_url)||null,total_contacts:J,total_deals:ne,total_videos:ie}})},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(f=>e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(ys,{className:"h-5 w-32"})}),e.jsx($e,{children:e.jsx(ys,{className:"h-24 w-full"})})]},f))});if(r.length===0)return e.jsx(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(br,{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(Y,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((f,g)=>f+g.member_count,0),d=(a||[]).reduce((f,g)=>f+g.total_contacts,0),h=(a||[]).reduce((f,g)=>f+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(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(br,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(br,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(bk,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:d.toLocaleString()})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Fu,{className:"h-4 w-4"})," Total Deals"]}),e.jsx("p",{className:"text-2xl font-bold",children:h.toLocaleString()})]})})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:(a||[]).map(f=>e.jsxs(Oe,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Ht,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Gt,{className:"text-lg",children:f.team_name}),e.jsxs(ct,{variant:"secondary",children:[f.member_count," members"]})]}),f.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(_a,{src:f.leader_avatar||""}),e.jsx(gn,{className:"text-xs",children:f.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(kh,{className:"h-3 w-3 text-amber-500"}),f.leader_name]})]})]}),e.jsx($e,{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:f.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:f.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:f.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},f.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Y,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},NPt=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Ys(),i=Yr(),{toast:d}=Sa(),[h,f]=T.useState(""),[g,v]=T.useState(!0),_=o||(a.length>0?a[0].id:r);T.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?j():a.length===0&&!r&&v(!1)},[t,s,n,_,i,a,o]);const j=async()=>{if(!_){v(!1);return}try{const{data:w,error:k}=await Z.from("brokerages").select("name").eq("id",_).single();if(k)throw k;f(w.name)}catch(w){console.error("Error loading brokerage info:",w),d({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{v(!1)}};return g?e.jsx(Vs,{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(Vs,{title:h||"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(er,{value:o||"",onValueChange:l,children:[e.jsxs(Qs,{className:"w-[280px]",children:[e.jsx(Ya,{className:"mr-2 h-4 w-4"}),e.jsx(tr,{placeholder:"Select brokerage"})]}),e.jsx(Js,{children:a.map(w=>e.jsx(Et,{value:w.id,children:w.name},w.id))})]})]}),e.jsxs(Qa,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(Fs,{value:"agents",children:"Agents"}),e.jsx(Fs,{value:"teams",children:"Teams"}),e.jsx(Fs,{value:"invite",children:"Invite Links"}),e.jsx(Fs,{value:"referrals",children:"Referrals"}),e.jsx(Fs,{value:"leaderboard",children:"Leaderboard"}),e.jsx(Fs,{value:"activity",children:"Activity"}),e.jsx(Fs,{value:"analytics",children:"Analytics"}),e.jsx(Fs,{value:"shares",children:"Shares"})]}),e.jsx(Zs,{value:"agents",className:"space-y-4",children:e.jsx(pPt,{brokerageId:_})}),e.jsx(Zs,{value:"teams",className:"space-y-4",children:e.jsx(kPt,{brokerageId:_})}),e.jsx(Zs,{value:"invite",className:"space-y-4",children:e.jsx(_Pt,{brokerageId:_})}),e.jsx(Zs,{value:"referrals",className:"space-y-4",children:e.jsx(jPt,{})}),e.jsx(Zs,{value:"leaderboard",className:"space-y-4",children:e.jsx(mVe,{brokerageId:_,title:`${h} Event Leaderboard`,showUserStats:!1})}),e.jsx(Zs,{value:"activity",className:"space-y-4",children:e.jsx(yPt,{brokerageId:_})}),e.jsx(Zs,{value:"analytics",className:"space-y-4",children:e.jsx(vPt,{brokerageId:_})}),e.jsx(Zs,{value:"shares",className:"space-y-4",children:e.jsx(kHe,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Vs,{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(Ya,{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 SPt({brokerageId:t,canManage:s}){const{user:r}=Ys(),[n,a]=T.useState([]),[o,l]=T.useState(!0),[i,d]=T.useState(!1),[h,f]=T.useState(null),[g,v]=T.useState(null),[_,j]=T.useState(!1),[w,k]=T.useState(""),[M,S]=T.useState(""),[E,D]=T.useState(!1),L=async()=>{try{const{data:G,error:J}=await Z.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(J)throw J;const ne=G;if(ne&&ne.length>0){const ie=[...new Set(ne.map(ue=>ue.created_by))],{data:ee}=await Z.from("profiles").select("id, name, avatar_url").in("id",ie),de=new Map((ee==null?void 0:ee.map(ue=>[ue.id,ue]))||[]),oe=ne.map(ue=>({...ue,author:de.get(ue.created_by)||{name:"Unknown",avatar_url:null}}));a(oe)}else a([])}catch(G){console.error("Error fetching announcements:",G)}finally{l(!1)}};T.useEffect(()=>{L()},[t]);const B=()=>{k(""),S(""),D(!1),f(null)},$=G=>{G?(f(G),k(G.title),S(G.content),D(G.is_pinned)):B(),d(!0)},V=async()=>{if(!w.trim()||!M.trim()){be.error("Please fill in all fields");return}j(!0);try{if(h){const{error:G}=await Z.from("brokerage_announcements").update({title:w.trim(),content:M.trim(),is_pinned:E,pinned_at:E?new Date().toISOString():null}).eq("id",h.id);if(G)throw G;be.success("Announcement updated")}else{const{error:G}=await Z.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:w.trim(),content:M.trim(),is_pinned:E,pinned_at:E?new Date().toISOString():null});if(G)throw G;be.success("Announcement created")}d(!1),B(),L()}catch(G){console.error("Error saving announcement:",G),be.error("Failed to save announcement")}finally{j(!1)}},W=async()=>{if(g)try{const{error:G}=await Z.from("brokerage_announcements").delete().eq("id",g);if(G)throw G;be.success("Announcement deleted"),L()}catch(G){console.error("Error deleting announcement:",G),be.error("Failed to delete announcement")}finally{v(null)}};return o?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(fg,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(fg,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(Y,{size:"sm",onClick:()=>$(),className:"gap-1",children:[e.jsx(ar,{className:"h-4 w-4"}),"New"]})]}),e.jsx($e,{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(G=>{var J,ne,ie,ee;return e.jsx("div",{className:`p-4 rounded-lg border ${G.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:[G.is_pinned&&e.jsx(E1,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:G.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:G.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(_a,{src:((J=G.author)==null?void 0:J.avatar_url)||void 0}),e.jsx(gn,{className:"text-[10px]",children:((ie=(ne=G.author)==null?void 0:ne.name)==null?void 0:ie.charAt(0))||"?"})]}),e.jsx("span",{children:(ee=G.author)==null?void 0:ee.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:Bs(new Date(G.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(G),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>v(G.id),children:e.jsx(Ir,{className:"h-4 w-4"})})]})]})},G.id)})})})]}),e.jsx(js,{open:i,onOpenChange:d,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:h?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"title",children:"Title"}),e.jsx(Be,{id:"title",value:w,onChange:G=>k(G.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"content",children:"Content"}),e.jsx(Rr,{id:"content",value:M,onChange:G=>S(G.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(ln,{id:"pinned",checked:E,onCheckedChange:D}),e.jsxs(je,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(E1,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(Y,{onClick:V,disabled:_,children:_?"Saving...":h?"Update":"Create"})]})]})]})}),e.jsx(Ec,{open:!!g,onOpenChange:()=>v(null),children:e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Delete Announcement"}),e.jsx(cc,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:W,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function CPt({brokerageId:t}){const[s,r]=T.useState([]),[n,a]=T.useState(!0),[o,l]=T.useState(""),[i,d]=T.useState(new Set);T.useEffect(()=>{(async()=>{try{const{data:g,error:v}=await Z.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(w=>w.id),{data:j}=await Z.from("agent_assistant_assignments").select("agent_id").in("agent_id",_);j&&d(new Set(j.map(w=>w.agent_id)))}}catch(g){console.error("Error fetching agents:",g)}finally{a(!1)}})()},[t]);const h=s.filter(f=>{var g,v;return f.name.toLowerCase().includes(o.toLowerCase())||f.email.toLowerCase().includes(o.toLowerCase())||((g=f.title)==null?void 0:g.toLowerCase().includes(o.toLowerCase()))||((v=f.areas_served)==null?void 0:v.toLowerCase().includes(o.toLowerCase()))});return n?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx($e,{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(f=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},f))})})]}):e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(br,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search agents...",value:o,onChange:f=>l(f.target.value),className:"pl-9"})]})]}),e.jsx($e,{children:h.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:h.map(f=>e.jsx(MPt,{agent:f,hasAssistant:i.has(f.id)},f.id))})})]})}function MPt({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(_a,{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(ct,{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(Gi,{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(Y,{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(Ha,{className:"h-4 w-4"})})}),e.jsx(Y,{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(zr,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(Y,{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(cm,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(Y,{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(vu,{className:"h-4 w-4"})})})]})]})}function TPt({brokerageId:t}){const[s,r]=T.useState([]),[n,a]=T.useState(!0);if(T.useEffect(()=>{(async()=>{try{const{data:d,error:h}=await Z.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(h)throw h;if(!d||d.length===0){r([]),a(!1);return}const f=d.map(w=>w.id),{data:g,error:v}=await Z.from("agent_attendance_stats").select("user_id, total_points").in("user_id",f).order("total_points",{ascending:!1});if(v)throw v;const _=new Map(d.map(w=>[w.id,w])),j=(g||[]).filter(w=>w.total_points>0).map(w=>{const k=_.get(w.user_id);return{user_id:w.user_id,total_points:w.total_points,name:(k==null?void 0:k.name)||"Unknown",avatar_url:(k==null?void 0:k.avatar_url)||null}});r(j)}catch(d){console.error("Error fetching leaderboard:",d)}finally{a(!1)}})()},[t]),n)return e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx($e,{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(s0,{className:$t("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx($e,{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 h=i.name.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2),f=d+1;return e.jsxs("div",{className:$t("flex items-center gap-3 p-2 rounded-lg",f<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(f)}),e.jsxs(fn,{className:"h-8 w-8",children:[e.jsx(_a,{src:i.avatar_url||void 0}),e.jsx(gn,{className:"text-xs",children:h})]}),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 APt({brokerageId:t}){const s=Yr(),[r,n]=T.useState([]),[a,o]=T.useState(!0);T.useEffect(()=>{(async()=>{try{const{data:d,error:h}=await Z.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(h)throw h;if(!d||d.length===0){n([]),o(!1);return}const f=d.map(w=>w.id),g=new Map(d.map(w=>[w.id,w])),{data:v,error:_}=await Z.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",f).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(_)throw _;const j=(v||[]).map(w=>({id:w.id,slug:w.slug,property_address:w.property_address,city:w.city,price:w.price,property_type:w.property_type,agent_id:w.agent_id,agent:g.get(w.agent_id)||null,photos:w.listing_photos||[]}));n(j)}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(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx($e,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx(ar,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs($e,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Zn,{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(Y,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx(ar,{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(Zn,{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(Y,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(bn,{className:"h-3 w-3 ml-1"})]})]})]})}function EPt(){const{user:t,isAdmin:s,isBrokerageManager:r}=Ys(),n=Yr(),[a,o]=T.useState(!0),[l,i]=T.useState(null),[d,h]=T.useState(""),[f,g]=T.useState(0),[v,_]=T.useState(!1),[j,w]=T.useState(!1);return T.useEffect(()=>{(async()=>{if(t)try{const{data:M}=await Z.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(M!=null&&M.brokerage_id)){o(!1);return}i(M.brokerage_id);const{data:S}=await Z.from("brokerages").select("name").eq("id",M.brokerage_id).maybeSingle();S&&h(S.name);const{count:E}=await Z.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",M.brokerage_id);if(g(E||0),s)_(!0),w(!0);else if(r){const{data:D}=await Z.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",M.brokerage_id).maybeSingle();_(!!D),w(!!D)}}catch(M){console.error("Error fetching brokerage info:",M)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Vs,{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(Vs,{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(br,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[f," ",f===1?"Agent":"Agents"]})]}),j&&e.jsxs(Y,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Zn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]}),e.jsx(SPt,{brokerageId:l,canManage:v}),e.jsx(CPt,{brokerageId:l}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(TPt,{brokerageId:l}),e.jsx(APt,{brokerageId:l})]})]})}):e.jsx(Vs,{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(Ya,{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 IPt(){const t=Yr(),[s,r]=T.useState(""),[n,a]=T.useState("grid"),{data:o,isLoading:l}=zt({queryKey:["newsletters"],queryFn:async()=>{const{data:E,error:D}=await Z.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(D)throw D;return E}}),{data:i}=zt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:E}=await Z.from("newsletter_likes").select("newsletter_id");return E||[]}}),{data:d}=zt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:E}=await Z.from("newsletter_comments").select("newsletter_id");return E||[]}}),{data:h}=zt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[E,D,L,B]=await Promise.all([Z.from("newsletter_canva_links").select("newsletter_id"),Z.from("newsletter_pdfs").select("newsletter_id"),Z.from("newsletter_videos").select("newsletter_id"),Z.from("newsletter_drive_links").select("newsletter_id")]);return{canva:E.data||[],pdfs:D.data||[],videos:L.data||[],drives:B.data||[]}}}),f=E=>(i==null?void 0:i.filter(D=>D.newsletter_id===E).length)||0,g=E=>(d==null?void 0:d.filter(D=>D.newsletter_id===E).length)||0,v=E=>{var D;return((D=h==null?void 0:h.canva)==null?void 0:D.filter(L=>L.newsletter_id===E).length)||0},_=E=>{var D;return((D=h==null?void 0:h.pdfs)==null?void 0:D.filter(L=>L.newsletter_id===E).length)||0},j=E=>{var D;return((D=h==null?void 0:h.videos)==null?void 0:D.filter(L=>L.newsletter_id===E).length)||0},w=E=>{var D;return((D=h==null?void 0:h.drives)==null?void 0:D.filter(L=>L.newsletter_id===E).length)||0},k=E=>v(E)+_(E)+j(E)+w(E),M=o==null?void 0:o.filter(E=>{var D;return E.title.toLowerCase().includes(s.toLowerCase())||((D=E.description)==null?void 0:D.toLowerCase().includes(s.toLowerCase()))}),S=E=>{t(`/newsletters/${E}`)};return e.jsx(Vs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search newsletters...",value:s,onChange:E=>r(E.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Qm,{className:"h-4 w-4"})}),e.jsx(Y,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(dm,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(M==null?void 0:M.length)||0," item",(M==null?void 0:M.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((E,D)=>e.jsx(Oe,{children:e.jsxs($e,{className:"p-0",children:[e.jsx(ys,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-full"})]})]})},D))}),!l&&(M==null?void 0:M.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Yn,{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(Y,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&M&&M.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:M.map(E=>{const D=k(E.id),L=v(E.id),B=_(E.id),$=j(E.id);return n==="grid"?e.jsxs(Oe,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(E.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:E.preview_image_url?e.jsx("img",{src:E.preview_image_url,alt:E.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(Yn,{className:"h-16 w-16"})})}),e.jsxs($e,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:E.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(xn,{className:"h-3 w-3"}),Bs(new Date(E.publish_date),"MMM d, yyyy")]})]}),E.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:E.description.replace(/<[^>]*>/g,"")}),D>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L>0&&e.jsxs(ct,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(hd,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),B>0&&e.jsxs(ct,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Vi,{className:"h-3 w-3"})," ",B," PDF",B>1?"s":""]}),$>0&&e.jsxs(ct,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Kl,{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(Ed,{className:"h-3 w-3"})," ",f(E.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gl,{className:"h-3 w-3"})," ",g(E.id)]})]})]})]},E.id):e.jsx(Oe,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(E.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:E.preview_image_url?e.jsx("img",{src:E.preview_image_url,alt:E.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(Yn,{className:"h-10 w-10"})})}),e.jsxs($e,{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:E.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(xn,{className:"h-3 w-3"}),Bs(new Date(E.publish_date),"MMM d, yyyy")]})]}),E.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:E.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[D>0&&e.jsxs("span",{children:[D," resource",D>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ed,{className:"h-3 w-3"})," ",f(E.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gl,{className:"h-3 w-3"})," ",g(E.id)]})]})]})]})},E.id)})})]})})}function PPt({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(Oe,{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($e,{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 LPt(){const{id:t}=wl(),s=Yr(),{user:r}=Ys(),{toast:n}=Sa(),a=vs(),{trackEngagement:o}=G6(),[l,i]=T.useState(""),{data:d,isLoading:h}=zt({queryKey:["newsletter",t],queryFn:async()=>{const{data:L,error:B}=await Z.from("newsletter_content").select("*").eq("id",t).single();if(B)throw B;return L},enabled:!!t});T.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:f}=zt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:L}=await Z.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:g}=zt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:L}=await Z.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:v}=zt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:L}=await Z.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:_}=zt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:L}=await Z.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:j}=zt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await Z.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:w}=zt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:L}=await Z.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return L||[]},enabled:!!t}),k=j==null?void 0:j.some(L=>L.user_id===(r==null?void 0:r.id)),M=Wt({mutationFn:async()=>{k?await Z.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await Z.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),S=Wt({mutationFn:async L=>{const{error:B}=await Z.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:L});if(B)throw B},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),E=Wt({mutationFn:async L=>{const{error:B}=await Z.from("newsletter_comments").delete().eq("id",L);if(B)throw B},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),D=L=>{if(L.includes("player.mediadelivery.net")||L.includes("iframe.mediadelivery.net")){const B=L.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(B)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${B[1]}/${B[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 B=L.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(B)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${B[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(Kl,{className:"h-4 w-4"})," Watch Video"]})};return h?e.jsx(Vs,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-32"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-32 w-full"})]})}):d?e.jsx(Vs,{title:"",description:"",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(Y,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(bi,{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:Bs(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(PPt,{rows:d.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(G3,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),e.jsxs(Y,{variant:k?"default":"outline",size:"sm",onClick:()=>M.mutate(),children:[e.jsx(Ti,{className:`h-4 w-4 mr-1 ${k?"fill-current":""}`}),(j==null?void 0:j.length)||0," ",(j==null?void 0:j.length)===1?"Like":"Likes"]})]}),_&&_.length>0&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Canva Templates"})}),e.jsx($e,{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(hd,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(bn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),f&&f.length>0&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx($e,{className:"space-y-2",children:f.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(bn,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),g&&g.length>0&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx($e,{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(Yn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(Vi,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),v&&v.length>0&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Videos"})}),e.jsx($e,{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}),D(L.video_url)]},L.id))})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"text-lg",children:["Comments (",(w==null?void 0:w.length)||0,")"]})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Rr,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(Y,{onClick:()=>l.trim()&&S.mutate(l),disabled:!l.trim()||S.isPending,children:e.jsx(Wa,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:w==null?void 0:w.map(L=>{var B,$,V;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{children:(($=(B=L.profiles)==null?void 0:B.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:((V=L.profiles)==null?void 0:V.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:Bs(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>E.mutate(L.id),children:e.jsx(Ir,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:L.content})]})]},L.id)})})]})]})]})}):e.jsx(Vs,{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(Y,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function DPt({rows:t,onChange:s}){const[r,n]=T.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=h=>{s(t.filter((f,g)=>g!==h))},l=(h,f,g,v)=>{const _=[...t];_[h]={..._[h],columns:_[h].columns.map((j,w)=>w===f?{...j,[g]:v}:j)},s(_)},i=async(h,f,g)=>{var j;const v=(j=g.target.files)==null?void 0:j[0];if(!v)return;const _=`${h}-${f}`;n(_);try{const w=`content-blocks/${Date.now()}-${v.name}`,{error:k}=await Z.storage.from("newsletter-content").upload(w,v);if(!k){const{data:M}=Z.storage.from("newsletter-content").getPublicUrl(w);l(h,f,"image_url",M.publicUrl)}}finally{n(null)}},d=(h,f)=>{l(h,f,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx(ar,{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((h,f)=>e.jsxs(Oe,{className:"relative",children:[e.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(f),children:e.jsx(Xr,{className:"h-4 w-4"})}),e.jsxs($e,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(lm,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",f+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:h.columns.map((g,v)=>{const _=`${f}-${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(Y,{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(f,v),children:e.jsx(Xr,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(Be,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${_}`,onChange:j=>i(f,v,j)}),e.jsx(Y,{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(fl,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(Be,{placeholder:"Title",value:g.title,onChange:j=>l(f,v,"title",j.target.value),className:"h-8 text-sm"}),e.jsx(Rr,{placeholder:"Description",value:g.description,onChange:j=>l(f,v,"description",j.target.value),className:"text-sm min-h-[60px] resize-none"})]},v)})})]})]},f))]})}function OPt(){const{toast:t}=Sa(),s=vs(),[r,n]=T.useState(!1),[a,o]=T.useState(null),[l,i]=T.useState({title:"",description:"",publish_date:Bs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,h]=T.useState(null),[f,g]=T.useState(null),[v,_]=T.useState([]),[j,w]=T.useState([]),[k,M]=T.useState([]),[S,E]=T.useState([]),[D,L]=T.useState([]),[B,$]=T.useState([]),[V,W]=T.useState(!1),{data:G,isLoading:J}=zt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Ae,error:Ee}=await Z.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Ee)throw Ee;return Ae}}),ne=Wt({mutationFn:async Ae=>{const{data:Ee,error:He}=await Z.from("newsletter_content").insert({title:Ae.title,description:Ae.description||null,preview_image_url:Ae.preview_image_url,publish_date:Ae.publish_date,is_published:Ae.is_published,content_blocks:Ae.content_blocks}).select().single();if(He)throw He;return Ee},onSuccess:async Ae=>{await de(Ae.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Ae.is_published&&oEt(Ae.title,Ae.id),ce()},onError:Ae=>{t({title:"Error creating newsletter",description:Ae.message,variant:"destructive"})}}),ie=Wt({mutationFn:async Ae=>{const{error:Ee}=await Z.from("newsletter_content").update({title:Ae.title,description:Ae.description||null,preview_image_url:Ae.preview_image_url,publish_date:Ae.publish_date,is_published:Ae.is_published,content_blocks:Ae.content_blocks}).eq("id",Ae.id);if(Ee)throw Ee;return Ae.id},onSuccess:async Ae=>{await de(Ae),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),ce()},onError:Ae=>{t({title:"Error updating newsletter",description:Ae.message,variant:"destructive"})}}),ee=Wt({mutationFn:async Ae=>{const{error:Ee}=await Z.from("newsletter_content").delete().eq("id",Ae);if(Ee)throw Ee},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Ae=>{t({title:"Error deleting newsletter",description:Ae.message,variant:"destructive"})}}),de=async Ae=>{await Z.from("newsletter_drive_links").delete().eq("newsletter_id",Ae),await Z.from("newsletter_pdfs").delete().eq("newsletter_id",Ae),await Z.from("newsletter_videos").delete().eq("newsletter_id",Ae),await Z.from("newsletter_canva_links").delete().eq("newsletter_id",Ae);for(const Ee of B){const He=`${Ae}/${Date.now()}-${Ee.file.name}`,{error:Ue}=await Z.storage.from("newsletter-content").upload(He,Ee.file);if(!Ue){const{data:De}=Z.storage.from("newsletter-content").getPublicUrl(He);j.push({name:Ee.name,file_url:De.publicUrl,file_size:Ee.file.size,sort_order:j.length})}}v.length>0&&await Z.from("newsletter_drive_links").insert(v.map((Ee,He)=>({newsletter_id:Ae,title:Ee.title,drive_url:Ee.drive_url,sort_order:He}))),j.length>0&&await Z.from("newsletter_pdfs").insert(j.map((Ee,He)=>({newsletter_id:Ae,name:Ee.name,file_url:Ee.file_url,file_size:Ee.file_size||null,sort_order:He}))),k.length>0&&await Z.from("newsletter_videos").insert(k.map((Ee,He)=>({newsletter_id:Ae,title:Ee.title,video_url:Ee.video_url,sort_order:He}))),S.length>0&&await Z.from("newsletter_canva_links").insert(S.map((Ee,He)=>({newsletter_id:Ae,title:Ee.title,canva_share_link:Ee.canva_share_link,sort_order:He})))},oe=async Ae=>{o(Ae),i({title:Ae.title,description:Ae.description||"",publish_date:Bs(new Date(Ae.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Ae.is_published}),g(Ae.preview_image_url),L(Ae.content_blocks||[]);const[Ee,He,Ue,De]=await Promise.all([Z.from("newsletter_drive_links").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Z.from("newsletter_pdfs").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Z.from("newsletter_videos").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Z.from("newsletter_canva_links").select("*").eq("newsletter_id",Ae.id).order("sort_order")]);_(Ee.data||[]),w(He.data||[]),M(Ue.data||[]),E(De.data||[]),$([]),n(!0)},ue=async Ae=>{const[Ee,He,Ue,De]=await Promise.all([Z.from("newsletter_drive_links").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Z.from("newsletter_pdfs").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Z.from("newsletter_videos").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Z.from("newsletter_canva_links").select("*").eq("newsletter_id",Ae.id).order("sort_order")]);o(null),i({title:`${Ae.title} (Copy)`,description:Ae.description||"",publish_date:Bs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),g(Ae.preview_image_url),L(Ae.content_blocks||[]),_((Ee.data||[]).map(({id:Ge,...wt})=>wt)),w((He.data||[]).map(({id:Ge,...wt})=>wt)),M((Ue.data||[]).map(({id:Ge,...wt})=>wt)),E((De.data||[]).map(({id:Ge,...wt})=>wt)),$([]),n(!0)},ce=()=>{n(!1),o(null),i({title:"",description:"",publish_date:Bs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),h(null),g(null),_([]),w([]),M([]),E([]),L([]),$([])},ge=async Ae=>{var He;const Ee=(He=Ae.target.files)==null?void 0:He[0];Ee&&(h(Ee),g(URL.createObjectURL(Ee)))},Te=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}W(!0);let Ae=f;if(d){const Ee=`previews/${Date.now()}-${d.name}`,{error:He}=await Z.storage.from("newsletter-content").upload(Ee,d);if(!He){const{data:Ue}=Z.storage.from("newsletter-content").getPublicUrl(Ee);Ae=Ue.publicUrl}}a?ie.mutate({id:a.id,...l,preview_image_url:Ae,content_blocks:D}):ne.mutate({...l,preview_image_url:Ae,content_blocks:D}),W(!1)},ve=()=>_([...v,{title:"",drive_url:"",sort_order:v.length}]),ye=()=>M([...k,{title:"",video_url:"",sort_order:k.length}]),Se=()=>E([...S,{title:"",canva_share_link:"",sort_order:S.length}]),Ke=Ae=>{const Ee=Ae.target.files;if(!Ee)return;const He=Array.from(Ee).map(Ue=>({file:Ue,name:Ue.name.replace(/\.[^/.]+$/,"")}));$([...B,...He])};return e.jsx(Vs,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:(G==null?void 0:G.length)||0})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:(G==null?void 0:G.filter(Ae=>Ae.is_published).length)||0})})]})]}),e.jsxs(js,{open:r,onOpenChange:Ae=>!Ae&&ce(),children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{onClick:()=>n(!0),children:[e.jsx(ar,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(_s,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{children:"Title *"}),e.jsx(Be,{value:l.title,onChange:Ae=>i({...l,title:Ae.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Publish Date"}),e.jsx(Be,{type:"datetime-local",value:l.publish_date,onChange:Ae=>i({...l,publish_date:Ae.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Ig,{content:l.description,onChange:Ae=>i({...l,description:Ae}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:f,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(Y,{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:()=>{h(null),g(null)},children:e.jsx(Xr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Be,{type:"file",accept:"image/*",onChange:ge,className:"hidden",id:"preview-upload"}),e.jsx(Y,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(ji,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{checked:l.is_published,onCheckedChange:Ae=>i({...l,is_published:Ae})}),e.jsx(je,{children:"Published"})]}),e.jsx(DPt,{rows:D,onChange:L}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:Se,children:[e.jsx(ar,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),S.map((Ae,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Be,{placeholder:"Link title",value:Ae.title,onChange:He=>{const Ue=[...S];Ue[Ee].title=He.target.value,E(Ue)},className:"w-1/3"}),e.jsx(Be,{placeholder:"Canva share link",value:Ae.canva_share_link,onChange:He=>{const Ue=[...S];Ue[Ee].canva_share_link=He.target.value,E(Ue)},className:"flex-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>E(S.filter((He,Ue)=>Ue!==Ee)),children:e.jsx(Xr,{className:"h-4 w-4"})})]},Ee))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:ve,children:[e.jsx(ar,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),v.map((Ae,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Be,{placeholder:"Link title",value:Ae.title,onChange:He=>{const Ue=[...v];Ue[Ee].title=He.target.value,_(Ue)},className:"w-1/3"}),e.jsx(Be,{placeholder:"Google Drive URL",value:Ae.drive_url,onChange:He=>{const Ue=[...v];Ue[Ee].drive_url=He.target.value,_(Ue)},className:"flex-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(v.filter((He,Ue)=>Ue!==Ee)),children:e.jsx(Xr,{className:"h-4 w-4"})})]},Ee))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(Be,{type:"file",accept:".pdf",multiple:!0,onChange:Ke,className:"hidden",id:"pdf-upload"}),e.jsx(Y,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(ji,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),j.map((Ae,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Ae.name}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(j.filter((He,Ue)=>Ue!==Ee)),children:e.jsx(Xr,{className:"h-4 w-4"})})]},`existing-${Ee}`)),B.map((Ae,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Be,{value:Ae.name,onChange:He=>{const Ue=[...B];Ue[Ee].name=He.target.value,$(Ue)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>$(B.filter((He,Ue)=>Ue!==Ee)),children:e.jsx(Xr,{className:"h-4 w-4"})})]},`pending-${Ee}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:ye,children:[e.jsx(ar,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),k.map((Ae,Ee)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Be,{placeholder:"Video title",value:Ae.title,onChange:He=>{const Ue=[...k];Ue[Ee].title=He.target.value,M(Ue)},className:"w-1/3"}),e.jsx(Be,{placeholder:"Video URL",value:Ae.video_url,onChange:He=>{const Ue=[...k];Ue[Ee].video_url=He.target.value,M(Ue)},className:"flex-1"}),e.jsx(Y,{type:"button",variant:"ghost",size:"icon",onClick:()=>M(k.filter((He,Ue)=>Ue!==Ee)),children:e.jsx(Xr,{className:"h-4 w-4"})})]},Ee))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(Y,{variant:"outline",onClick:ce,children:"Cancel"}),e.jsx(Y,{onClick:Te,disabled:V||ne.isPending||ie.isPending,children:V?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Publish Date"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:J?e.jsx(ws,{children:e.jsx(ot,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(G==null?void 0:G.length)===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):G==null?void 0:G.map(Ae=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ae.preview_image_url?e.jsx("img",{src:Ae.preview_image_url,alt:Ae.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(Yn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ae.title}),Ae.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ae.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(ot,{children:Bs(new Date(Ae.publish_date),"MMM d, yyyy")}),e.jsx(ot,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ae.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:Ae.is_published?"Published":"Draft"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>oe(Ae),title:"Edit",children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>ue(Ae),title:"Duplicate",children:e.jsx(Di,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&ee.mutate(Ae.id)},children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},Ae.id))})]})})})]})})}const DMe={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 RPt(){const{user:t}=Ys(),{toast:s}=Sa(),r=Yr(),n=vs(),[a,o]=T.useState(""),[l,i]=T.useState("popular"),[d,h]=T.useState(!1),[f,g]=T.useState(""),[v,_]=T.useState(""),[j,w]=T.useState(!1),{data:k=[],isLoading:M}=zt({queryKey:["wishlist-items",l,j],queryFn:async()=>{let B=Z.from("wishlist_items").select("*");j&&t&&(B=B.eq("user_id",t.id)),l==="latest"?B=B.order("created_at",{ascending:!1}):l==="popular"?B=B.order("vote_count",{ascending:!1}):l==="trending"&&(B=B.order("vote_count",{ascending:!1}));const{data:$,error:V}=await B;if(V)throw V;const W=[...new Set(($==null?void 0:$.map(oe=>oe.user_id))||[])],{data:G}=await Z.from("profiles").select("id, name").in("id",W),J=new Map((G==null?void 0:G.map(oe=>[oe.id,oe]))||[]);let ne=[];if(t){const{data:oe}=await Z.from("wishlist_votes").select("item_id").eq("user_id",t.id);ne=(oe==null?void 0:oe.map(ue=>ue.item_id))||[]}const ie=($==null?void 0:$.map(oe=>oe.id))||[],{data:ee}=await Z.from("wishlist_comments").select("item_id").in("item_id",ie),de=new Map;return ee==null||ee.forEach(oe=>{de.set(oe.item_id,(de.get(oe.item_id)||0)+1)}),$==null?void 0:$.map(oe=>{const ue=J.get(oe.user_id),ce=(ue==null?void 0:ue.name)||"Unknown";return{...oe,user_name:ce,user_initials:ce.split(" ").map(ge=>ge[0]).join("").toUpperCase().slice(0,2),has_voted:ne.includes(oe.id),comment_count:de.get(oe.id)||0}})}}),S=Wt({mutationFn:async({title:B,description:$})=>{const{error:V}=await Z.from("wishlist_items").insert({user_id:t.id,title:B,description:$});if(V)throw V},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),h(!1),g(""),_(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:B=>{s({title:"Error",description:B.message,variant:"destructive"})}}),E=Wt({mutationFn:async({itemId:B,hasVoted:$})=>{if($){const{error:V}=await Z.from("wishlist_votes").delete().eq("item_id",B).eq("user_id",t.id);if(V)throw V;return{itemId:B,wasAdded:!1}}else{const{error:V}=await Z.from("wishlist_votes").insert({item_id:B,user_id:t.id});if(V)throw V;return{itemId:B,wasAdded:!0}}},onSuccess:async B=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),B!=null&&B.wasAdded){const $=k.find(W=>W.id===B.itemId),V=(($==null?void 0:$.vote_count)||0)+1;Z.functions.invoke("wishlist-notify",{body:{itemId:B.itemId,voteCount:V}}).catch(console.error)}},onError:B=>{s({title:"Error",description:B.message,variant:"destructive"})}}),D=k.filter(B=>B.title.toLowerCase().includes(a.toLowerCase())||B.description.toLowerCase().includes(a.toLowerCase())),L=()=>{if(!f.trim()||!v.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}S.mutate({title:f.trim(),description:v.trim()})};return e.jsx(Vs,{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(t0,{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(js,{open:d,onOpenChange:h,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{htmlFor:"title",children:"Title"}),e.jsx(Be,{id:"title",placeholder:"Give your idea a clear title...",value:f,onChange:B=>g(B.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:v,onChange:B=>_(B.target.value),rows:4})]}),e.jsx(Y,{onClick:L,className:"w-full",disabled:S.isPending,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Us,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search ideas...",value:a,onChange:B=>o(B.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Qa,{value:l,onValueChange:B=>i(B),children:e.jsxs(Ga,{children:[e.jsx(Fs,{value:"popular",children:"Most Popular"}),e.jsx(Fs,{value:"latest",children:"Latest"}),e.jsx(Fs,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(Y,{variant:j?"default":"outline",size:"sm",onClick:()=>w(!j),children:j?"Show All Ideas":"My Ideas"})}),M?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):D.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(t0,{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(Y,{onClick:()=>h(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:D.map(B=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${B.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:$=>{$.stopPropagation(),E.mutate({itemId:B.id,hasVoted:B.has_voted||!1})},className:$t("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",B.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Wm,{className:$t("h-4 w-4",B.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:B.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:B.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:B.title}),e.jsx(ct,{className:$t("text-xs",DMe[B.status].color),children:DMe[B.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:B.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:B.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(B.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Eo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:B.comment_count})]})]})},B.id))})]})})}const OMe={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 FPt(){const{itemId:t}=wl(),s=Yr(),{user:r}=Ys(),{toast:n}=Sa(),a=vs(),[o,l]=T.useState(""),{data:i=!1}=zt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:k,error:M}=await Z.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!M&&!!k},enabled:!!r}),{data:d,isLoading:h}=zt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:k,error:M}=await Z.from("wishlist_items").select("*").eq("id",t).single();if(M)throw M;const{data:S}=await Z.from("profiles").select("name").eq("id",k.user_id).single();let E=!1;if(r){const{data:D}=await Z.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();E=!!D}return{...k,user_name:(S==null?void 0:S.name)||"Unknown",user_initials:((S==null?void 0:S.name)||"U").split(" ").map(D=>D[0]).join("").toUpperCase().slice(0,2),has_voted:E}}}),{data:f=[],isLoading:g}=zt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:k,error:M}=await Z.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(M)throw M;const S=[...new Set((k==null?void 0:k.map(L=>L.user_id))||[])],{data:E}=await Z.from("profiles").select("id, name").in("id",S),D=new Map((E==null?void 0:E.map(L=>[L.id,L]))||[]);return k==null?void 0:k.map(L=>{const B=D.get(L.user_id),$=(B==null?void 0:B.name)||"Unknown";return{...L,user_name:$,user_initials:$.split(" ").map(V=>V[0]).join("").toUpperCase().slice(0,2)}})}}),v=Wt({mutationFn:async k=>{if(k){const{error:M}=await Z.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(M)throw M;return{wasAdded:!1}}else{const{error:M}=await Z.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(M)throw M;return{wasAdded:!0}}},onSuccess:async k=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),k!=null&&k.wasAdded&&d){const M=(d.vote_count||0)+1;Z.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:M}}).catch(console.error)}},onError:k=>{n({title:"Error",description:k.message,variant:"destructive"})}}),_=Wt({mutationFn:async k=>{const{error:M}=await Z.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:k});if(M)throw M},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:k=>{n({title:"Error",description:k.message,variant:"destructive"})}}),j=Wt({mutationFn:async k=>{const{error:M}=await Z.from("wishlist_comments").delete().eq("id",k);if(M)throw M},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:k=>{n({title:"Error",description:k.message,variant:"destructive"})}}),w=()=>{o.trim()&&_.mutate(o.trim())};return h?e.jsx(Vs,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(ys,{className:"h-8 w-32 mb-6"}),e.jsx(ys,{className:"h-48 w-full mb-6"}),e.jsx(ys,{className:"h-32 w-full"})]})}):d?e.jsx(Vs,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(bi,{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:$t("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(Wm,{className:$t("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(ct,{className:$t("text-xs",OMe[d.status].color),children:OMe[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 (",f.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(Fne,{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(Y,{onClick:w,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(Wa,{className:"h-4 w-4"})})]}),g?e.jsx("div",{className:"space-y-4",children:[1,2].map(k=>e.jsx(ys,{className:"h-20 w-full"},k))}):f.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:f.map(k=>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:k.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:k.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(k.created_at).toLocaleDateString()})]}),e.jsx(L_e,{content:k.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===k.user_id&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>j.mutate(k.id),children:e.jsx(Ir,{className:"h-4 w-4"})})]},k.id))})]})]})}):e.jsx(Vs,{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(Y,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const RMe={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"}},FMe=["open","under_review","planned","in_progress","launched","declined"];function zPt(){const{toast:t}=Sa(),s=Yr(),r=vs(),[n,a]=T.useState(""),[o,l]=T.useState("all"),[i,d]=T.useState(!1),[h,f]=T.useState(null),{data:g=[],isLoading:v}=zt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:M,error:S}=await Z.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(S)throw S;const E=[...new Set((M==null?void 0:M.map(W=>W.user_id))||[])],{data:D}=await Z.from("profiles").select("id, name, email").in("id",E),L=new Map((D==null?void 0:D.map(W=>[W.id,W]))||[]),B=(M==null?void 0:M.map(W=>W.id))||[],{data:$}=await Z.from("wishlist_comments").select("item_id").in("item_id",B),V=new Map;return $==null||$.forEach(W=>{V.set(W.item_id,(V.get(W.item_id)||0)+1)}),M==null?void 0:M.map(W=>{const G=L.get(W.user_id);return{...W,user_name:(G==null?void 0:G.name)||"Unknown",user_email:(G==null?void 0:G.email)||"",comment_count:V.get(W.id)||0}})}}),_=Wt({mutationFn:async({itemId:M,status:S})=>{const{error:E}=await Z.from("wishlist_items").update({status:S}).eq("id",M);if(E)throw E},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:M=>{t({title:"Error",description:M.message,variant:"destructive"})}}),j=Wt({mutationFn:async M=>{const{error:S}=await Z.from("wishlist_items").delete().eq("id",M);if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),f(null),t({title:"Item deleted!"})},onError:M=>{t({title:"Error",description:M.message,variant:"destructive"})}}),w=g.filter(M=>{const S=M.title.toLowerCase().includes(n.toLowerCase())||M.description.toLowerCase().includes(n.toLowerCase())||M.user_name.toLowerCase().includes(n.toLowerCase()),E=o==="all"||M.status===o;return S&&E}),k={total:g.length,open:g.filter(M=>M.status==="open").length,inProgress:g.filter(M=>M.status==="in_progress").length,launched:g.filter(M=>M.status==="launched").length,highVotes:g.filter(M=>M.vote_count>=10).length};return e.jsx(Vs,{title:"Admin - Wishlist",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(bi,{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:k.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:k.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:k.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:k.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:k.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search ideas, users...",value:n,onChange:M=>a(M.target.value),className:"pl-10"})]}),e.jsxs(er,{value:o,onValueChange:M=>l(M),children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{placeholder:"Filter by status"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Statuses"}),FMe.map(M=>e.jsx(Et,{value:M,children:RMe[M].label},M))]})]})]}),v?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(M=>e.jsx(ys,{className:"h-16 w-full"},M))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-[60px]",children:"Votes"}),e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(Ct,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Bn,{children:w.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):w.map(M=>e.jsxs(ws,{className:$t(M.vote_count>=10&&"bg-primary/5"),children:[e.jsx(ot,{children:e.jsx(ct,{variant:M.vote_count>=10?"default":"secondary",children:M.vote_count})}),e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:M.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:M.description})]})}),e.jsx(ot,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:M.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M.user_email})]})}),e.jsx(ot,{className:"hidden sm:table-cell",children:M.comment_count}),e.jsx(ot,{children:e.jsxs(er,{value:M.status,onValueChange:S=>_.mutate({itemId:M.id,status:S}),children:[e.jsx(Qs,{className:"w-[140px] h-8",children:e.jsx(tr,{})}),e.jsx(Js,{children:FMe.map(S=>e.jsx(Et,{value:S,children:RMe[S].label},S))})]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${M.id}`,"_blank"),children:e.jsx(bn,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{f(M.id),d(!0)},children:e.jsx(Ir,{className:"h-4 w-4"})})]})})]},M.id))})]})}),e.jsx(js,{open:i,onOpenChange:d,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{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(Y,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(Y,{variant:"destructive",onClick:()=>h&&j.mutate(h),disabled:j.isPending,children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function BPt(){const{user:t}=Ys(),[s,r]=T.useState([]),[n,a]=T.useState(!0),[o,l]=T.useState(!1),[i,d]=T.useState(null),[h,f]=T.useState(!1),[g,v]=T.useState(null),[_,j]=T.useState(""),[w,k]=T.useState(""),[M,S]=T.useState(""),[E,D]=T.useState(""),[L,B]=T.useState(""),[$,V]=T.useState(!1),[W,G]=T.useState(""),[J,ne]=T.useState("once"),[ie,ee]=T.useState([]),[de,oe]=T.useState([]),[ue,ce]=T.useState(!1),[ge,Te]=T.useState(!1),[ve,ye]=T.useState([]),[Se,Ke]=T.useState({total:0,dismissed:0});T.useEffect(()=>{Ae()},[]);const Ae=async()=>{const{data:tt,error:ut}=await Z.from("levelup_briefs").select("*").order("created_at",{ascending:!1});ut?(be.error("Failed to fetch briefs"),console.error(ut)):r(tt||[]),a(!1)},Ee=()=>{j(""),k(""),S(""),D(""),B(""),V(!1),G(new Date().toISOString().slice(0,16)),ne("once"),ee([]),oe([]),d(null)},He=()=>{Ee(),l(!0)},Ue=async tt=>{d(tt),j(tt.title),k(tt.description||""),S(tt.video_url||""),D(tt.graphic_url||""),B(tt.graphic_link_url||""),V(tt.is_published),G(tt.publish_date.slice(0,16)),ne(tt.show_frequency);const{data:ut}=await Z.from("levelup_brief_links").select("*").eq("brief_id",tt.id).order("sort_order");ee((ut==null?void 0:ut.map(_t=>({title:_t.title,url:_t.url})))||[]);const{data:xt}=await Z.from("levelup_brief_polls").select("*").eq("brief_id",tt.id).order("sort_order");if(xt){const _t=[];for(const qe of xt){const{data:Lt}=await Z.from("levelup_brief_poll_options").select("*").eq("poll_id",qe.id).order("sort_order");_t.push({question:qe.question,poll_type:qe.poll_type,options:(Lt==null?void 0:Lt.map(Rt=>Rt.option_text))||[]})}oe(_t)}l(!0)},De=async tt=>{var xt;const ut=(xt=tt.target.files)==null?void 0:xt[0];if(ut){ce(!0);try{const _t=await Z.functions.invoke("bunny-upload",{body:{action:"create",title:ut.name.replace(/\.[^/.]+$/,"")}});if(_t.error)throw _t.error;const{videoId:qe,libraryId:Lt}=_t.data,Rt=await Z.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:qe}});if(Rt.error)throw Rt.error;const{uploadUrl:Kt,apiKey:Xt}=Rt.data,ss=new XMLHttpRequest;await new Promise((fr,yt)=>{ss.upload.addEventListener("progress",bs=>{if(bs.lengthComputable){const gr=Math.round(bs.loaded/bs.total*100);console.log("Upload progress:",gr)}}),ss.addEventListener("load",()=>{ss.status>=200&&ss.status<300?fr():yt(new Error(`Upload failed with status ${ss.status}`))}),ss.addEventListener("error",()=>yt(new Error("Upload failed"))),ss.open("PUT",Kt),ss.setRequestHeader("AccessKey",Xt),ss.send(ut)});const fs=`https://player.mediadelivery.net/embed/${Lt}/${qe}`;S(fs),be.success("Video uploaded successfully! It may take a few minutes to process.")}catch(_t){console.error("Upload error:",_t),be.error("Failed to upload video")}finally{ce(!1)}}},Ge=async()=>{if(!_.trim()){be.error("Title is required");return}try{let tt;if(i){const{error:ut}=await Z.from("levelup_briefs").update({title:_,description:w||null,video_url:M||null,graphic_url:E||null,graphic_link_url:L||null,is_published:$,publish_date:W,show_frequency:J}).eq("id",i.id);if(ut)throw ut;tt=i.id,await Z.from("levelup_brief_links").delete().eq("brief_id",tt);const{data:xt}=await Z.from("levelup_brief_polls").select("id").eq("brief_id",tt);if(xt)for(const _t of xt)await Z.from("levelup_brief_poll_options").delete().eq("poll_id",_t.id);await Z.from("levelup_brief_polls").delete().eq("brief_id",tt)}else{const{data:ut,error:xt}=await Z.from("levelup_briefs").insert({title:_,description:w||null,video_url:M||null,graphic_url:E||null,graphic_link_url:L||null,is_published:$,publish_date:W,show_frequency:J,created_by:t==null?void 0:t.id}).select().single();if(xt)throw xt;tt=ut.id}if(ie.length>0){const ut=ie.map((xt,_t)=>({brief_id:tt,title:xt.title,url:xt.url,sort_order:_t}));await Z.from("levelup_brief_links").insert(ut)}for(let ut=0;ut0){const Lt=xt.options.map((Rt,Kt)=>({poll_id:_t.id,option_text:Rt,sort_order:Kt}));await Z.from("levelup_brief_poll_options").insert(Lt)}}be.success(i?"Brief updated":"Brief created"),l(!1),Ee(),Ae()}catch(tt){console.error("Error saving brief:",tt),be.error("Failed to save brief")}},wt=async tt=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:ut}=await Z.from("levelup_briefs").delete().eq("id",tt);if(ut)throw ut;be.success("Brief deleted"),Ae()}catch(ut){console.error("Error deleting brief:",ut),be.error("Failed to delete brief")}},Ie=async tt=>{v(tt);const{count:ut}=await Z.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",tt.id),{count:xt}=await Z.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",tt.id).not("dismissed_at","is",null);Ke({total:ut||0,dismissed:xt||0});const{data:_t}=await Z.from("levelup_brief_polls").select("*").eq("brief_id",tt.id).order("sort_order");if(_t){const qe=[];for(const Lt of _t){const{data:Rt}=await Z.from("levelup_brief_poll_options").select("*").eq("poll_id",Lt.id).order("sort_order"),{data:Kt}=await Z.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Lt.id),Xt=[...new Set((Kt==null?void 0:Kt.map(bs=>bs.user_id))||[])];let ss={};if(Xt.length>0){const{data:bs}=await Z.from("profiles").select("id, name, email").in("id",Xt);bs&&bs.forEach(gr=>{ss[gr.id]=gr.name||gr.email||"Unknown"})}const fs=(Kt||[]).map(bs=>({optionId:bs.option_id,userName:ss[bs.user_id]||"Unknown",userId:bs.user_id})),fr={};let yt=0;Rt&&Rt.forEach(bs=>{const gr=(Kt==null?void 0:Kt.filter(Br=>Br.option_id===bs.id).length)||0;fr[bs.id]=gr,yt+=gr}),qe.push({...Lt,options:Rt||[],results:fr,respondents:fs,totalResponses:Lt.poll_type==="single"?new Set(Kt==null?void 0:Kt.map(bs=>bs.user_id)).size:yt})}ye(qe)}f(!0)},st=()=>{ee([...ie,{title:"",url:""}])},he=(tt,ut,xt)=>{const _t=[...ie];_t[tt][ut]=xt,ee(_t)},We=tt=>{ee(ie.filter((ut,xt)=>xt!==tt))},et=()=>{oe([...de,{question:"",poll_type:"single",options:["",""]}])},Ye=(tt,ut)=>{const xt=[...de];xt[tt].question=ut,oe(xt)},ke=(tt,ut)=>{const xt=[...de];xt[tt].poll_type=ut,oe(xt)},at=tt=>{const ut=[...de];ut[tt].options.push(""),oe(ut)},Fe=(tt,ut,xt)=>{const _t=[...de];_t[tt].options[ut]=xt,oe(_t)},it=(tt,ut)=>{const xt=[...de];xt[tt].options=xt[tt].options.filter((_t,qe)=>qe!==ut),oe(xt)},dt=tt=>{oe(de.filter((ut,xt)=>xt!==tt))};return e.jsxs(Vs,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(Y,{onClick:He,children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{children:"Frequency"}),e.jsx(Ct,{children:"Publish Date"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:n?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(tt=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:tt.title}),e.jsx(ot,{children:e.jsx(ct,{variant:tt.is_published?"default":"secondary",children:tt.is_published?"Published":"Draft"})}),e.jsx(ot,{className:"capitalize",children:tt.show_frequency.replace("_"," ")}),e.jsx(ot,{children:Bs(new Date(tt.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>Ie(tt),children:e.jsx(Sc,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>Ue(tt),children:e.jsx(_c,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>wt(tt.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},tt.id))})]})})})]}),e.jsx(js,{open:o,onOpenChange:l,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(Qa,{defaultValue:"content",className:"w-full",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-4",children:[e.jsx(Fs,{value:"content",children:"Content"}),e.jsx(Fs,{value:"media",children:"Media"}),e.jsx(Fs,{value:"links",children:"Links"}),e.jsx(Fs,{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(je,{children:"Title *"}),e.jsx(Be,{value:_,onChange:tt=>j(tt.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Ig,{content:w,onChange:tt=>k(tt),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(je,{children:"Publish Date"}),e.jsx(Be,{type:"datetime-local",value:W,onChange:tt=>G(tt.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Show Frequency"}),e.jsxs(er,{value:J,onValueChange:ne,children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"once",children:"Once (until dismissed)"}),e.jsx(Et,{value:"every_login",children:"Every login"}),e.jsx(Et,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ln,{checked:$,onCheckedChange:V}),e.jsx(je,{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(je,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Be,{type:"file",accept:"video/*",onChange:De,disabled:ue})}),ue&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Or paste embed URL"}),e.jsx(Be,{value:M,onChange:tt=>S(tt.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),M&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:M,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(je,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Be,{type:"file",accept:"image/*",onChange:async tt=>{var xt;const ut=(xt=tt.target.files)==null?void 0:xt[0];if(ut){Te(!0);try{const _t=ut.name.split(".").pop(),qe=`brief-graphics/${Date.now()}.${_t}`,{error:Lt}=await Z.storage.from("banner-images").upload(qe,ut,{upsert:!0});if(Lt)throw Lt;const{data:Rt}=Z.storage.from("banner-images").getPublicUrl(qe);D(Rt.publicUrl),be.success("Image uploaded!")}catch(_t){console.error(_t),be.error("Failed to upload image")}finally{Te(!1)}}},disabled:ge})}),ge&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Or paste Image URL"}),e.jsx(Be,{value:E,onChange:tt=>D(tt.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Click-through Link (optional)"}),e.jsx(Be,{value:L,onChange:tt=>B(tt.target.value),placeholder:"https://example.com/landing-page"})]}),E&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:E,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(je,{children:"Quick Links"}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:st,children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),ie.map((tt,ut)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Be,{value:tt.title,onChange:xt=>he(ut,"title",xt.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Be,{value:tt.url,onChange:xt=>he(ut,"url",xt.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>We(ut),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]},ut)),ie.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(je,{children:"Polls"}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:et,children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),de.map((tt,ut)=>e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(Be,{value:tt.question,onChange:xt=>Ye(ut,xt.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(er,{value:tt.poll_type,onValueChange:xt=>ke(ut,xt),children:[e.jsx(Qs,{className:"w-32",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"single",children:"Single"}),e.jsx(Et,{value:"multi",children:"Multi-select"})]})]}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>dt(ut),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[tt.options.map((xt,_t)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:xt,onChange:qe=>Fe(ut,_t,qe.target.value),placeholder:`Option ${_t+1}`}),tt.options.length>2&&e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>it(ut,_t),children:e.jsx(Ir,{className:"h-4 w-4 text-muted-foreground"})})]},_t)),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>at(ut),children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},ut)),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(Y,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Y,{onClick:Ge,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(js,{open:h,onOpenChange:f,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Ls,{children:e.jsxs(Ps,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx($e,{children:e.jsx("p",{className:"text-2xl font-bold",children:Se.total})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx($e,{children:e.jsx("p",{className:"text-2xl font-bold",children:Se.dismissed})})]})]}),ve.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),ve.map(tt=>e.jsxs(Oe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:tt.question}),e.jsx("div",{className:"space-y-2",children:tt.options.map(ut=>{const xt=tt.results[ut.id]||0,_t=tt.totalResponses>0?Math.round(xt/tt.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:ut.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[xt," (",_t,"%)"]})]}),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:`${_t}%`}})}),xt>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(tt.respondents||[]).filter(qe=>qe.optionId===ut.id).map((qe,Lt)=>e.jsx(ct,{variant:"secondary",className:"text-xs font-normal",children:qe.userName},Lt))})]},ut.id)})})]},tt.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const $Pt=()=>{const{user:t}=Ys(),{toast:s}=Sa(),r=vs(),[n,a]=T.useState(!1),[o,l]=T.useState(null),[i,d]=T.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[h,f]=T.useState(null),[g,v]=T.useState(""),{data:_=[],isLoading:j}=zt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:L,error:B}=await Z.from("additional_services").select("*").order("publish_date",{ascending:!1});if(B)throw B;return L}}),w=Wt({mutationFn:async L=>{let B=L.existingImageUrl;if(L.image){const V=L.image.name.split(".").pop(),W=`${Date.now()}-${Math.random().toString(36).substring(7)}.${V}`,{error:G}=await Z.storage.from("service-images").upload(W,L.image);if(G)throw G;const{data:J}=Z.storage.from("service-images").getPublicUrl(W);B=J.publicUrl}const $={name:L.item.name,description:L.item.description||null,preview_image_url:B,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:V}=await Z.from("additional_services").update($).eq("id",L.itemId);if(V)throw V}else{const{error:V}=await Z.from("additional_services").insert($);if(V)throw V}},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:o?"Service updated":"Service created"}),a(!1),M()},onError:L=>{s({title:"Error saving service",description:L.message,variant:"destructive"})}}),k=Wt({mutationFn:async L=>{const{error:B}=await Z.from("additional_services").delete().eq("id",L);if(B)throw B},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"})}}),M=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),f(null),v(""),l(null)},S=L=>{l(L),d({name:L.name,description:L.description||"",signup_link_url:L.signup_link_url,publish_date:L.publish_date?new Date(L.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:L.is_published}),v(L.preview_image_url||""),a(!0)},E=L=>{var $;const B=($=L.target.files)==null?void 0:$[0];B&&(f(B),v(URL.createObjectURL(B)))},D=L=>{if(L.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}w.mutate({item:i,image:h,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Vs,{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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx($e,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(L=>L.is_published).length})})]})]}),e.jsxs(js,{open:n,onOpenChange:L=>{a(L),L||M()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"name",children:"Name *"}),e.jsx(Be,{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(je,{children:"Description"}),e.jsx(Ig,{content:i.description,onChange:L=>d({...i,description:L}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(Be,{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(je,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Be,{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(ln,{id:"is_published",checked:i.is_published,onCheckedChange:L=>d({...i,is_published:L})}),e.jsx(je,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{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(Y,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{f(null),v("")},children:e.jsx(Xr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(fl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Be,{type:"file",accept:"image/*",onChange:E,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:j?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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-16",children:"Preview"}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Signup Link"}),e.jsx(Ct,{children:"Publish Date"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:_.map(L=>e.jsxs(ws,{children:[e.jsx(ot,{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(fl,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(ot,{className:"font-medium",children:L.name}),e.jsx(ot,{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(bn,{className:"h-3 w-3"}),"Link"]})}),e.jsx(ot,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(ot,{children:e.jsx(ct,{variant:L.is_published?"default":"secondary",children:L.is_published?"Published":"Draft"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>S(L),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&k.mutate(L.id)},children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function UPt(){const{toast:t}=Sa(),[s,r]=T.useState([]),[n,a]=T.useState(!0),[o,l]=T.useState(!1),[i,d]=T.useState(!1),[h,f]=T.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});T.useEffect(()=>{g()},[]);const g=async()=>{try{const{data:k,error:M}=await Z.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(M)throw M;r(k.coupons||[])}catch(k){console.error("Error fetching coupons:",k),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},v=async()=>{if(!h.name){t({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(h.discountType==="percent"&&!h.percentOff){t({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(h.discountType==="amount"&&!h.amountOff){t({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(h.duration==="repeating"&&!h.durationInMonths){t({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const k={action:"create",name:h.name,duration:h.duration,promotion_code:h.promotionCode.trim()||void 0};h.discountType==="percent"?k.percent_off=parseFloat(h.percentOff):(k.amount_off=Math.round(parseFloat(h.amountOff)*100),k.currency="usd"),h.duration==="repeating"&&(k.duration_in_months=parseInt(h.durationInMonths));const{data:M,error:S}=await Z.functions.invoke("stripe-manage-coupons",{body:k});if(S)throw S;t({title:"Success",description:"Coupon created successfully"}),d(!1),f({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),g()}catch(k){console.error("Error creating coupon:",k),t({title:"Error",description:k.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async k=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:M}=await Z.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:k}});if(M)throw M;t({title:"Success",description:"Coupon deleted successfully"}),g()}catch(M){console.error("Error deleting coupon:",M),t({title:"Error",description:M.message||"Failed to delete coupon",variant:"destructive"})}},j=k=>k.percent_off?`${k.percent_off}% off`:k.amount_off?`$${(k.amount_off/100).toFixed(2)} off`:"N/A",w=k=>{switch(k.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${k.duration_in_months} months`;default:return k.duration}};return e.jsx(Vs,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(js,{open:i,onOpenChange:d,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Create New Coupon"}),e.jsx(en,{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(je,{children:"Promotion Code (what users will type)"}),e.jsx(Be,{placeholder:"e.g., BROKERAGE50",value:h.promotionCode,onChange:k=>f({...h,promotionCode:k.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(je,{children:"Coupon Name (internal label)"}),e.jsx(Be,{placeholder:"e.g., 50% Off Brokerage Launch",value:h.name,onChange:k=>f({...h,name:k.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Discount Type"}),e.jsxs(er,{value:h.discountType,onValueChange:k=>{const M=k==="amount"&&h.duration==="forever"?"once":h.duration;f({...h,discountType:k,duration:M})},children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx($4,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(Et,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(Ad,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),h.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(Be,{type:"number",min:"1",max:"100",placeholder:"20",value:h.percentOff,onChange:k=>f({...h,percentOff:k.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(je,{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(Be,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:h.amountOff,onChange:k=>f({...h,amountOff:k.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Duration"}),e.jsxs(er,{value:h.duration,onValueChange:k=>f({...h,duration:k}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"once",children:"Once (first payment only)"}),e.jsx(Et,{value:"repeating",children:"Multiple months"}),e.jsxs(Et,{value:"forever",disabled:h.discountType==="amount",children:["Forever ",h.discountType==="amount"&&"(% discounts only)"]})]})]}),h.discountType==="amount"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'Note: "Forever" duration is only available for percentage-based discounts.'})]}),h.duration==="repeating"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Number of Months"}),e.jsx(Be,{type:"number",min:"1",placeholder:"3",value:h.durationInMonths,onChange:k=>f({...h,durationInMonths:k.target.value})})]}),e.jsx(Y,{onClick:v,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Active Coupons"}),e.jsx(Tr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx($e,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Us,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Promo Code"}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Discount"}),e.jsx(Ct,{children:"Duration"}),e.jsx(Ct,{children:"Redemptions"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:s.map(k=>{var M;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-mono font-medium",children:((M=k.promotion_codes)==null?void 0:M.length)>0?k.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(ot,{children:k.name||"-"}),e.jsx(ot,{children:j(k)}),e.jsx(ot,{children:w(k)}),e.jsx(ot,{children:k.times_redeemed}),e.jsx(ot,{children:e.jsx(ct,{variant:k.valid?"default":"secondary",children:k.valid?"Active":"Inactive"})}),e.jsx(ot,{className:"text-right",children:e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>_(k.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})})]},k.id)})})]})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"How to Use Coupons"})}),e.jsxs($e,{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 qhe={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 qPt(){const[t,s]=T.useState(""),[r,n]=T.useState("all"),[a,o]=T.useState(null),{data:l,isLoading:i,refetch:d}=zt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:j,error:w}=await Z.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(w)throw w;return j}}),{data:h}=zt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:j,error:w}=await Z.from("brokerages").select("*").order("name");if(w)throw w;return await Promise.all((j||[]).map(async M=>{const{data:S}=await Z.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",M.id),{data:E}=await Z.from("user_roles").select("user_id").eq("role","brokerage_manager"),D=(E==null?void 0:E.map($=>$.user_id))||[],L=(S==null?void 0:S.filter($=>D.includes($.id)))||[],B=(S==null?void 0:S.length)||0;return{...M,managers:L,agentCount:B}}))}}),f=j=>{if(j.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(j.brokerage_id&&!j.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(j.is_trial&&j.trial_expires_at)return new Date(j.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(j.subscription_status==="active"||j.subscription_status==="trialing"){const w=qhe[j.subscription_product_id];return{status:(w==null?void 0:w.name)||"Active",badge:j.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return j.subscription_status==="canceled"||j.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},g=l==null?void 0:l.filter(j=>{var k,M;if(!(((k=j.name)==null?void 0:k.toLowerCase().includes(t.toLowerCase()))||((M=j.email)==null?void 0:M.toLowerCase().includes(t.toLowerCase()))))return!1;switch(f(j),r){case"active":return j.subscription_status==="active";case"trialing":return j.subscription_status==="trialing"||j.is_trial&&new Date(j.trial_expires_at)>new Date;case"grandfathered":return j.is_grandfathered;case"brokerage":return j.brokerage_id&&!j.subscription_product_id&&!j.is_grandfathered;case"expired":return j.subscription_status==="canceled"||j.subscription_status==="past_due"||j.is_trial&&new Date(j.trial_expires_at)<=new Date;case"none":return!j.subscription_status||j.subscription_status==="none";default:return!0}}),v={totalUsers:(l==null?void 0:l.length)||0,activeSubscriptions:(l==null?void 0:l.filter(j=>j.subscription_status==="active").length)||0,trials:(l==null?void 0:l.filter(j=>j.subscription_status==="trialing"||j.is_trial&&new Date(j.trial_expires_at)>new Date).length)||0,grandfathered:(l==null?void 0:l.filter(j=>j.is_grandfathered).length)||0,brokerageMembers:(l==null?void 0:l.filter(j=>j.brokerage_id&&!j.subscription_product_id&&!j.is_grandfathered).length)||0,individualSubscribers:(l==null?void 0:l.filter(j=>j.subscription_status==="active"&&j.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(l==null?void 0:l.filter(j=>j.subscription_status==="active"&&(j.subscription_product_id==="prod_Tc08MupgoVySDG"||j.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},_=j=>{window.open(`https://dashboard.stripe.com/customers/${j}`,"_blank")};return e.jsx(Vs,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(Y,{onClick:()=>d(),variant:"outline",size:"sm",children:[e.jsx(el,{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(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(br,{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(Oe,{className:"border-green-500/50",children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zm,{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(Oe,{className:"border-blue-500/50",children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ca,{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(Oe,{className:"border-purple-500/50",children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kh,{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(Oe,{className:"border-orange-500/50",children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ya,{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(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lk,{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(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ya,{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(Qa,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"users",children:"All Users"}),e.jsx(Fs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name or email...",value:t,onChange:j=>s(j.target.value),className:"pl-9"})]}),e.jsxs(er,{value:r,onValueChange:j=>n(j),children:[e.jsx(Qs,{className:"w-[200px]",children:e.jsx(tr,{placeholder:"Filter by status"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Users"}),e.jsx(Et,{value:"active",children:"Active Subscriptions"}),e.jsx(Et,{value:"trialing",children:"Trials"}),e.jsx(Et,{value:"grandfathered",children:"Grandfathered"}),e.jsx(Et,{value:"brokerage",children:"Brokerage Members"}),e.jsx(Et,{value:"expired",children:"Expired/Canceled"}),e.jsx(Et,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"User"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{children:"Plan"}),e.jsx(Ct,{children:"Brokerage"}),e.jsx(Ct,{children:"End Date"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:i?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(g==null?void 0:g.length)===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):g==null?void 0:g.map(j=>{var M,S;const w=f(j),k=qhe[j.subscription_product_id];return e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:j.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:j.email})]})}),e.jsx(ot,{children:e.jsx(ct,{variant:w.variant,children:w.badge})}),e.jsx(ot,{children:e.jsx("span",{className:"text-sm",children:j.is_grandfathered?"Legacy Access":j.brokerage_id&&!j.subscription_product_id?"Brokerage Subscription":(k==null?void 0:k.name)||w.status})}),e.jsx(ot,{children:(M=j.brokerages)!=null&&M.name?e.jsx("span",{className:"text-sm",children:j.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ot,{children:j.subscription_end_date?e.jsx("span",{className:"text-sm",children:Bs(new Date(j.subscription_end_date),"MMM d, yyyy")}):j.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",Bs(new Date(j.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[j.stripe_customer_id&&e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>_(j.stripe_customer_id),children:e.jsx(bn,{className:"h-4 w-4"})}),e.jsxs(js,{children:[e.jsx(Fi,{asChild:!0,children:e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>o(j),children:"Details"})}),e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Subscription Details"}),e.jsxs(en,{children:[j.name," (",j.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(ct,{variant:w.variant,className:"mt-1",children:w.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:j.is_grandfathered?"Grandfathered (Legacy)":j.brokerage_id&&!j.subscription_product_id?"Brokerage Subscription":(k==null?void 0:k.name)||"None"})]}),j.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((S=j.brokerages)==null?void 0:S.name)||"Unknown"})]}),j.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:Bs(new Date(j.subscription_end_date),"MMMM d, yyyy")})]}),j.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:Bs(new Date(j.trial_expires_at),"MMMM d, yyyy")})]}),j.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:j.stripe_customer_id})]})]}),j.stripe_customer_id&&e.jsxs(Y,{className:"w-full",onClick:()=>_(j.stripe_customer_id),children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},j.id)})})]})})})]}),e.jsx(Zs,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:h==null?void 0:h.map(j=>{var k,M;const w=(k=j.managers)==null?void 0:k.some(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Oe,{children:[e.jsx(Ht,{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(Ya,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-lg",children:j.name}),e.jsxs(Tr,{children:[j.agentCount," agents"]})]})]}),e.jsx(ct,{variant:w?"default":"outline",children:w?"Active Subscription":"No Active Subscription"})]})}),e.jsx($e,{children:((M=j.managers)==null?void 0:M.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),j.managers.map(S=>{const E=qhe[S.subscription_product_id];return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.email})]}),e.jsx("div",{className:"text-right",children:E?e.jsxs("div",{children:[e.jsx(ct,{variant:"default",children:E.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:E.price})]}):e.jsx(ct,{variant:"outline",children:"No Subscription"})})]},S.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},j.id)})})})]})]})})}function VPt(){const[t,s]=T.useState([]),[r,n]=T.useState(!0),[a,o]=T.useState(""),[l,i]=T.useState("all"),[d,h]=T.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});T.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:j,error:w}=await Z.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(w)throw w;s(j||[]);const k=(j==null?void 0:j.filter(E=>E.status==="qualified").length)||0,M=(j==null?void 0:j.filter(E=>E.status==="pending").length)||0,S=(j==null?void 0:j.filter(E=>E.status==="cancelled").length)||0;h({total:(j==null?void 0:j.length)||0,qualified:k,pending:M,cancelled:S,totalDiscounts:k*25})}catch(j){console.error("Error fetching referrals:",j),be.error("Failed to load referrals")}finally{n(!1)}},g=async()=>{try{be.loading("Processing qualifications...");const{error:j}=await Z.functions.invoke("process-referral-qualifications");if(j)throw j;be.dismiss(),be.success("Qualifications processed successfully"),f()}catch(j){be.dismiss(),console.error("Error processing qualifications:",j),be.error("Failed to process qualifications")}},v=t.filter(j=>{var M,S,E,D,L,B;const w=((S=(M=j.referrer_brokerage)==null?void 0:M.name)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((D=(E=j.referred_brokerage)==null?void 0:E.name)==null?void 0:D.toLowerCase().includes(a.toLowerCase()))||((B=(L=j.referred_user)==null?void 0:L.email)==null?void 0:B.toLowerCase().includes(a.toLowerCase())),k=l==="all"||j.status===l;return w&&k}),_=j=>{switch(j){case"qualified":return e.jsxs(ct,{className:"bg-green-100 text-green-800",children:[e.jsx(yi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(ct,{variant:"secondary",children:[e.jsx(ca,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(ct,{variant:"destructive",children:[e.jsx(Cc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(ct,{children:j})}};return e.jsx(Vs,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(Y,{onClick:g,variant:"outline",children:[e.jsx(el,{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(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(br,{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(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yi,{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(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ca,{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(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cc,{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(Oe,{children:e.jsx($e,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ad,{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(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"All Referrals"}),e.jsx(Tr,{children:"View and manage all referral relationships"})]}),e.jsxs($e,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by brokerage or email...",value:a,onChange:j=>o(j.target.value),className:"pl-10"})]}),e.jsxs(er,{value:l,onValueChange:i,children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{placeholder:"Filter by status"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Statuses"}),e.jsx(Et,{value:"pending",children:"Pending"}),e.jsx(Et,{value:"qualified",children:"Qualified"}),e.jsx(Et,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Referrer"}),e.jsx(Ct,{children:"Referred"}),e.jsx(Ct,{children:"Signup Date"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{children:"Qualified Date"}),e.jsx(Ct,{children:"Discount"})]})}),e.jsx(Bn,{children:v.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):v.map(j=>{var w,k,M,S;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:((w=j.referrer_brokerage)==null?void 0:w.name)||"Unknown"}),e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("p",{children:((k=j.referred_brokerage)==null?void 0:k.name)||((M=j.referred_user)==null?void 0:M.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(S=j.referred_user)==null?void 0:S.email})]})}),e.jsx(ot,{children:Bs(new Date(j.signup_date),"MMM d, yyyy")}),e.jsx(ot,{children:_(j.status)}),e.jsx(ot,{children:j.qualified_date?Bs(new Date(j.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(ot,{children:j.discount_applied?e.jsx(ct,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},j.id)})})]})]})]})]})})}const Vhe=[{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"}],HPt=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function WPt(){const[t,s]=T.useState([]),[r,n]=T.useState(!0),[a,o]=T.useState(!1),[l,i]=T.useState(null),[d,h]=T.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});T.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:S,error:E}=await Z.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(E)throw E;s(S||[])}catch(S){console.error("Error fetching checklist items:",S),be.error("Failed to load checklist items")}finally{n(!1)}},g=()=>{i(null),h({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},v=S=>{i(S),h({title:S.title,description:S.description||"",action_type:S.action_type,target_role:S.target_role,is_active:S.is_active}),o(!0)},_=async()=>{if(!d.title.trim()){be.error("Title is required");return}try{if(l){const{error:S}=await Z.from("onboarding_checklist_items").update({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active}).eq("id",l.id);if(S)throw S;be.success("Checklist item updated")}else{const S=t.filter(D=>D.target_role===d.target_role).reduce((D,L)=>Math.max(D,L.sort_order),-1),{error:E}=await Z.from("onboarding_checklist_items").insert({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active,sort_order:S+1});if(E)throw E;be.success("Checklist item created")}o(!1),f()}catch(S){console.error("Error saving checklist item:",S),be.error("Failed to save checklist item")}},j=async S=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:E}=await Z.from("onboarding_checklist_items").delete().eq("id",S);if(E)throw E;be.success("Checklist item deleted"),f()}catch(E){console.error("Error deleting checklist item:",E),be.error("Failed to delete checklist item")}},w=async S=>{try{const{error:E}=await Z.from("onboarding_checklist_items").update({is_active:!S.is_active}).eq("id",S.id);if(E)throw E;be.success(S.is_active?"Item deactivated":"Item activated"),f()}catch(E){console.error("Error toggling item:",E),be.error("Failed to update item")}},k=t.filter(S=>S.target_role==="brokerage_manager"),M=t.filter(S=>S.target_role==="agent");return e.jsxs(Vs,{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(Y,{onClick:g,className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(ct,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx($e,{children:k.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-12",children:"#"}),e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Action Type"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:k.map((S,E)=>{var D;return e.jsxs(ws,{children:[e.jsx(ot,{className:"text-muted-foreground",children:E+1}),e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(ot,{children:e.jsx(ct,{variant:"outline",children:((D=Vhe.find(L=>L.value===S.action_type))==null?void 0:D.label)||S.action_type})}),e.jsx(ot,{children:e.jsx(ln,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>v(S),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>j(S.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(ct,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx($e,{children:M.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-12",children:"#"}),e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Action Type"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:M.map((S,E)=>{var D;return e.jsxs(ws,{children:[e.jsx(ot,{className:"text-muted-foreground",children:E+1}),e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(ot,{children:e.jsx(ct,{variant:"outline",children:((D=Vhe.find(L=>L.value===S.action_type))==null?void 0:D.label)||S.action_type})}),e.jsx(ot,{children:e.jsx(ln,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>v(S),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>j(S.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]})]}),e.jsx(js,{open:a,onOpenChange:o,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{htmlFor:"title",children:"Title *"}),e.jsx(Be,{id:"title",value:d.title,onChange:S=>h({...d,title:S.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",value:d.description,onChange:S=>h({...d,description:S.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Target Role"}),e.jsxs(er,{value:d.target_role,onValueChange:S=>h({...d,target_role:S}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:HPt.map(S=>e.jsx(Et,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Action Type"}),e.jsxs(er,{value:d.action_type,onValueChange:S=>h({...d,action_type:S}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:Vhe.map(S=>e.jsx(Et,{value:S.value,children:S.label},S.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{id:"is_active",checked:d.is_active,onCheckedChange:S=>h({...d,is_active:S})}),e.jsx(je,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(Y,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function GPt(){const[t,s]=T.useState(""),[r,n]=T.useState("all"),[a,o]=T.useState("name"),[l,i]=T.useState("asc"),[d,h]=T.useState(""),[f,g]=T.useState(""),[v,_]=T.useState(""),[j,w]=T.useState(""),{data:k}=zt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:G,error:J}=await Z.from("brokerages").select("id, name").order("name");if(J)throw J;return G}}),M=async G=>{let ne=[],ie=0,ee=!0;for(;ee;){const{data:de,error:oe}=await G(ie,ie+1e3-1);if(oe)throw oe;de&&de.length>0?(ne=[...ne,...de],ie+=1e3,ee=de.length===1e3):ee=!1}return ne},{data:S,isLoading:E}=zt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const G=await M((Ue,De)=>Z.from("profiles").select("id, name, email, brokerage_id, created_at").range(Ue,De)),{data:J}=await Z.from("brokerages").select("id, name"),ne=new Map((J==null?void 0:J.map(Ue=>[Ue.id,Ue.name]))||[]),[{data:ie},{data:ee},{data:de},{data:oe},{data:ue},{data:ce},{data:ge}]=await Promise.all([Z.rpc("get_admin_contact_counts"),Z.rpc("get_admin_video_counts"),Z.rpc("get_admin_popby_counts"),Z.rpc("get_admin_listing_counts"),Z.rpc("get_admin_deal_counts"),Z.rpc("get_admin_portal_counts"),Z.rpc("get_admin_sendable_card_counts")]),Te=new Map;ie==null||ie.forEach(Ue=>Te.set(Ue.owner_user_id,Ue.contact_count));const ve=new Map;ee==null||ee.forEach(Ue=>ve.set(Ue.owner_user_id,Ue.video_count));const ye=new Map;de==null||de.forEach(Ue=>ye.set(Ue.owner_user_id,Ue.popby_count));const Se=new Map;oe==null||oe.forEach(Ue=>Se.set(Ue.agent_id,Ue.listing_count));const Ke=new Map;ue==null||ue.forEach(Ue=>Ke.set(Ue.owner_user_id,Ue.deal_count));const Ae=new Map;ce==null||ce.forEach(Ue=>Ae.set(Ue.owner_user_id,{total:Ue.portal_count,active:Ue.active_portal_count}));const Ee=new Map;return ge==null||ge.forEach(Ue=>Ee.set(Ue.owner_user_id,{total:Ue.card_count,sent:Ue.sent_card_count,views:Ue.total_card_views})),G.map(Ue=>{const De=Ae.get(Ue.id),Ge=Ee.get(Ue.id);return{id:Ue.id,name:Ue.name||"Unknown",email:Ue.email||"",brokerage_id:Ue.brokerage_id,brokerage_name:Ue.brokerage_id&&ne.get(Ue.brokerage_id)||null,contact_count:Te.get(Ue.id)||0,video_count:ve.get(Ue.id)||0,popby_count:ye.get(Ue.id)||0,listing_count:Se.get(Ue.id)||0,deal_count:Ke.get(Ue.id)||0,portal_count:(De==null?void 0:De.total)||0,active_portal_count:(De==null?void 0:De.active)||0,card_count:(Ge==null?void 0:Ge.total)||0,sent_card_count:(Ge==null?void 0:Ge.sent)||0,total_card_views:(Ge==null?void 0:Ge.views)||0,created_at:Ue.created_at}})}}),D=T.useMemo(()=>{if(!S)return[];let G=S.filter(J=>{const ne=t.toLowerCase(),ie=!t||J.name.toLowerCase().includes(ne)||J.email.toLowerCase().includes(ne),ee=r==="all"||r==="none"&&!J.brokerage_id||J.brokerage_id===r,de=parseInt(d)||0,oe=parseInt(f)||0,ue=parseInt(v)||0,ce=parseInt(j)||0,ge=J.contact_count>=de&&J.video_count>=oe&&J.popby_count>=ue&&J.listing_count>=ce;return ie&&ee&&ge});return G.sort((J,ne)=>{let ie=0;return a==="name"?ie=J.name.localeCompare(ne.name):ie=J[a]-ne[a],l==="asc"?ie:-ie}),G},[S,t,r,a,l,d,f,v,j]),L=G=>{a===G?i(l==="asc"?"desc":"asc"):(o(G),i("desc"))},B=()=>{const G=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],J=D.map(oe=>[oe.name,oe.email,oe.brokerage_name||"None",oe.contact_count,oe.video_count,oe.popby_count,oe.listing_count,oe.deal_count,`${oe.portal_count} (${oe.active_portal_count})`,oe.card_count,oe.sent_card_count,oe.total_card_views]),ne=[G.join(","),...J.map(oe=>oe.map(ue=>`"${ue}"`).join(","))].join(` `),ie=new Blob([ne],{type:"text/csv"}),ee=URL.createObjectURL(ie),de=document.createElement("a");de.href=ee,de.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,de.click(),URL.revokeObjectURL(ee)},$=T.useMemo(()=>D.length?D.reduce((G,J)=>({contacts:G.contacts+J.contact_count,videos:G.videos+J.video_count,popbys:G.popbys+J.popby_count,listings:G.listings+J.listing_count,deals:G.deals+J.deal_count,portals:G.portals+J.portal_count,activePortals:G.activePortals+J.active_portal_count,cards:G.cards+J.card_count,sentCards:G.sentCards+J.sent_card_count,cardViews:G.cardViews+J.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},[D]),V=T.useMemo(()=>D.length?{portals:D.filter(G=>G.portal_count>0).length,cards:D.filter(G=>G.card_count>0).length}:{portals:0,cards:0},[D]),W=({field:G,children:J})=>e.jsx(Ct,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(G),children:e.jsxs("div",{className:"flex items-center gap-1",children:[J,e.jsx(Hp,{className:`h-3 w-3 ${a===G?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(bN,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Oe,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Xy,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx($e,{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:V.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(Oe,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(zr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx($e,{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:V.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(Oe,{children:[e.jsx(Ht,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(Tr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:B,children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs($e,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name or email...",value:t,onChange:G=>s(G.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(er,{value:r,onValueChange:n,children:[e.jsxs(Qs,{children:[e.jsx(Ya,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(tr,{placeholder:"Brokerage"})]}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Brokerages"}),e.jsx(Et,{value:"none",children:"No Brokerage"}),k==null?void 0:k.map(G=>e.jsx(Et,{value:G.id,children:G.name},G.id))]})]})}),e.jsx("div",{children:e.jsx(Be,{type:"number",placeholder:"Min contacts",value:d,onChange:G=>h(G.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Be,{type:"number",placeholder:"Min videos",value:f,onChange:G=>g(G.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Be,{type:"number",placeholder:"Min popbys",value:v,onChange:G=>_(G.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:D.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"})]})]}),E?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(W,{field:"name",children:"Name"}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:"Brokerage"}),e.jsx(W,{field:"contact_count",children:"Contacts"}),e.jsx(W,{field:"video_count",children:"Videos"}),e.jsx(W,{field:"popby_count",children:"Popbys"}),e.jsx(W,{field:"listing_count",children:"Listings"}),e.jsx(W,{field:"deal_count",children:"Deals"}),e.jsx(W,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Xy,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(W,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Bn,{children:D.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):D.map(G=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:G.name}),e.jsx(ot,{className:"text-muted-foreground",children:G.email}),e.jsx(ot,{children:G.brokerage_name?e.jsx(ct,{variant:"secondary",children:G.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ot,{children:e.jsx(ct,{variant:G.contact_count>0?"default":"outline",children:G.contact_count})}),e.jsx(ot,{children:e.jsx(ct,{variant:G.video_count>0?"default":"outline",children:G.video_count})}),e.jsx(ot,{children:e.jsx(ct,{variant:G.popby_count>0?"default":"outline",children:G.popby_count})}),e.jsx(ot,{children:e.jsx(ct,{variant:G.listing_count>0?"default":"outline",children:G.listing_count})}),e.jsx(ot,{children:e.jsx(ct,{variant:G.deal_count>0?"default":"outline",children:G.deal_count})}),e.jsx(ot,{children:G.portal_count>0?e.jsxs(em,{children:[e.jsx(tm,{children:e.jsxs(ct,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[G.portal_count,G.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",G.active_portal_count," active)"]})]})}),e.jsxs(fh,{children:[e.jsxs("p",{children:[G.portal_count," total portals"]}),e.jsxs("p",{children:[G.active_portal_count," currently active"]})]})]}):e.jsx(ct,{variant:"outline",children:"0"})}),e.jsx(ot,{children:G.card_count>0?e.jsxs(em,{children:[e.jsx(tm,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ct,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:G.card_count}),G.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(Wa,{className:"h-3 w-3"}),G.sent_card_count]}),G.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(wi,{className:"h-3 w-3"}),G.total_card_views]})]})}),e.jsxs(fh,{children:[e.jsxs("p",{children:[G.card_count," cards created"]}),e.jsxs("p",{children:[G.sent_card_count," sent"]}),e.jsxs("p",{children:[G.total_card_views," total views"]})]})]}):e.jsx(ct,{variant:"outline",children:"0"})})]},G.id))})]})})]})]})]})})}function KPt(){Sa(),vs();const[t,s]=T.useState("user-analytics"),{data:r}=zt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:_,error:j}=await Z.from("feature_flags").select("*").order("key");if(j)throw j;return _}}),{data:n,isLoading:a}=zt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:_,error:j}=await Z.from("relationship_types").select("*").order("sort_order");if(j)throw j;return _}}),{data:o,isLoading:l}=zt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:_,error:j}=await Z.from("action_types").select("*").order("sort_order");if(j)throw j;return _}}),{data:i,isLoading:d}=zt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:_,error:j}=await Z.from("action_scripts").select("*, action_type:action_types(*)");if(j)throw j;return _}}),{data:h,isLoading:f}=zt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:j}=await Z.from("touchpoint_plans").select("*").order("name");if(j)throw j;return _}}),{data:g,isLoading:v}=zt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:_,error:j}=await Z.from("popby_items").select("*").is("owner_user_id",null).order("name");if(j)throw j;return _}});return e.jsx(Vs,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(Qa,{value:t,onValueChange:s,children:[e.jsxs(Ga,{className:"grid w-full grid-cols-9",children:[e.jsxs(Fs,{value:"user-analytics",className:"gap-2",children:[e.jsx(Sc,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(Fs,{value:"relationship-types",className:"gap-2",children:[e.jsx(br,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(Fs,{value:"action-types",className:"gap-2",children:[e.jsx(Ha,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(Fs,{value:"scripts",className:"gap-2",children:[e.jsx(Yn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(Fs,{value:"video-scripts",className:"gap-2",children:[e.jsx(Wd,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(Fs,{value:"plans",className:"gap-2",children:[e.jsx(xn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(Fs,{value:"popbys",className:"gap-2",children:[e.jsx(oo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(Fs,{value:"settings",className:"gap-2",children:[e.jsx(Ic,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(Fs,{value:"feature-flags",className:"gap-2",children:[e.jsx(e0,{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(GPt,{})}),e.jsx(Zs,{value:"relationship-types",className:"mt-6",children:e.jsx(ZPt,{types:n||[],isLoading:a})}),e.jsx(Zs,{value:"action-types",className:"mt-6",children:e.jsx(YPt,{types:o||[],isLoading:l})}),e.jsx(Zs,{value:"scripts",className:"mt-6",children:e.jsx(XPt,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(Zs,{value:"video-scripts",className:"mt-6",children:e.jsx(t6t,{})}),e.jsx(Zs,{value:"plans",className:"mt-6",children:e.jsx(QPt,{plans:h||[],actionTypes:o||[],scripts:i||[],isLoading:f})}),e.jsx(Zs,{value:"popbys",className:"mt-6",children:e.jsx(e6t,{items:g||[],isLoading:v})}),e.jsx(Zs,{value:"settings",className:"mt-6",children:e.jsx(s6t,{})}),e.jsx(Zs,{value:"feature-flags",className:"mt-6",children:e.jsx(JPt,{flags:r||[]})})]})]})})}function ZPt({types:t,isLoading:s}){const{toast:r}=Sa(),n=vs(),[a,o]=T.useState(null),[l,i]=T.useState(!1),d=Wt({mutationFn:async f=>{if(f.id){const{error:g}=await Z.from("relationship_types").update({name:f.name,description:f.description,icon:f.icon}).eq("id",f.id);if(g)throw g}else{const{error:g}=await Z.from("relationship_types").insert([{name:f.name,description:f.description,icon:f.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:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),h=async f=>{await Z.from("relationship_types").update({active:!f.active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Relationship Types"}),e.jsx(Tr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(Y,{onClick:()=>{o(null),i(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx($e,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-12"}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(f=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsx(lm,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(ot,{className:"font-medium",children:f.name}),e.jsx(ot,{className:"text-muted-foreground",children:f.description}),e.jsx(ot,{children:e.jsx(ln,{checked:f.active,onCheckedChange:()=>h(f)})}),e.jsx(ot,{children:e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Xa,{className:"h-4 w-4"})})})]},f.id))})]})}),e.jsx(js,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.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(je,{htmlFor:"name",children:"Name"}),e.jsx(Be,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"icon",children:"Icon"}),e.jsx(Be,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(Hn,{className:"mt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function YPt({types:t,isLoading:s}){const{toast:r}=Sa(),n=vs(),[a,o]=T.useState(null),[l,i]=T.useState(!1),d=Wt({mutationFn:async f=>{if(f.id){const{error:g}=await Z.from("action_types").update({name:f.name,description:f.description,icon:f.icon,color:f.color}).eq("id",f.id);if(g)throw g}else{const{error:g}=await Z.from("action_types").insert([{name:f.name,description:f.description,icon:f.icon,color:f.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:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),h=async f=>{await Z.from("action_types").update({active:!f.active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Action Types"}),e.jsx(Tr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(Y,{onClick:()=>{o(null),i(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx($e,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{children:"Color"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(f=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:f.name}),e.jsx(ot,{className:"text-muted-foreground",children:f.description}),e.jsx(ot,{children:f.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:f.color}})}),e.jsx(ot,{children:e.jsx(ln,{checked:f.active,onCheckedChange:()=>h(f)})}),e.jsx(ot,{children:e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(Xa,{className:"h-4 w-4"})})})]},f.id))})]})}),e.jsx(js,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.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(je,{htmlFor:"name",children:"Name"}),e.jsx(Be,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"icon",children:"Icon"}),e.jsx(Be,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"color",children:"Color"}),e.jsx(Be,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(Hn,{className:"mt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function XPt({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Sa(),a=vs(),[o,l]=T.useState(null),[i,d]=T.useState(!1),h=Wt({mutationFn:async g=>{if(g.id){const{error:v}=await Z.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 Z.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"})}}),f=Wt({mutationFn:async g=>{const{error:v}=await Z.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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Script Library"}),e.jsx(Tr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(Y,{onClick:()=>{l(null),d(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx($e,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Action Type"}),e.jsx(Ct,{children:"Tone"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(g=>{var v;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:g.title}),e.jsx(ot,{children:e.jsx(ct,{variant:"outline",children:((v=g.action_type)==null?void 0:v.name)||"Unknown"})}),e.jsx(ot,{className:"text-muted-foreground",children:g.tone}),e.jsx(ot,{children:e.jsx(ct,{variant:g.active?"default":"secondary",children:g.active?"Active":"Inactive"})}),e.jsxs(ot,{className:"flex gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{l(g),d(!0)},children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>f.mutate(g.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})]},g.id)})})]})}),e.jsx(js,{open:i,onOpenChange:d,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:g=>{g.preventDefault();const v=new FormData(g.currentTarget);h.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(je,{htmlFor:"title",children:"Title"}),e.jsx(Be,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(er,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select action type"})}),e.jsx(Js,{children:s.map(g=>e.jsx(Et,{value:g.id,children:g.name},g.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(Be,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Rr,{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(Hn,{className:"mt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:h.isPending,children:[h.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function QPt({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Sa(),o=vs(),[l,i]=T.useState(null),[d,h]=T.useState(!1),[f,g]=T.useState(null),[v,_]=T.useState(!1),[j,w]=T.useState(null),[k,M]=T.useState(null),{data:S}=zt({queryKey:["plan-items",f],queryFn:async()=>{if(!f)return[];const{data:W,error:G}=await Z.from("touchpoint_plan_items").select("*").eq("plan_id",f).order("month_number");if(G)throw G;return W},enabled:!!f}),E=Wt({mutationFn:async W=>{if(W.id){const{error:G}=await Z.from("touchpoint_plans").update({name:W.name,description:W.description,active:W.active}).eq("id",W.id);if(G)throw G}else{const{error:G}=await Z.from("touchpoint_plans").insert([{name:W.name,description:W.description,active:!0}]);if(G)throw G}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),h(!1),i(null),a({title:"Saved successfully"})},onError:W=>{a({title:"Error",description:W.message,variant:"destructive"})}}),D=Wt({mutationFn:async W=>{if(W.id){const{error:G}=await Z.from("touchpoint_plan_items").update({action_type_id:W.action_type_id,default_script_id:W.default_script_id,notes:W.notes}).eq("id",W.id);if(G)throw G}else{const{error:G}=await Z.from("touchpoint_plan_items").insert([{plan_id:W.plan_id,month_number:W.month_number,action_type_id:W.action_type_id,default_script_id:W.default_script_id,notes:W.notes}]);if(G)throw G}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",f]}),a({title:"Item saved"})}}),L=Wt({mutationFn:async W=>{const{error:G}=await Z.from("touchpoint_plan_items").delete().eq("id",W);if(G)throw G},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",f]})}}),B=Wt({mutationFn:async W=>{const{data:G,error:J}=await Z.from("action_scripts").insert([{...W,active:!0}]).select().single();if(J)throw J;return G},onSuccess:async W=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),j&&await D.mutateAsync({id:j.itemId,plan_id:f,month_number:j.month,action_type_id:j.actionTypeId,default_script_id:W.id}),_(!1),w(null),a({title:"Script created and assigned"})},onError:W=>{a({title:"Error",description:W.message,variant:"destructive"})}}),$=(W,G,J)=>{w({month:W,actionTypeId:G,itemId:J}),_(!0)},V=W=>r.find(G=>G.id===W);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Touchpoint Plans"}),e.jsx(Tr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(Y,{onClick:()=>{i(null),h(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx($e,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Us,{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(W=>e.jsxs(Oe,{className:`cursor-pointer transition-colors ${f===W.id?"border-primary":""}`,onClick:()=>g(W.id),children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Gt,{className:"text-base",children:W.name}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:G=>{G.stopPropagation(),i(W),h(!0)},children:e.jsx(Xa,{className:"h-4 w-4"})})]})}),e.jsxs($e,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:W.description}),e.jsx(ct,{variant:W.active?"default":"secondary",className:"mt-2",children:W.active?"Active":"Inactive"})]})]},W.id))})})]}),f&&e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Plan Schedule"}),e.jsx(Tr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx($e,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(W,G)=>G+1).map(W=>{const G=S==null?void 0:S.find(ie=>ie.month_number===W),J=G!=null&&G.default_script_id?V(G.default_script_id):null,ne=r.filter(ie=>ie.action_type_id===(G==null?void 0:G.action_type_id)&&ie.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 ",W]}),e.jsxs(er,{value:(G==null?void 0:G.action_type_id)||"none",onValueChange:ie=>{ie==="none"&&G?L.mutate(G.id):ie!=="none"&&D.mutate({id:G==null?void 0:G.id,plan_id:f,month_number:W,action_type_id:ie,default_script_id:null})},children:[e.jsx(Qs,{className:"w-40",children:e.jsx(tr,{placeholder:"No action"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No action"}),s.filter(ie=>ie.active).map(ie=>e.jsx(Et,{value:ie.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[ie.color&&e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ie.color}}),ie.name]})},ie.id))]})]}),G&&e.jsxs(e.Fragment,{children:[e.jsxs(er,{value:G.default_script_id||"none",onValueChange:ie=>{M(null),D.mutate({id:G.id,default_script_id:ie==="none"?null:ie})},children:[e.jsx(Qs,{className:"w-56",children:e.jsx(tr,{placeholder:"Select script"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No default script"}),ne.map(ie=>e.jsxs(Et,{value:ie.id,children:[ie.title," ",ie.tone&&`(${ie.tone})`]},ie.id))]})]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>$(W,G.action_type_id,G.id),children:[e.jsx(ar,{className:"h-3 w-3 mr-1"}),"New Script"]}),J&&e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>M((k==null?void 0:k.id)===J.id?null:J),children:(k==null?void 0:k.id)===J.id?"Hide":"Preview"})]})]}),k&&(G==null?void 0:G.default_script_id)===k.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(ct,{variant:"outline",children:k.title}),k.tone&&e.jsx(ct,{variant:"secondary",children:k.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:k.script_body})]})]},W)})})})]}),e.jsx(js,{open:d,onOpenChange:h,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:W=>{W.preventDefault();const G=new FormData(W.currentTarget);E.mutate({id:l==null?void 0:l.id,name:G.get("name"),description:G.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"name",children:"Name"}),e.jsx(Be,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(Hn,{className:"mt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:E.isPending,children:[E.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(js,{open:v,onOpenChange:_,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Create New Script"}),e.jsxs(en,{children:["Create a script for Month ",j==null?void 0:j.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:W=>{W.preventDefault();const G=new FormData(W.currentTarget);B.mutate({title:G.get("title"),action_type_id:j.actionTypeId,tone:G.get("tone"),script_body:G.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(je,{htmlFor:"script_title",children:"Title"}),e.jsx(Be,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"script_tone",children:"Tone"}),e.jsx(Be,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Rr,{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(Hn,{className:"mt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:B.isPending,children:[B.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function JPt({flags:t}){const{toast:s}=Sa(),r=vs(),n=async(a,o)=>{const{error:l}=await Z.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(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Feature Flags"}),e.jsx(Tr,{children:"Control which features are enabled for members"})]}),e.jsx($e,{children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Flag"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{children:"Notes"}),e.jsx(Ct,{children:"Last Updated"})]})}),e.jsx(Bn,{children:t.map(a=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-mono text-sm",children:a.key}),e.jsx(ot,{children:e.jsx(ln,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(ot,{children:e.jsx(Be,{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(ot,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function e6t({items:t,isLoading:s}){const{toast:r}=Sa(),n=vs(),[a,o]=T.useState(null),[l,i]=T.useState(!1),d=Wt({mutationFn:async g=>{if(g.id){const{error:v}=await Z.from("popby_items").update({name:g.name,description:g.description}).eq("id",g.id);if(v)throw v}else{const{error:v}=await Z.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"})}}),h=async g=>{await Z.from("popby_items").update({is_active:!g.is_active}).eq("id",g.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},f=async g=>{await Z.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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Popby Ideas"}),e.jsx(Tr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(Y,{onClick:()=>{o(null),i(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx($e,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Us,{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(oo,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(g=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:g.name}),e.jsx(ot,{className:"text-muted-foreground",children:g.description}),e.jsx(ot,{children:e.jsx(ln,{checked:g.is_active,onCheckedChange:()=>h(g)})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{o(g),i(!0)},children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>f(g.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},g.id))})]})}),e.jsx(js,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsxs(Ps,{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(je,{htmlFor:"name",children:"Name"}),e.jsx(Be,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(Hn,{className:"mt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function t6t(){var _;const{toast:t}=Sa(),s=vs(),[r,n]=T.useState(null),[a,o]=T.useState(!1),{data:l,isLoading:i}=zt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:j,error:w}=await Z.from("video_script_categories").select("*").order("sort_order");if(w)throw w;return j}}),{data:d,isLoading:h}=zt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:j,error:w}=await Z.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(w)throw w;return j}}),f=Wt({mutationFn:async j=>{var w,k;if(j.id){const{error:M}=await Z.from("video_scripts").update({title:j.title,script_text:j.script_text,category_id:j.category_id,tags:((w=j.tags)==null?void 0:w.split(",").map(S=>S.trim()).filter(Boolean))||[]}).eq("id",j.id);if(M)throw M}else{const{error:M}=await Z.from("video_scripts").insert([{title:j.title,script_text:j.script_text,category_id:j.category_id||null,tags:((k=j.tags)==null?void 0:k.split(",").map(S=>S.trim()).filter(Boolean))||[]}]);if(M)throw M}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:j=>t({title:"Error",description:j.message,variant:"destructive"})}),g=async j=>{await Z.from("video_scripts").update({is_active:!j.is_active}).eq("id",j.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},v=async j=>{confirm("Delete this video script?")&&(await Z.from("video_scripts").delete().eq("id",j),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Video Scripts"}),e.jsx(Tr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(Y,{onClick:()=>{n(null),o(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx($e,{children:h?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Title"}),e.jsx(Ct,{children:"Category"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:d==null?void 0:d.map(j=>{var w;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:j.title}),e.jsx(ot,{className:"text-muted-foreground",children:((w=j.category)==null?void 0:w.name)||"Uncategorized"}),e.jsx(ot,{children:e.jsx(ln,{checked:j.is_active,onCheckedChange:()=>g(j)})}),e.jsxs(ot,{className:"flex gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>{n(j),o(!0)},children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>v(j.id),children:e.jsx(Ir,{className:"h-4 w-4"})})]})]},j.id)})})]})}),e.jsx(js,{open:a,onOpenChange:o,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:j=>{j.preventDefault();const w=new FormData(j.currentTarget);f.mutate({id:r==null?void 0:r.id,title:w.get("title"),script_text:w.get("script_text"),category_id:w.get("category_id")||null,tags:w.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"title",children:"Title"}),e.jsx(Be,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"category_id",children:"Category"}),e.jsxs(er,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select category"})}),e.jsx(Js,{children:l==null?void 0:l.map(j=>e.jsx(Et,{value:j.id,children:j.name},j.id))})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Rr,{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(je,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(Be,{id:"tags",name:"tags",defaultValue:((_=r==null?void 0:r.tags)==null?void 0:_.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(Hn,{className:"mt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:f.isPending,children:[f.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function s6t(){const{toast:t}=Sa(),[s,r]=T.useState(""),[n,a]=T.useState(!0),[o,l]=T.useState(!1);T.useEffect(()=>{(async()=>{a(!0);try{const{data:h}=await Z.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();h!=null&&h.value&&r(h.value)}catch(h){console.error("Error fetching settings:",h)}a(!1)})()},[]);const i=async()=>{l(!0);try{await Z.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(Oe,{children:e.jsx($e,{className:"flex justify-center py-8",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Gi,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(Tr,{children:"Configure the map feature for popbys"})]}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(Be,{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(Y,{onClick:i,disabled:o,children:[o&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(ct,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const r6t=()=>{const[t,s]=T.useState(""),[r,n]=T.useState("grid"),a=Yr(),{data:o=[],isLoading:l}=zt({queryKey:["additional-services"],queryFn:async()=>{const{data:d,error:h}=await Z.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(h)throw h;return d}}),i=o.filter(d=>{var f;return d.name.toLowerCase().includes(t.toLowerCase())||((f=d.description)==null?void 0:f.toLowerCase().includes(t.toLowerCase()))});return e.jsx(Vs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{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(Y,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(Qm,{className:"h-4 w-4"})}),e.jsx(Y,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(dm,{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,h)=>e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"})]})},h))}),!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(Y,{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(Oe,{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(Sn,{className:"h-8 w-8"})})}),e.jsxs($e,{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:pie(d.description)})]})]},d.id))})]})})},n6t=()=>{const{serviceId:t}=wl(),s=Yr(),{data:r,isLoading:n}=zt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await Z.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Vs,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-64 w-full rounded-lg"}),e.jsx(ys,{className:"h-24 w-full"})]})}):r?e.jsx(Vs,{title:r.name,children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(Y,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(bi,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Oe,{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(Sn,{className:"h-16 w-16"})})})}),e.jsx(Oe,{children:e.jsxs($e,{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(xn,{className:"h-4 w-4 mr-1"}),"Published ",Bs(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(Y,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(bn,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Vs,{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(Y,{onClick:()=>s("/additional-services"),children:[e.jsx(bi,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},AA=[{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 a6t(){const[t,s]=T.useState(AA[0].id),r=AA.find(n=>n.id===t)||AA[0];return e.jsx(Vs,{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(C4,{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(er,{value:t,onValueChange:s,children:[e.jsx(Qs,{className:"w-full",children:e.jsx(tr,{placeholder:"Select a tool"})}),e.jsx(Js,{children:AA.map(n=>e.jsx(Et,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(Qa,{value:t,onValueChange:s,className:"w-full",children:e.jsx(Ga,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:AA.map(n=>e.jsx(Fs,{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 zMe="agent-os-onboarding-completed",f8=[{icon:Cx,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:Ax,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:br,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:Km,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:oo,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:Sc,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"]}],i6t=()=>{const[t,s]=T.useState(!1),[r,n]=T.useState(0),[a,o]=T.useState(!1);T.useEffect(()=>{if(!localStorage.getItem(zMe)){const j=setTimeout(()=>s(!0),500);return()=>clearTimeout(j)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(zMe,"true"),s(!1)},h=f8[r],f=h.icon,g=r===f8.length-1,v=_=>{_||d(),s(_)};return e.jsx(js,{open:t,onOpenChange:v,children:e.jsxs(_s,{className:"sm:max-w-lg overflow-hidden p-0 gap-0",children:[e.jsxs("div",{className:`relative bg-gradient-to-br ${h.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(f,{className:`h-10 w-10 ${h.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(Sn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(Ls,{className:"text-center sm:text-center pb-2",children:[e.jsx(Ps,{className:`text-2xl font-bold transition-all duration-300 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:h.title}),e.jsx(en,{className:`text-base pt-2 transition-all duration-300 delay-75 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:h.description})]}),h.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:h.highlights.map((_,j)=>e.jsxs("div",{className:"flex items-center gap-3 group",style:{transitionDelay:`${150+j*50}ms`},children:[e.jsx("div",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${h.bgGradient} shadow-sm`,children:e.jsx(ma,{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:_})]},j))}),e.jsx("div",{className:"flex justify-center gap-2 py-4",children:f8.map((_,j)=>e.jsx("button",{onClick:()=>{j!==r&&(o(!0),setTimeout(()=>{n(j),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${j===r?"w-8 bg-gradient-to-r "+h.bgGradient:j{const{user:t}=Ys();return zt({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},l6t=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=Ul(new Date,n);await Z.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await Z.from("contact_snoozes").insert({contact_id:r,owner_user_id:s.id,snoozed_until:a.toISOString()});if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),t.invalidateQueries({queryKey:["today-actions"]}),t.invalidateQueries({queryKey:["popby-logs"]}),pn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{pn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},c6t=()=>{const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),pn({title:"Snooze cancelled"})},onError:s=>{pn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},d6t=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function Ooe({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=T.useState(null),l=l6t(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=h=>Bs(Ul(new Date,h),"MMM d, yyyy");return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(ca,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(en,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:d6t.map(h=>e.jsxs("button",{type:"button",onClick:()=>o(h.days),className:$t("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===h.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:h.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(xn,{className:"h-3.5 w-3.5"}),"Until ",d(h.days)]})]},h.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Y,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const u6t={Crown:kh,FileText:Yn,Users:br,Globe:pg,Star:qn,Phone:Ha,MessageSquare:Eo,PenTool:Tk,Video:Wn,Gift:oo};function h6t({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=Yr(),[d,h]=T.useState("name"),[f,g]=T.useState("asc"),[v,_]=T.useState(null),[j,w]=T.useState(""),k=L=>{d===L?g(B=>B==="asc"?"desc":"asc"):(h(L),g("asc"))},M=T.useMemo(()=>[...t].sort((L,B)=>{var V,W;let $=0;switch(d){case"name":{const G=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),J=`${B.contact.first_name} ${B.contact.last_name||""}`.toLowerCase();$=G.localeCompare(J);break}case"relationship_type":$=(L.relationshipTypeName||"").localeCompare(B.relationshipTypeName||"");break;case"action_type":$=(((V=L.actionType)==null?void 0:V.name)||"").localeCompare(((W=B.actionType)==null?void 0:W.name)||"");break;case"last_touch":$=(L.monthNumber||0)-(B.monthNumber||0);break}return f==="asc"?$:-$}),[t,d,f]),S=L=>u6t[L||"Phone"]||Ha,E=({field:L,children:B})=>e.jsxs(Y,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>k(L),children:[B,d===L?f==="asc"?e.jsx(Wm,{className:"ml-2 h-4 w-4"}):e.jsx(jx,{className:"ml-2 h-4 w-4"}):e.jsx(Hp,{className:"ml-2 h-4 w-4 opacity-50"})]}),D=(L,B,$)=>{_(L),w(`${B} ${$||""}`.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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/50",children:[e.jsx(Ct,{className:"w-[180px]",children:e.jsx(E,{field:"name",children:"Contact"})}),e.jsx(Ct,{className:"w-[130px]",children:e.jsx(E,{field:"relationship_type",children:"Type"})}),e.jsx(Ct,{className:"w-[120px]",children:e.jsx(E,{field:"action_type",children:"Action"})}),e.jsx(Ct,{className:"w-[130px]",children:"Phone"}),e.jsx(Ct,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Bn,{children:M.map((L,B)=>{var ne,ie,ee,de,oe,ue;const $=L.isSpecialDate,V=L.specialDateType,W=$?V==="birthday"?Gm:Zn:S(((ne=L.actionType)==null?void 0:ne.icon)||null),G=L.contact.phone,J=L.contact.email;return e.jsxs(ws,{className:$t("hover:bg-muted/50 transition-colors",$&&V==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",$&&V==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(ot,{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(ot,{children:L.relationshipTypeName?e.jsx(ct,{variant:"secondary",className:"text-xs",children:L.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ot,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:$?e.jsx(ct,{className:$t("gap-1",V==="birthday"&&"bg-pink-500 hover:bg-pink-600",V==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:V==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Gm,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Zn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(ct,{variant:"outline",className:"gap-1",children:[e.jsx(W,{className:"h-3 w-3"}),(ie=L.actionType)==null?void 0:ie.name]})})}),e.jsx(ot,{children:G?e.jsx("span",{className:"text-sm font-mono",children:L.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[G&&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(Ha,{className:"h-3.5 w-3.5"})}),G&&e.jsx("a",{href:a(L.contact.phone,(ee=L.script)==null?void 0:ee.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(Eo,{className:"h-3.5 w-3.5"})}),J&&(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(zr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(L.contact.email,(de=L.script)==null?void 0:de.script_body,(oe=L.script)==null?void 0:oe.email_subject,(ue=L.actionType)==null?void 0:ue.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(zr,{className:"h-3.5 w-3.5"})})),$&&e.jsxs("button",{onClick:()=>{const ce=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,ge=V==="birthday"?"birthday":"home_anniversary",Te=new URLSearchParams({cardType:ge,contactId:L.contact.id,name:ce,...L.contact.address?{address:L.contact.address}:{},...V==="anniversary"&&L.contact.home_anniversary?{date:L.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${Te.toString()}`)},className:$t("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",V==="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 ${V==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(zr,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>D(L.contact.id,L.contact.first_name,L.contact.last_name),title:"Snooze",children:e.jsx(ep,{className:"h-3.5 w-3.5"})}),e.jsxs(Y,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var ce;return s(L.contact.id,L.actionType.id,(ce=L.script)==null?void 0:ce.id)},disabled:n,children:[e.jsx(oi,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${B}`)})})]})}),e.jsx(Ooe,{open:!!v,onOpenChange:L=>!L&&_(null),contactId:v||"",contactName:j})]})}function MN(){const{data:t,isLoading:s}=zt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await Z.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 m6t({onSelect:t}){const[s,r]=T.useState(null),{data:n=[],isLoading:a}=zt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:d,error:h}=await Z.from("email_template_categories").select("*").order("sort_order");if(h)throw h;return d}}),{data:o=[],isLoading:l}=zt({queryKey:["agent-email-templates",s],queryFn:async()=>{let d=Z.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(d=d.eq("category_id",s));const{data:h,error:f}=await d;if(f)throw f;return h}}),i=n.find(d=>d.id===s);return a?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(Us,{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(hc,{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(Us,{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(po,{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(ct,{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(Ri,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}const p6t=5*1024*1024,f6t=["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 g6t(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function x6t(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 EA(t,s){return 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())}function Roe({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const d=!!n&&n.length>0,h=d?n:r?[r]:[],f=h[0],[g,v]=T.useState((f==null?void 0:f.email)||""),[_,j]=T.useState(a),[w,k]=T.useState(o),[M,S]=T.useState(!1),[E,D]=T.useState(!1),[L,B]=T.useState([]);T.useEffect(()=>{t&&(v((f==null?void 0:f.email)||""),j(EA(a,f||{first_name:""})),k(EA(o,f||{first_name:""})),D(!a&&!o),B([]))},[t,f,a,o]);const $=async ie=>{const ee=ie.target.files;if(!ee)return;const de=L.reduce((ue,ce)=>ue+ce.size,0),oe=[];for(const ue of Array.from(ee)){if(!f6t.includes(ue.type)){be.error(`${ue.name}: Unsupported file type`);continue}if(de+ue.size>p6t){be.error("Total attachments exceed 20MB limit");break}try{const ce=await x6t(ue);oe.push({name:ue.name,type:ue.type,size:ue.size,data:ce})}catch{be.error(`Failed to read ${ue.name}`)}}B(ue=>[...ue,...oe]),ie.target.value=""},V=ie=>{B(ee=>ee.filter((de,oe)=>oe!==ie))},W=ie=>{j(EA(ie.subject,f||{first_name:""})),k(EA(ie.body,f||{first_name:""})),D(!1)},G=ie=>ie.split(/\n\n+/).map(ee=>`

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

`).join(""),J=async ie=>{if(!_||!w)return be.error("Please fill in subject and message"),!1;const ee=EA(w,ie),de=G(ee);try{const{data:oe,error:ue}=await Z.functions.invoke("gmail-send",{body:{to:ie.email,subject:_,body:de,contactId:ie.id,attachments:L.map(({name:ce,type:ge,data:Te})=>({name:ce,type:ge,data:Te}))}});if(ue)throw ue;if(!(oe!=null&&oe.success))throw new Error((oe==null?void 0:oe.error)||"Failed to send");return!0}catch(oe){return console.error("Gmail send error:",oe),be.error("Failed to send to "+ie.first_name+": "+(oe instanceof Error?oe.message:"Unknown error")),!1}},ne=async()=>{if(!_||!w){be.error("Please fill in subject and message");return}if(d&&h.length>50){be.error("Maximum 50 recipients per bulk send");return}S(!0);try{if(d){let ie=0;for(const ee of h)await J(ee)&&ie++,await new Promise(oe=>setTimeout(oe,100));be.success(`Sent ${ie} of ${h.length} emails`)}else await J(f)&&be.success("Email sent successfully!");s(!1),i==null||i()}catch(ie){console.error("Bulk send error:",ie),be.error("Error sending emails")}finally{S(!1)}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"h-5 w-5 text-red-500"}),d?`Send to ${h.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})]})]}),e.jsxs("div",{className:"space-y-4",children:[E?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(Yn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>D(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Xr,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(m6t,{onSelect:W})]}):e.jsxs(Y,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>D(!0),children:[e.jsx(Yn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(ud,{}),e.jsx("div",{className:"space-y-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(je,{children:"Recipients"}),e.jsx("div",{className:"bg-muted p-3 rounded-md space-y-1 max-h-24 overflow-y-auto text-muted-foreground",children:h.map(ie=>e.jsxs("div",{className:"text-sm",children:[ie.first_name," ",ie.last_name," — ",ie.email]},ie.id))})]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{htmlFor:"gmail-to",children:"To"}),e.jsx(Be,{id:"gmail-to",value:g,onChange:ie=>v(ie.target.value),placeholder:"recipient@example.com"})]})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(Be,{id:"gmail-subject",value:_,onChange:ie=>j(ie.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(je,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(ct,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>k(ie=>ie+"{{first_name}}"),children:"{{first_name}}"}),e.jsx(ct,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>k(ie=>ie+"{{last_name}}"),children:"{{last_name}}"})]})]}),e.jsx(Rr,{id:"gmail-body",value:w,onChange:ie=>k(ie.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(Y,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var ie;return(ie=document.getElementById("gmail-attachments"))==null?void 0:ie.click()},disabled:M,children:[e.jsx(Mk,{className:"h-4 w-4"}),"Attach Files"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"PDF, images, Word, Excel (max 5MB total)"}),e.jsx("input",{id:"gmail-attachments",type:"file",multiple:!0,accept:".pdf,.jpg,.jpeg,.png,.gif,.webp,.doc,.docx,.xls,.xlsx,.csv",className:"hidden",onChange:$})]}),L.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:L.map((ie,ee)=>e.jsxs(ct,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(Mk,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:ie.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",g6t(ie.size),")"]}),e.jsx("button",{type:"button",onClick:()=>V(ee),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Xr,{className:"h-3 w-3"})})]},ee))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>s(!1),disabled:M,children:"Cancel"}),e.jsxs(Y,{onClick:ne,disabled:M||!_||!w,className:"gap-2",children:[M?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(Wa,{className:"h-4 w-4"}),M?"Sending...":d?`Send to ${h.length}`:"Send Email"]})]})]})]})})}const BMe={Crown:kh,FileText:Yn,Users:br,Globe:pg,Star:qn,Phone:Ha,MessageSquare:Eo,PenTool:Tk,Video:Wn,Gift:oo},y6t={"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 v6t(){var it,dt,tt,ut,xt,_t;const t=Yr(),{user:s}=Ys(),{data:r}=Ag(),{data:n}=I9e(),{data:a}=of(),{data:o}=A1e(),{data:l}=z9e(),i=Ewt(),d=F9e(),h=Twt(90),f=D9e(),[g,v]=T.useState(null),[_,j]=T.useState(null),[w,k]=T.useState(!1),[M,S]=T.useState(""),[E,D]=T.useState(!1),[L,B]=T.useState(""),[$,V]=T.useState(Gre()),[W,G]=T.useState("cards"),[J,ne]=T.useState(!1),[ie,ee]=T.useState(null),[de,oe]=T.useState(null),[ue,ce]=T.useState(""),{isGmailConnected:ge,gmailEmail:Te}=MN(),ve=()=>{const qe=parseInt(L,10);if(isNaN(qe)||qe<1){pn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}V(qe),R9e(qe),D(!1),pn({title:"Goal updated",description:`Weekly touch goal set to ${qe}`})},ye=()=>{B($.toString()),D(!0)};T.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:Lt}=await Z.from("profiles").select("name").eq("id",s.id).single();Lt!=null&&Lt.name&&S(Lt.name.split(" ")[0])})()},[s==null?void 0:s.id]),T.useEffect(()=>{i.mutate()},[]);const Se=ip(new Date),Ke=Ul(Se,7),Ae=qe=>{if(!qe)return null;const Lt=qe.split(/[-/T]/);if(Lt.length<3)return null;const Rt=parseInt(Lt[1],10)-1,Kt=parseInt(Lt[2],10);return isNaN(Rt)||isNaN(Kt)?null:new Date(Se.getFullYear(),Rt,Kt)},Ee=(a==null?void 0:a.filter(qe=>{const Lt=Ae(qe.birthday),Rt=Ae(qe.home_anniversary);return Lt&&Vl(Lt,Se)||Rt&&Vl(Rt,Se)}))||[],He=(a==null?void 0:a.filter(qe=>{if(!qe.birthday&&!qe.home_anniversary)return!1;const Lt=Rt=>{if(!Rt)return!1;const Kt=Ae(Rt);return Kt?Are(Kt,Se)&&Hie(Kt,Ke):!1};return Lt(qe.birthday)||Lt(qe.home_anniversary)}).slice(0,5))||[],Ue=[],De=(o==null?void 0:o.find(qe=>qe.name==="Call"))||(o==null?void 0:o[0]);for(const qe of Ee){const Lt=Ae(qe.birthday),Rt=Ae(qe.home_anniversary),Kt=Lt&&Vl(Lt,Se),Xt=Rt&&Vl(Rt,Se);Kt&&Ue.push({contact:qe,actionType:De||{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:((tt=(dt=(it=qe.tags)==null?void 0:it[0])==null?void 0:dt.relationship_type)==null?void 0:tt.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),Xt&&Ue.push({contact:qe,actionType:De||{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:((_t=(xt=(ut=qe.tags)==null?void 0:ut[0])==null?void 0:xt.relationship_type)==null?void 0:_t.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const wt=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((qe,Lt)=>{var Kt,Xt,ss;const Rt=o==null?void 0:o[Lt%((o==null?void 0:o.length)||1)];return Rt?{contact:qe,actionType:Rt,planName:"Quick Touch",relationshipTypeName:((ss=(Xt=(Kt=qe.tags)==null?void 0:Kt[0])==null?void 0:Xt.relationship_type)==null?void 0:ss.name)||"",monthNumber:0}:null}).filter(Boolean))||[],Ie=[...Ue,...wt],st=async(qe,Lt,Rt)=>{await f.mutateAsync({contactId:qe,actionTypeId:Lt,scriptUsedId:Rt}),k(!1),j(null)},he=qe=>{qe.script?(j(qe),k(!0)):st(qe.contact.id,qe.actionType.id)},We=qe=>BMe[qe||"Phone"]||Ha,et=qe=>BMe[qe||"Users"]||br,Ye=(qe,Lt)=>qe.replace(/\{\{FirstName\}\}/g,Lt.first_name).replace(/\{\{LastName\}\}/g,Lt.last_name||"").replace(/\{\{AgentName\}\}/g,M||"there"),ke=(qe,Lt)=>({Call:`Thinking of you, ${Lt}!`,Text:`Quick hello, ${Lt}`,Email:`Checking in, ${Lt}`,"Handwritten Note":`A note for ${Lt}`,Video:`Video message for ${Lt}`,Gift:`Something special for you, ${Lt}`})[qe]||`Hello ${Lt}!`,at=(qe,Lt,Rt)=>{const Kt=`sms:${qe}`;if(Lt&&Rt){const Xt=Ye(Lt,Rt);return`${Kt}?body=${encodeURIComponent(Xt)}`}return Kt},Fe=(qe,Lt,Rt,Kt,Xt)=>{const ss=`mailto:${qe}`,fs=[];if(Xt){const fr=Rt||ke(Kt||"Email",Xt.first_name);if(fs.push(`subject=${encodeURIComponent(fr)}`),Lt){const yt=Ye(Lt,Xt);fs.push(`body=${encodeURIComponent(yt)}`)}}return fs.length>0?`${ss}?${fs.join("&")}`:ss};return e.jsxs(e.Fragment,{children:[e.jsxs(Vs,{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(qe=>qe.active).map(qe=>{const Lt=et(qe.icon),Rt=(n==null?void 0:n[qe.id])||0,Kt=g===qe.id,Xt=y6t[qe.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Kt?(v(null),t("/mission-control/contacts")):(v(qe.id),t(`/mission-control/contacts?type=${qe.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Kt?Xt:"bg-card hover:bg-accent"} `,children:[e.jsx(Lt,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:qe.name}),e.jsxs("div",{className:`text-sm ${Kt?"opacity-90":"text-muted-foreground"}`,children:[Rt," Contacts"]})]})]},qe.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(Y,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(Wd,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(Y,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(Ri,{className:"h-4 w-4 ml-1"})]}),e.jsx(Y,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(Y,{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(ct,{variant:"outline",className:"gap-1",children:[e.jsx(Sn,{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(Y,{variant:W==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>G("cards"),title:"Card view",children:e.jsx(Qm,{className:"h-4 w-4"})}),e.jsx(Y,{variant:W==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>G("table"),title:"Table view",children:e.jsx(dm,{className:"h-4 w-4"})})]})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-4",children:Ie.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(Y,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):W==="table"?e.jsx(h6t,{actions:Ie,onMarkComplete:st,onViewScript:he,isLoading:f.isPending,buildSmsLink:at,buildEmailLink:Fe,onGmailCompose:ge?qe=>{ee(qe),ne(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[Ie.map((qe,Lt)=>{var bs,gr,Br,na,za,go,Ia;const Rt=qe.isSpecialDate,Kt=qe.specialDateType,Xt=Rt?Kt==="birthday"?Gm:Zn:We(((bs=qe.actionType)==null?void 0:bs.icon)||null),ss=qe.contact.phone,fs=qe.contact.email,fr=Rt?Kt==="birthday"?"#EC4899":"#8B5CF6":((gr=qe.actionType)==null?void 0:gr.color)||"#3B82F6",yt=Rt?Kt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(Br=qe.actionType)==null?void 0:Br.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":fr}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:fr},children:[e.jsx(Xt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:yt})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${qe.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[qe.contact.first_name," ",qe.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[ss&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${qe.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(Ha,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:at(qe.contact.phone,(na=qe.script)==null?void 0:na.script_body,qe.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(Eo,{className:"h-3 w-3"}),"Text"]})]}),fs&&(ge?e.jsxs("button",{onClick:()=>{ee({id:qe.contact.id,first_name:qe.contact.first_name,last_name:qe.contact.last_name,email:qe.contact.email}),ne(!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(zr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:Fe(qe.contact.email,(za=qe.script)==null?void 0:za.script_body,(go=qe.script)==null?void 0:go.email_subject,(Ia=qe.actionType)==null?void 0:Ia.name,qe.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(zr,{className:"h-3 w-3"}),"Email"]}))]}),Rt&&e.jsxs("button",{onClick:()=>{const nn=`${qe.contact.first_name}${qe.contact.last_name?" "+qe.contact.last_name:""}`,Qt=Kt==="birthday"?"birthday":"home_anniversary",lr=new URLSearchParams({cardType:Qt,contactId:qe.contact.id,name:nn,...qe.contact.address?{address:qe.contact.address}:{},...Kt==="anniversary"&&qe.contact.home_anniversary?{date:qe.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${lr.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(zr,{className:"h-3 w-3"}),"Send ",Kt==="birthday"?"Birthday":"Anniversary"," Card"]}),!ss&&!fs&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[qe.relationshipTypeName&&e.jsx(ct,{variant:"secondary",className:"text-xs",children:qe.relationshipTypeName}),qe.monthNumber>0&&e.jsxs(ct,{variant:"outline",className:"text-xs",children:["Month ",qe.monthNumber]})]}),qe.script&&e.jsx(Y,{size:"sm",variant:"outline",className:"w-full",onClick:()=>he(qe),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(Y,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{oe(qe.contact.id),ce(`${qe.contact.first_name} ${qe.contact.last_name||""}`.trim())},children:[e.jsx(ep,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(Y,{size:"sm",className:"flex-1",onClick:()=>{var nn;return st(qe.contact.id,qe.actionType.id,(nn=qe.script)==null?void 0:nn.id)},disabled:f.isPending,children:"Mark Complete"})]})]})]},qe.contact.id+Lt)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsxs(Y,{variant:"ghost",className:"h-full w-full",children:[e.jsx(Rp,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(ju,{children:e.jsx(Va,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Oe,{className:"md:col-span-2",children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gt,{className:"text-lg",children:"Momentum"}),e.jsxs(js,{open:E,onOpenChange:D,children:[e.jsx(Fi,{asChild:!0,children:e.jsx("button",{onClick:ye,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Ic,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(_s,{className:"sm:max-w-[360px]",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Set Weekly Goal"}),e.jsx(en,{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(je,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(Be,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:qe=>B(qe.target.value),placeholder:"20",onKeyDown:qe=>{qe.key==="Enter"&&ve()}})]}),e.jsx(Y,{onClick:ve,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs($e,{className:"space-y-4",children:[e.jsx(rl,{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(Ym,{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)"]})]})]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-lg",children:"Upcoming Reminders"})}),e.jsxs($e,{className:"space-y-3",children:[He.length>0?He.map(qe=>{const Lt=qe.birthday,Rt=qe.home_anniversary;return e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[Lt?e.jsx("span",{className:"text-lg",children:"🎂"}):e.jsx("span",{className:"text-lg",children:"🏠"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"font-medium",children:[qe.first_name,"'s"]}),e.jsxs("span",{className:"text-muted-foreground",children:[" ",Lt?"Birthday":"Home Anniversary"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[Lt&&qe.birthday&&(()=>{const Kt=qe.birthday.split(/[-/T]/);return Bs(new Date(new Date().getFullYear(),parseInt(Kt[1],10)-1,parseInt(Kt[2],10)),"MMM d")})(),Lt&&Rt&&" · ",Rt&&qe.home_anniversary&&(()=>{const Kt=qe.home_anniversary.split(/[-/T]/);return Bs(new Date(new Date().getFullYear(),parseInt(Kt[1],10)-1,parseInt(Kt[2],10)),"MMM d")})()]})]}),e.jsxs("button",{onClick:()=>{const Kt=`${qe.first_name}${qe.last_name?" "+qe.last_name:""}`,Xt=Lt?"birthday":"home_anniversary",ss=new URLSearchParams({cardType:Xt,contactId:qe.id,name:Kt,...qe.address?{address:qe.address}:{},...!Lt&&qe.home_anniversary?{date:qe.home_anniversary}:{}});t(`/mission-control/card-studio?${ss.toString()}`)},className:"shrink-0 flex items-center gap-1 px-2 py-1 rounded-full text-[10px] font-semibold bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Send a card",children:[e.jsx(zr,{className:"h-3 w-3"}),"Send Card"]})]},qe.id)}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming reminders"}),h.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(ca,{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:[h.count," Contact",h.count!==1?"s":""]}),e.jsx("span",{className:"text-muted-foreground",children:" Not Reached in 90+ Days"})]}),e.jsx(Ri,{className:"h-4 w-4 text-muted-foreground ml-auto mt-0.5"})]})]})]}),e.jsx(e$e,{})]})]}),e.jsx(js,{open:w,onOpenChange:k,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Ls,{children:e.jsx(Ps,{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:Ye(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{variant:"outline",className:"flex-1",onClick:()=>k(!1),children:"Close"}),e.jsx(Y,{className:"flex-1",onClick:()=>{var qe;return st(_.contact.id,_.actionType.id,(qe=_.script)==null?void 0:qe.id)},disabled:f.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(i6t,{})]}),ge&&ie&&e.jsx(Roe,{open:J,onOpenChange:ne,contact:ie,gmailEmail:Te}),e.jsx(Ooe,{open:!!de,onOpenChange:qe=>!qe&&oe(null),contactId:de||"",contactName:ue})]})}const SHe=()=>{const{user:t}=Ys();return zt({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.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})},Foe=t=>{const{user:s}=Ys();return zt({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=Z.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})},G_e=()=>{const{user:t}=Ys();return zt({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},CHe=()=>{const{user:t}=Ys();return zt({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},MHe=()=>{const{data:t}=of(),{data:s}=Ag(),{data:r}=Foe(),{data:n}=CHe(),{data:a}=G_e(),o=new Map;r==null||r.forEach(f=>{const g=o.get(f.contact_id);(!g||new Date(f.completed_at)>new Date(g))&&o.set(f.contact_id,f.completed_at)});const l=new Map;a==null||a.forEach(f=>l.set(f.relationship_type_id,f.frequency_days));const i=new Map;n==null||n.filter(f=>f.is_active).forEach(f=>{i.set(f.contact_id,f.frequency_days)});const d=ip(new Date);return(t||[]).map(f=>{let g=90;if(i.has(f.id))g=i.get(f.id);else if(f.tags&&f.tags.length>0){const k=f.tags.map(M=>l.get(M.relationship_type_id)).filter(M=>M!==void 0);k.length>0&&(g=Math.min(...k))}const v=o.get(f.id)||null,_=v?bg(d,ip(new Date(v))):null,j=_===null||_>=g,w=j&&_!==null?_-g:0;return{...f,lastPopby:v,daysSinceLastPopby:_,frequencyDays:g,isDue:j,daysOverdue:w}}).sort((f,g)=>g.daysOverdue-f.daysOverdue)},THe=()=>MHe().filter(s=>s.isDue),_6t=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{error:n}=await Z.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),pn({title:"Popby item created!"})},onError:r=>{pn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},AHe=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{error:n}=await Z.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),pn({title:"Popby logged!"})},onError:r=>{pn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},b6t=()=>{const t=vs(),{user:s}=Ys();return Wt({mutationFn:async r=>{const{error:n}=await Z.from("relationship_type_popby_defaults").upsert({...r,owner_user_id:s==null?void 0:s.id},{onConflict:"relationship_type_id,owner_user_id"});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["relationship-type-popby-defaults"]}),pn({title:"Frequency updated!"})},onError:r=>{pn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},w6t=()=>{const{data:t}=Foe(30),s=THe(),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 j6t(){const{user:t}=Ys();return zt({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function EHe(t){const{data:s}=j6t(),{data:r}=CHe(),{data:n}=G_e(),{data:a}=o6t();return T.useMemo(()=>{const o=a==null?void 0:a.find(k=>k.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=ip(new Date);if(l&&!Hie(l,i))return{nextTouchDate:l,daysUntil:bg(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const h=((s==null?void 0:s.filter(k=>k.contact_id===t.id))||[]).sort((k,M)=>new Date(M.completed_at).getTime()-new Date(k.completed_at).getTime())[0],f=h?new Date(h.completed_at):null;let g=90;const v=r==null?void 0:r.find(k=>k.contact_id===t.id&&k.is_active);if(v)g=v.frequency_days;else if(t.tags&&t.tags.length>0){const k=t.tags.map(M=>{const S=n==null?void 0:n.find(E=>E.relationship_type_id===M.relationship_type_id);return S==null?void 0:S.frequency_days}).filter(M=>M!==void 0);k.length>0&&(g=Math.min(...k))}if(!f)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:g,lastTouchDate:null,snoozedUntil:null};const _=Ul(ip(f),g),j=bg(_,i);let w;return j<0?w="overdue":j<=7?w="due-soon":w="on-track",{nextTouchDate:_,daysUntil:j,status:w,frequencyDays:g,lastTouchDate:f,snoozedUntil:null}},[t,s,r,n,a])}function Wge({contact:t}){const s=EHe(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:ca,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:oi,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:ep,text:`Snoozed until ${Bs(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:xn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(ct,{variant:n.variant,className:$t("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function k6t({contact:t,onLogTouch:s,onSnooze:r}){const n=EHe(t),a=c6t(),[o,l]=T.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(ca,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(oi,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(ep,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(xn,{className:"h-5 w-5 text-muted-foreground"})}},h=()=>{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"}},f=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs($e,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d(),e.jsx("span",{className:$t("font-medium",i()),children:h()})]}),n.status==="snoozed"&&n.snoozedUntil&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",Bs(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:"})," ",Bs(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:"})," ",Bs(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(Y,{size:"sm",variant:"outline",className:"flex-1",onClick:f,disabled:a.isPending,children:[e.jsx(Xr,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(Y,{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(Y,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(ep,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(Y,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(Ooe,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const Hhe=768;function Q3(){const[t,s]=T.useState(void 0);return T.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Hhe-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}const N6t={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"}},S6t={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 Whe({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=N6t[t.status],l=S6t[n],i=e.jsxs("div",{className:$t("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:$t("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(bN,{children:e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:i}),e.jsx(fh,{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:$t("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(rl,{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 C6t=[{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}],M6t=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Ys(),{toast:o}=Sa(),l=T.useRef(null),[i,d]=T.useState("upload"),[h,f]=T.useState([]),[g,v]=T.useState([]),[_,j]=T.useState({}),[w,k]=T.useState([]),[M,S]=T.useState([]),[E,D]=T.useState(!1),[L,B]=T.useState(null),$=()=>{d("upload"),f([]),v([]),j({}),k([]),S([]),B(null),l.current&&(l.current.value="")},V=()=>{$(),s(!1)},W=ue=>{const ce=ue.split(` `).map(ye=>ye.trim()).filter(ye=>ye);if(ce.length===0)return{headers:[],data:[]};const ge=ye=>{const Se=[];let Ke="",Ae=!1;for(let Ee=0;Ee{var Te;const ce=(Te=ue.target.files)==null?void 0:Te[0];if(!ce)return;const ge=new FileReader;ge.onload=ve=>{var Ee;const ye=(Ee=ve.target)==null?void 0:Ee.result,{headers:Se,data:Ke}=W(ye);if(Se.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}f(Se),v(Ke);const Ae={};Se.forEach(He=>{const Ue=He.toLowerCase().replace(/[_\s-]/g,"");Ue.includes("firstname")||Ue==="first"?Ae.first_name=He:Ue.includes("lastname")||Ue==="last"?Ae.last_name=He:Ue.includes("email")?Ae.email=He:Ue.includes("phone")||Ue.includes("mobile")||Ue.includes("cell")?Ae.phone=He:Ue.includes("address")||Ue.includes("street")?Ae.address=He:Ue==="city"?Ae.city=He:Ue==="state"||Ue==="province"?Ae.state=He:Ue==="zip"||Ue==="zipcode"||Ue==="postalcode"?Ae.zip=He:Ue.includes("spouse")&&Ue.includes("email")?Ae.spouse_email=He:Ue.includes("spouse")||Ue.includes("partner")?Ae.spouse_name=He:Ue.includes("company")||Ue.includes("organization")||Ue.includes("business")?Ae.company_name=He:Ue.includes("jobtitle")||Ue.includes("title")||Ue.includes("position")?Ae.job_title=He:Ue.includes("birthday")||Ue.includes("dob")||Ue.includes("birthdate")?Ae.birthday=He:Ue.includes("anniversary")||Ue.includes("homeanniversary")?Ae.home_anniversary=He:(Ue.includes("notes")||Ue.includes("comment"))&&(Ae.notes=He)}),j(Ae),d("mapping")},ge.readAsText(ce)},J=(ue,ce)=>{j(ge=>{if(ce==="none"){const{[ue]:Te,...ve}=ge;return ve}return{...ge,[ue]:ce}})},ne=ue=>{k(ce=>ce.includes(ue)?ce.filter(ge=>ge!==ue):[...ce,ue])},ie=()=>{const ue=g.map(ce=>{const ge=ye=>{const Se=_[ye];if(!Se)return"";const Ke=h.indexOf(Se);return Ke>=0?(ce[Ke]||"").trim():""},Te=ge("first_name"),ve=Te.length>0;return{first_name:Te,last_name:ge("last_name"),email:ge("email"),phone:ge("phone"),address:ge("address"),city:ge("city"),state:ge("state"),zip:ge("zip"),spouse_name:ge("spouse_name"),spouse_email:ge("spouse_email"),company_name:ge("company_name"),job_title:ge("job_title"),birthday:ge("birthday"),home_anniversary:ge("home_anniversary"),notes:ge("notes"),isValid:ve,error:ve?void 0:"First name is required"}});S(ue),d("preview")},ee=async()=>{if(!(a!=null&&a.id))return;const ue=M.filter(ve=>ve.isValid);if(ue.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}D(!0);let ce=0,ge=0,Te=0;try{for(const ve of ue)try{let ye=null;if(ve.email){const{data:Ke}=await Z.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",ve.email).maybeSingle();ye=Ke}if(!ye&&ve.phone){const{data:Ke}=await Z.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("phone",ve.phone).maybeSingle();ye=Ke}const Se={owner_user_id:a.id,first_name:ve.first_name,last_name:ve.last_name||null,email:ve.email||null,phone:ve.phone||null,address:ve.address||null,city:ve.city||null,state:ve.state||null,zip:ve.zip||null,spouse_name:ve.spouse_name||null,spouse_email:ve.spouse_email||null,company_name:ve.company_name||null,job_title:ve.job_title||null,birthday:ve.birthday||null,home_anniversary:ve.home_anniversary||null,notes:ve.notes||null};if(ye)await Z.from("innercircle_contacts").update(Se).eq("id",ye.id),ge++;else{const{data:Ke}=await Z.from("innercircle_contacts").insert(Se).select("id").single();Ke&&w.length>0&&await Z.from("innercircle_contact_tags").insert(w.map(Ae=>({contact_id:Ke.id,relationship_type_id:Ae}))),ce++}}catch(ye){console.error("Error importing contact:",ye),Te++}B({created:ce,updated:ge,failed:Te}),d("result"),(ce>0||ge>0)&&n(),o({title:"Import Complete",description:`${ce} created, ${ge} updated${Te>0?`, ${Te} failed`:""}.`})}catch(ve){console.error("Import error:",ve),o({title:"Import Failed",description:ve.message||"Failed to import contacts",variant:"destructive"})}finally{D(!1)}},de=M.filter(ue=>ue.isValid).length,oe=M.filter(ue=>!ue.isValid).length;return e.jsx(js,{open:t,onOpenChange:V,children:e.jsxs(_s,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(Qy,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(en,{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:G,className:"hidden"}),e.jsx(ji,{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(Y,{onClick:()=>{var ue;return(ue=l.current)==null?void 0:ue.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, Company, Job Title, Birthday, Home Anniversary, Notes"}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>{const ue=`First Name,Last Name,Email,Phone,Street Address,City,State,Zip,Spouse Name,Company,Job Title,Birthday,Home Anniversary,Notes John,Doe,john@example.com,555-123-4567,123 Main St,Austin,TX,78701,Jane Doe,ABC Realty,Real Estate Agent,1985-06-15,2020-03-22,Met at open house`,ce=new Blob([ue],{type:"text/csv"}),ge=URL.createObjectURL(ce),Te=document.createElement("a");Te.href=ge,Te.download="contact_import_template.csv",Te.click(),URL.revokeObjectURL(ge)},children:[e.jsx(Vi,{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(je,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:C6t.map(ue=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(je,{className:"w-40 text-sm",children:[ue.label,ue.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(er,{value:_[ue.key]||"none",onValueChange:ce=>J(ue.key,ce),children:[e.jsx(Qs,{className:"w-48",children:e.jsx(tr,{placeholder:"Select column..."})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"-- Not mapped --"}),h.map(ce=>e.jsx(Et,{value:ce,children:ce},ce))]})]})]},ue.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(ue=>e.jsx(ct,{variant:w.includes(ue.id)?"default":"outline",className:"cursor-pointer",onClick:()=>ne(ue.id),children:ue.name},ue.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",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oi,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[de," valid"]})]}),oe>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:[oe," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/30",children:[e.jsx(Ct,{children:"First Name"}),e.jsx(Ct,{children:"Last Name"}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:"Phone"}),e.jsx(Ct,{children:"Status"})]})}),e.jsx(Bn,{children:M.slice(0,100).map((ue,ce)=>e.jsxs(ws,{children:[e.jsx(ot,{children:ue.first_name}),e.jsx(ot,{children:ue.last_name}),e.jsx(ot,{children:ue.email}),e.jsx(ot,{children:ue.phone}),e.jsx(ot,{children:ue.isValid?e.jsx(ct,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(ct,{variant:"destructive",children:ue.error||"Invalid"})})]},ce))})]}),M.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",M.length," contacts"]})]})]}),i==="result"&&L&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(oi,{className:"h-12 w-12 mx-auto text-green-500"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground",children:[L.created," contact(s) created, ",L.updated," updated"]}),L.failed>0&&e.jsxs("p",{className:"text-destructive",children:[L.failed," failed to import"]})]}),e.jsxs(Hn,{children:[i==="upload"&&e.jsx(Y,{variant:"outline",onClick:V,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"outline",onClick:$,children:"Back"}),e.jsx(Y,{onClick:ie,disabled:!_.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"outline",onClick:()=>d("mapping"),children:"Back"}),e.jsx(Y,{onClick:ee,disabled:E||de===0,children:E?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${de} Contact${de!==1?"s":""}`})]}),i==="result"&&e.jsx(Y,{onClick:V,children:"Done"})]})]})})};function T6t(){return"contacts"in navigator&&"ContactsManager"in window}function A6t(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="",h="";for(const f of a){const g=f.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))&&!h&&(h=g.substring(g.indexOf(":")+1).split(";").map(j=>j.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:d,address:h})}return s}function E6t({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Ys(),{data:a}=of(),o=M1e(),l=T.useRef(null),[i,d]=T.useState("choose"),[h,f]=T.useState([]),[g,v]=T.useState(new Set),[_,j]=T.useState(0),[w,k]=T.useState(0),M=T6t(),S=T.useCallback(J=>{if(!a)return J;const ne=new Set(a.filter(ee=>ee.email).map(ee=>ee.email.toLowerCase())),ie=new Set(a.filter(ee=>ee.phone).map(ee=>ee.phone.replace(/\D/g,"")));return J.map(ee=>{var ue,ce;const de=(ue=ee.email)==null?void 0:ue.toLowerCase(),oe=(ce=ee.phone)==null?void 0:ce.replace(/\D/g,"");return de&&ne.has(de)?{...ee,isDuplicate:!0,duplicateField:"email"}:oe&&oe.length>=7&&ie.has(oe)?{...ee,isDuplicate:!0,duplicateField:"phone"}:ee})},[a]),E=async()=>{try{const J=["name","email","tel","address"],ne=await navigator.contacts.select(J,{multiple:!0});if(!ne||ne.length===0)return;const ie=ne.map(oe=>{var ge,Te,ve,ye;const ce=(((ge=oe.name)==null?void 0:ge[0])||"").split(" ");return{first_name:ce[0]||"",last_name:ce.slice(1).join(" "),email:((Te=oe.email)==null?void 0:Te[0])||"",phone:((ve=oe.tel)==null?void 0:ve[0])||"",address:(ye=oe.address)!=null&&ye[0]?[oe.address[0].streetAddress,oe.address[0].city,oe.address[0].region,oe.address[0].postalCode].filter(Boolean).join(", "):""}}),ee=S(ie);f(ee);const de=new Set;ee.forEach((oe,ue)=>{oe.isDuplicate||de.add(ue)}),v(de),d("preview")}catch(J){console.error("Contact Picker error:",J),pn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},D=J=>{var ee;const ne=(ee=J.target.files)==null?void 0:ee[0];if(!ne)return;const ie=new FileReader;ie.onload=de=>{var Te;const oe=(Te=de.target)==null?void 0:Te.result,ue=A6t(oe);if(ue.length===0){pn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const ce=S(ue);f(ce);const ge=new Set;ce.forEach((ve,ye)=>{ve.isDuplicate||ge.add(ye)}),v(ge),d("preview")},ie.readAsText(ne),l.current&&(l.current.value="")},L=async()=>{const J=h.filter((ie,ee)=>g.has(ee));if(J.length===0)return;d("importing");let ne=0;for(const ie of J)try{await o.mutateAsync({first_name:ie.first_name,last_name:ie.last_name||void 0,email:ie.email||void 0,phone:ie.phone||void 0,address:ie.address||void 0}),ne++,k(Math.round(ne/J.length*100))}catch(ee){console.error(`Failed to import ${ie.first_name} ${ie.last_name}:`,ee)}j(ne),d("done")},B=J=>{v(ne=>{const ie=new Set(ne);return ie.has(J)?ie.delete(J):ie.add(J),ie})},$=()=>{g.size===h.length?v(new Set):v(new Set(h.map((J,ne)=>ne)))},V=J=>{J||(d("choose"),f([]),v(new Set),j(0),k(0),i==="done"&&r()),s(J)},W=h.filter(J=>J.isDuplicate).length,G=g.size;return e.jsx(js,{open:t,onOpenChange:V,children:e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(n0,{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(en,{children:"Add contacts from your phone directly into Agent OS."})]}),i==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[M&&e.jsxs(Y,{onClick:E,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(n0,{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:[M&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),M&&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(Y,{variant:M?"outline":"default",onClick:()=>{var J;return(J=l.current)==null?void 0:J.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(ji,{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:M?"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:D,className:"hidden"}),!M&&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:[h.length," contact",h.length!==1?"s":""," found",W>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",W," already exist)"]})]}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:$,children:g.size===h.length?"Deselect All":"Select All"})]}),e.jsx(po,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:h.map((J,ne)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${J.isDuplicate?"opacity-60":""}`,onClick:()=>B(ne),children:[e.jsx(Do,{checked:g.has(ne),onCheckedChange:()=>B(ne),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:[J.first_name," ",J.last_name]}),J.isDuplicate&&e.jsxs(ct,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",J.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[J.phone&&e.jsx("div",{children:J.phone}),J.email&&e.jsx("div",{className:"truncate",children:J.email})]})]})]},ne))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>d("choose"),children:"Back"}),e.jsxs(Y,{onClick:L,disabled:G===0,children:["Import ",G," Contact",G!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(Us,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${w}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(ma,{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(Y,{onClick:()=>V(!1),className:"mt-2",children:"Done"})]})]})})}function zoe(){const t=lo();return zt({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await Z.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function I6t(t){return zt({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await Z.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function K_e(){const t=vs(),s=lo();return Wt({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await Z.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 P6t(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.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 L6t(){const t=vs();return Wt({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 Z.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 IHe(){const t=vs();return Wt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await Z.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 D6t(){const t=vs();return Wt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await Z.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 O6t(){const t=lo();return zt({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await Z.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 R6t({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const{data:i}=Ag(),d=T1e(),h=vs(),{isGmailConnected:f}=MN(),{data:g}=zoe(),v=K_e(),_=IHe(),[j,w]=T.useState(!1),[k,M]=T.useState(!1),[S,E]=T.useState(!1),[D,L]=T.useState(""),B=t.size;if(B===0)return null;const $=async ee=>{w(!0);try{const oe=Array.from(t).map(ce=>({contact_id:ce,relationship_type_id:ee})),{error:ue}=await Z.from("innercircle_contact_tags").upsert(oe,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(ue)throw ue;h.invalidateQueries({queryKey:["innercircle-contacts"]}),h.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:`Assigned type to ${B} contacts`}),r()}catch(de){pn({title:"Error assigning type",description:de.message,variant:"destructive"})}finally{w(!1)}},V=async ee=>{w(!0);try{const de=Array.from(t);for(const oe of de)try{await _.mutateAsync({contactId:oe,tagId:ee})}catch{}h.invalidateQueries({queryKey:["all-contact-custom-tags"]}),pn({title:`Tagged ${B} contacts`}),E(!1),L("")}catch(de){pn({title:"Error adding tags",description:de.message,variant:"destructive"})}finally{w(!1)}},W=async()=>{if(D.trim()){w(!0);try{const ee=await v.mutateAsync({name:D.trim()});await V(ee.id)}catch(ee){pn({title:"Error creating tag",description:ee.message,variant:"destructive"}),w(!1)}}},G=(g==null?void 0:g.filter(ee=>ee.name.toLowerCase().includes(D.toLowerCase())))||[],J=g==null?void 0:g.find(ee=>ee.name.toLowerCase()===D.trim().toLowerCase()),ne=()=>{const ee=s.filter(ve=>t.has(ve.id)),de=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],oe=ee.map(ve=>{var ye;return[ve.first_name,ve.last_name||"",ve.email||"",ve.phone||"",ve.address||"",ve.birthday||"",ve.home_anniversary||"",ve.notes||"",((ye=ve.tags)==null?void 0:ye.map(Se=>{var Ke;return(Ke=Se.relationship_type)==null?void 0:Ke.name}).join("; "))||""]}),ue=[de.join(","),...oe.map(ve=>ve.map(ye=>`"${(ye||"").replace(/"/g,'""')}"`).join(","))].join(` `),ce=new Blob([ue],{type:"text/csv"}),ge=URL.createObjectURL(ce),Te=document.createElement("a");Te.href=ge,Te.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,Te.click(),URL.revokeObjectURL(ge),pn({title:`Exported ${B} contacts`})},ie=async()=>{if(confirm(`Are you sure you want to delete ${B} contacts? This cannot be undone.`)){w(!0);try{const ee=Array.from(t);for(const de of ee)await d.mutateAsync(de);r()}catch(ee){pn({title:"Error deleting contacts",description:ee.message,variant:"destructive"})}finally{w(!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(ct,{variant:"secondary",className:"font-semibold",children:[B," selected"]}),e.jsxs(er,{onValueChange:$,disabled:j,children:[e.jsx(Qs,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Kp,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(Js,{children:i==null?void 0:i.filter(ee=>ee.active).map(ee=>e.jsx(Et,{value:ee.id,children:ee.name},ee.id))})]}),e.jsxs(_l,{open:S,onOpenChange:E,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",size:"sm",disabled:j,children:[e.jsx(ar,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(nl,{className:"w-56 p-2",align:"start",children:[e.jsx(Be,{placeholder:"Search or create tag...",value:D,onChange:ee=>L(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&D.trim()&&!J?(ee.preventDefault(),W()):ee.key==="Enter"&&J&&(ee.preventDefault(),V(J.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[G.map(ee=>e.jsxs("button",{onClick:()=>V(ee.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:ee.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:ee.name})]},ee.id)),D.trim()&&!J&&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(ar,{className:"h-3.5 w-3.5"}),'Create "',D.trim(),'"']}),G.length===0&&!D.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>M(!0),disabled:j,children:[e.jsx(zr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),a&&n&&e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:j,children:[e.jsx(Nx,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:j,children:[e.jsx(Zy,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:ne,disabled:j,children:[e.jsx(Vi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:ie,disabled:j,className:"text-destructive hover:text-destructive",children:[e.jsx(Ir,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Xr,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(Roe,{open:k,onOpenChange:M,bulkContacts:Array.from(t).map(ee=>{const de=s.find(oe=>oe.id===ee);return de?{id:de.id,first_name:de.first_name,last_name:de.last_name,email:de.email||""}:null}).filter(ee=>ee!==null&&ee.email!==""),onSendComplete:()=>{M(!1),r()}})]})}function $Me({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=Yr(),h=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(Rp,{className:"h-4 w-4"})})}),e.jsxs(ju,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(Va,{onClick:()=>d(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Ha,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Va,{onClick:()=>d(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(Wn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Va,{onClick:()=>d(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Gi,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),e.jsxs(Va,{onClick:()=>n(t.id,h),children:[e.jsx(ep,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Va,{onClick:()=>a(t.id),children:[e.jsx(Nx,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Va,{onClick:()=>l(t.id),children:[e.jsx(Zy,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Va,{onClick:()=>s(t),children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Va,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(Ir,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function F6t(){const{user:t}=Ys();return zt({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function z6t(){const t=vs(),{user:s}=Ys();return Wt({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await Z.from("contact_smart_lists").insert({owner_user_id:s.id,name:r,filters:n,sort_by:a}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),pn({title:"Smart filter saved"})},onError:r=>{pn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function B6t(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),pn({title:"Smart filter deleted"})}})}function $6t({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=F6t(),a=z6t(),o=B6t(),[l,i]=T.useState(!1),[d,h]=T.useState(""),f=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}),h(""),i(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Jy,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(ct,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Gc,{className:"h-3.5 w-3.5"})]})}),e.jsxs(ju,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(v=>e.jsxs(Va,{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(Y,{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(Ir,{className:"h-3 w-3 text-destructive"})})]},v.id)),e.jsx(eN,{})]}):e.jsx(Va,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),f&&e.jsxs(Va,{onClick:()=>i(!0),children:[e.jsx(_E,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(js,{open:l,onOpenChange:i,children:e.jsxs(_s,{className:"max-w-sm",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Be,{placeholder:"e.g. Buyers in 40205",value:d,onChange:v=>h(v.target.value),onKeyDown:v=>v.key==="Enter"&&g(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(Y,{onClick:g,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function aE(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 qMe({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=Yr(),i=UMe(t,"birthday",7),d=UMe(s,"anniversary",7);if(!i&&!d)return null;const h=(f,g)=>{g.stopPropagation();const v=new URLSearchParams;n&&v.set("contactId",n),a&&v.set("name",a),o&&v.set("address",o),f==="home_anniversary"&&s&&v.set("date",s),v.set("cardType",f),l(`/mission-control/card-studio?${v.toString()}`)};return e.jsxs("div",{className:$t("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(ct,{variant:"secondary",className:$t("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:f=>h("birthday",f),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(zr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(ct,{variant:"secondary",className:$t("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:f=>h("home_anniversary",f),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(zr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function VMe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(ct,{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 U6t(){const t=lo();return zt({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await Z.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 q6t({contactId:t,compact:s=!1}){const{data:r}=zoe(),{data:n}=I6t(t),a=K_e(),o=IHe(),l=D6t(),[i,d]=T.useState(!1),[h,f]=T.useState(""),g=T.useRef(null),v=new Set((n==null?void 0:n.map(M=>M.tag_id))||[]),_=(r==null?void 0:r.filter(M=>M.name.toLowerCase().includes(h.toLowerCase())))||[],j=r==null?void 0:r.find(M=>M.name.toLowerCase()===h.trim().toLowerCase()),w=async M=>{v.has(M.id)?await l.mutateAsync({contactId:t,tagId:M.id}):await o.mutateAsync({contactId:t,tagId:M.id})},k=async()=>{if(!(!h.trim()||j))try{const M=await a.mutateAsync({name:h.trim()});await o.mutateAsync({contactId:t,tagId:M.id}),f("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(M=>{var S,E,D;return e.jsxs(ct,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((S=M.tag)==null?void 0:S.color)||"#6366F1",color:((E=M.tag)==null?void 0:E.color)||"#6366F1"},children:[e.jsx(Kp,{className:"h-2.5 w-2.5"}),(D=M.tag)==null?void 0:D.name,e.jsx("button",{onClick:L=>{L.stopPropagation(),l.mutate({contactId:t,tagId:M.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Xr,{className:"h-2.5 w-2.5"})})]},M.id)}),e.jsxs(_l,{open:i,onOpenChange:d,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:M=>M.stopPropagation(),children:[e.jsx(ar,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(nl,{className:"w-56 p-2",align:"start",onClick:M=>M.stopPropagation(),children:[e.jsx(Be,{ref:g,placeholder:"Search or create tag...",value:h,onChange:M=>f(M.target.value),onKeyDown:M=>{M.key==="Enter"&&h.trim()&&!j?(M.preventDefault(),k()):M.key==="Enter"&&j&&!v.has(j.id)&&(M.preventDefault(),w(j))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[_.map(M=>e.jsxs("button",{onClick:()=>w(M),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:M.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:M.name}),v.has(M.id)&&e.jsx(ma,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},M.id)),h.trim()&&!j&&e.jsxs("button",{onClick:k,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(ar,{className:"h-3.5 w-3.5"}),'Create "',h.trim(),'"']}),_.length===0&&!h.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create your first tag"})]})]})]})]})}function HMe({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(ct,{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 g8=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function V6t({open:t,onOpenChange:s}){const{data:r,isLoading:n}=zoe(),a=K_e(),o=L6t(),l=P6t(),[i,d]=T.useState(""),[h,f]=T.useState(g8[0]),[g,v]=T.useState(null),[_,j]=T.useState(""),[w,k]=T.useState(""),M=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:h}),d(""),f(g8[0]),pn({title:"Tag created"})}catch(L){pn({title:"Error",description:L.message,variant:"destructive"})}},S=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:w}),v(null),pn({title:"Tag updated"})}catch(B){pn({title:"Error",description:B.message,variant:"destructive"})}},E=async(L,B)=>{if(confirm(`Delete tag "${B}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),pn({title:"Tag deleted"})}catch($){pn({title:"Error",description:$.message,variant:"destructive"})}},D=L=>{v(L.id),j(L.name),k(L.color)};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{placeholder:"New tag name...",value:i,onChange:L=>d(L.target.value),onKeyDown:L=>L.key==="Enter"&&M(),className:"flex-1 h-9"}),e.jsxs(Y,{size:"sm",onClick:M,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:g8.map(L=>e.jsx("button",{onClick:()=>f(L),className:`h-6 w-6 rounded-full border-2 transition-transform ${h===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:g8.map(B=>e.jsx("button",{onClick:()=>k(B),className:`h-5 w-5 rounded-full border-2 ${w===B?"border-foreground":"border-transparent"}`,style:{backgroundColor:B}},B))}),e.jsx(Be,{value:_,onChange:B=>j(B.target.value),onKeyDown:B=>B.key==="Enter"&&S(L.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(Y,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(L.id),children:e.jsx(ma,{className:"h-4 w-4 text-primary"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>v(null),children:e.jsx(Xr,{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(Y,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>D(L),children:e.jsx(Xa,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{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:()=>E(L.id,L.name),children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function H6t(){var nn;const t=Yr(),[s]=Oc(),{user:r}=Ys(),n=Q3(),a=vs(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:d,isLoading:h}=P1e(),{data:f}=Ag(),{data:g}=U6t(),{data:v}=zoe(),{data:_}=O6t(),[j,w]=T.useState(new Set),[k,M]=T.useState("any"),S=M1e(),E=P9e(),D=T1e(),[L,B]=T.useState(""),[$,V]=T.useState(o||"all"),[W,G]=T.useState(l||"all"),[J,ne]=T.useState("date-added"),[ie,ee]=T.useState(i),[de,oe]=T.useState(null),[ue,ce]=T.useState(!1),[ge,Te]=T.useState(!1),[ve,ye]=T.useState(null),[Se,Ke]=T.useState(""),[Ae,Ee]=T.useState(new Set),[He,Ue]=T.useState(!1),[De,Ge]=T.useState(1),[wt,Ie]=T.useState(50),[st,he]=T.useState("my"),[We,et]=T.useState(!1),{data:Ye}=h_(),{addToLeadPond:ke}=YVe(Ye==null?void 0:Ye.teamId),at=!!((nn=Ye==null?void 0:Ye.team)!=null&&nn.lead_pond_enabled&&(Ye!=null&&Ye.teamId)),Fe=!!(Ye!=null&&Ye.teamId),[it,dt]=T.useState([]),[tt,ut]=T.useState(!1),xt=Qt=>{dt([Qt]),ut(!0)},_t=Qt=>{dt(Qt),ut(!0)},qe=Qt=>{Ye!=null&&Ye.teamId&&ke.mutate({contact_id:Qt,team_id:Ye.teamId})},Lt=Qt=>{Ye!=null&&Ye.teamId&&Qt.forEach(lr=>{ke.mutate({contact_id:lr,team_id:Ye.teamId})})},Rt=T.useCallback(Qt=>{Ue(!1),Ee(lr=>{const Vr=new Set(lr);return Vr.has(Qt)?Vr.delete(Qt):Vr.add(Qt),Vr})},[]);T.useEffect(()=>{if(!(r!=null&&r.id))return;const Qt=Z.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()=>{Z.removeChannel(Qt)}},[a,r==null?void 0:r.id]),T.useEffect(()=>{l&&G(l)},[l]);const[Kt,Xt]=T.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",notes:"",tagIds:[]});T.useEffect(()=>{i&&ee(!0)},[i]),T.useEffect(()=>{var Qt;de&&Xt({first_name:de.first_name||"",last_name:de.last_name||"",email:de.email||"",phone:de.phone||"",address:de.address||"",city:de.city||"",state:de.state||"",zip_code:de.zip_code||"",birthday:de.birthday||"",home_anniversary:de.home_anniversary||"",spouse_name:de.spouse_name||"",spouse_email:de.spouse_email||"",notes:de.notes||"",tagIds:((Qt=de.tags)==null?void 0:Qt.map(lr=>lr.relationship_type_id))||[]})},[de]);const ss=T.useMemo(()=>{if(!d)return[];let Qt=d.filter(lr=>{var cs,ka,zi;const Vr=L===""||`${lr.first_name} ${lr.last_name}`.toLowerCase().includes(L.toLowerCase())||((cs=lr.email)==null?void 0:cs.toLowerCase().includes(L.toLowerCase()))||((ka=lr.phone)==null?void 0:ka.includes(L)),Pr=$==="all"||((zi=lr.tags)==null?void 0:zi.some(li=>li.relationship_type_id===$)),on=j.size===0||(()=>{const li=(_==null?void 0:_.filter(Or=>Or.contact_id===lr.id).map(Or=>Or.tag_id))||[];return k==="any"?li.some(Or=>j.has(Or)):Array.from(j).every(Or=>li.includes(Or))})();return Vr&&Pr&&on});return W==="not-touched-90"?Qt=Qt.filter(lr=>{const Vr=lr.relationshipScore.daysSinceTouch;return Vr===null||Vr>90}):W==="at-risk"?Qt=Qt.filter(lr=>lr.relationshipScore.status==="at-risk"):W==="cooling"?Qt=Qt.filter(lr=>lr.relationshipScore.status==="cooling"):W==="warm"?Qt=Qt.filter(lr=>lr.relationshipScore.status==="warm"):W==="has-deal"?Qt=Qt.filter(lr=>g&&g[lr.id]):W==="no-deal"?Qt=Qt.filter(lr=>!g||!g[lr.id]):W==="open-house"&&(Qt=Qt.filter(lr=>lr.lead_source==="Open House")),Qt=[...Qt].sort((lr,Vr)=>{switch(J){case"important-dates":{const Pr=aE(lr.birthday),on=aE(Vr.birthday),cs=aE(lr.home_anniversary),ka=aE(Vr.home_anniversary),zi=[Pr,cs].filter(Or=>Or!==null).sort((Or,Oi)=>(Or??1/0)-(Oi??1/0))[0]??1/0,li=[on,ka].filter(Or=>Or!==null).sort((Or,Oi)=>(Or??1/0)-(Oi??1/0))[0]??1/0;return zi-li}case"last-touched":{const Pr=lr.relationshipScore.lastTouchDate,on=Vr.relationshipScore.lastTouchDate;return!Pr&&!on?0:Pr?on?new Date(Pr).getTime()-new Date(on).getTime():1:-1}case"next-touch":{const Pr=lr.relationshipScore.daysSinceTouch,on=Vr.relationshipScore.daysSinceTouch;return Pr===null&&on===null?0:Pr===null?-1:on===null?1:on-Pr}case"score":return lr.relationshipScore.score-Vr.relationshipScore.score;case"date-added":{const Pr=lr.created_at,on=Vr.created_at;return!Pr&&!on?0:Pr?on?new Date(on).getTime()-new Date(Pr).getTime():-1:1}case"name":default:{const Pr=`${lr.first_name||""} ${lr.last_name||""}`.toLowerCase(),on=`${Vr.first_name||""} ${Vr.last_name||""}`.toLowerCase();return Pr.localeCompare(on)}}}),Qt},[d,L,$,j,k,W,J,g,_]),fs=ss.length,fr=Math.max(1,Math.ceil(fs/wt)),yt=Math.min(De,fr),bs=T.useMemo(()=>{const Qt=(yt-1)*wt;return ss.slice(Qt,Qt+wt)},[ss,yt,wt]);T.useEffect(()=>{Ge(1)},[L,$,j,k,W,J]);const gr=T.useCallback(()=>{Ue(!1),Ee(Qt=>Qt.size>0?new Set:new Set(bs.map(lr=>lr.id)))},[bs]),Br=T.useCallback(()=>{Ue(!0),Ee(new Set(ss.map(Qt=>Qt.id)))},[ss]),na=T.useCallback((Qt,lr)=>{B(Qt.search||""),V(Qt.type||"all"),G(Qt.status||"all"),ne(lr||"name")},[]),za=()=>{Xt({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",notes:"",tagIds:[]})},go=async Qt=>{Qt.preventDefault(),de?(await E.mutateAsync({id:de.id,...Kt}),oe(null)):(await S.mutateAsync(Kt),ee(!1)),za()},Ia=async Qt=>{confirm("Are you sure you want to delete this contact?")&&await D.mutateAsync(Qt)};return e.jsx(Vs,{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"})]}),Ye&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>he("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${st==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(Ye.team.contact_visibility==="full_team"||Ye.team.contact_visibility==="leader_only"&&Ye.role==="team_leader")&&e.jsxs("button",{onClick:()=>he("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${st==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(br,{className:"h-3.5 w-3.5"}),"Team"]}),Ye.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>he("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${st==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Nx,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(hc,{className:"h-4 w-4 mr-1"}),"Back"]})}),st==="team"?e.jsx(D_e,{}):st==="lead-pond"&&Ye?e.jsx(O_e,{teamId:Ye.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{children:e.jsx($e,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name, email, or phone...",value:L,onChange:Qt=>B(Qt.target.value),className:"pl-9"})]}),e.jsxs(er,{value:$,onValueChange:V,children:[e.jsx(Qs,{className:"w-[160px]",children:e.jsx(tr,{placeholder:"Filter by type"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Types"}),f==null?void 0:f.filter(Qt=>Qt.active).map(Qt=>e.jsx(Et,{value:Qt.id,children:Qt.name},Qt.id))]})]}),v&&v.length>0&&e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:"w-[180px] justify-start text-sm h-10",children:[e.jsx(Kp,{className:"h-4 w-4 mr-2 shrink-0 text-muted-foreground"}),j.size===0?"Filter by Tags":`${j.size} tag${j.size>1?"s":""} selected`]})}),e.jsx(nl,{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:()=>M("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${k==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>M("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${k==="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(Qt=>{const lr=j.has(Qt.id);return e.jsxs("button",{onClick:()=>{w(Vr=>{const Pr=new Set(Vr);return Pr.has(Qt.id)?Pr.delete(Qt.id):Pr.add(Qt.id),Pr})},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(Do,{checked:lr,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Qt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Qt.name})]},Qt.id)})}),j.size>0&&e.jsx(Y,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>w(new Set),children:"Clear tags"})]})})]}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-10 w-10 shrink-0",onClick:()=>et(!0),title:"Manage Tags",children:e.jsx(Ic,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs(er,{value:W,onValueChange:G,children:[e.jsx(Qs,{className:"w-[160px]",children:e.jsx(tr,{placeholder:"Filter by status"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Status"}),e.jsx(Et,{value:"warm",children:"🟢 Warm"}),e.jsx(Et,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(Et,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(Et,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(Et,{value:"no-deal",children:"📭 No Deal"}),e.jsx(Et,{value:"open-house",children:"🏠 Open House"})]})]}),e.jsxs(er,{value:J,onValueChange:ne,children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hp,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(tr,{placeholder:"Sort by"})]})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"name",children:"Name (A-Z)"}),e.jsx(Et,{value:"important-dates",children:"Important Dates"}),e.jsx(Et,{value:"last-touched",children:"Last Touched"}),e.jsx(Et,{value:"next-touch",children:"Next Touch Due"}),e.jsx(Et,{value:"score",children:"Relationship Score"}),e.jsx(Et,{value:"date-added",children:"Date Added"})]})]}),e.jsx($6t,{currentFilters:{search:L,type:$,status:W},currentSortBy:J,onApplySmartList:na}),e.jsxs(Y,{onClick:()=>ee(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(Y,{variant:"outline",onClick:()=>ce(!0),children:[e.jsx(ji,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(Y,{variant:"outline",onClick:()=>Te(!0),children:[e.jsx(n0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]})]})})}),e.jsx(R6t,{selectedIds:Ae,contacts:ss,onClearSelection:()=>{Ee(new Set),Ue(!1)},showLeadPondAction:at,onSendToLeadPond:Lt,showTransferAction:Fe,onTransfer:_t}),Ae.size>0&&Ae.size===bs.length&&!He&&fs>wt&&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 ",bs.length," contacts on this page are selected."]}),e.jsxs(Y,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:Br,children:["Select all ",fs.toLocaleString()," matching contacts"]})]}),He&&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 ",fs.toLocaleString()," matching contacts are selected.",e.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Ee(new Set),Ue(!1)},children:"Clear selection"})]}),n?e.jsx("div",{className:"space-y-3",children:h?e.jsx(Oe,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):ss.length===0?e.jsx(Oe,{className:"p-6 text-center text-muted-foreground",children:L||$!=="all"||W!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):bs.map(Qt=>{var Vr;const{relationshipScore:lr}=Qt;return e.jsx(Oe,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Pr=new URLSearchParams;L&&Pr.set("search",L),$!=="all"&&Pr.set("type",$),W!=="all"&&Pr.set("filter",W);const on=Pr.toString();t(`/mission-control/contacts/${Qt.id}${on?`?${on}`:""}`)},children:e.jsx($e,{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:[Qt.first_name," ",Qt.last_name]}),e.jsx(Ri,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Qt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(zr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:Qt.email})]}),Qt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ha,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Qt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(Whe,{score:lr,size:"sm"}),e.jsx(Wge,{contact:Qt}),Qt.lead_source&&e.jsx(ct,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:Qt.lead_source}),(Vr=Qt.tags)==null?void 0:Vr.map(Pr=>{var on;return e.jsx(ct,{variant:"secondary",className:"text-xs",children:(on=Pr.relationship_type)==null?void 0:on.name},Pr.id)}),e.jsx(HMe,{contactId:Qt.id,tags:_==null?void 0:_.filter(Pr=>Pr.contact_id===Qt.id)}),e.jsx(VMe,{deal:g==null?void 0:g[Qt.id]})]}),e.jsx(qMe,{birthday:Qt.birthday,homeAnniversary:Qt.home_anniversary,className:"mb-2",contactId:Qt.id,contactName:`${Qt.first_name}${Qt.last_name?" "+Qt.last_name:""}`,contactAddress:[Qt.address,Qt.city,Qt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[lr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ca,{className:"h-3 w-3"}),Bs(new Date(lr.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Qt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),Bs(new Date(Qt.birthday),"MMM d")]}),Qt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Zn,{className:"h-3 w-3"}),Bs(new Date(Qt.home_anniversary),"MMM d")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Pr=>Pr.stopPropagation(),children:e.jsx($Me,{contact:Qt,onEdit:oe,onDelete:Ia,onSnooze:(Pr,on)=>{ye(Pr),Ke(on)},showLeadPondAction:at,onSendToLeadPond:qe,showTransferAction:Fe,onTransfer:xt})})]})})},Qt.id)})}):e.jsx(Oe,{children:e.jsx($e,{className:"p-0 overflow-x-auto",children:e.jsxs(Fn,{className:"min-w-[800px]",children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-[40px]",children:e.jsx(Do,{checked:bs.length>0&&bs.every(Qt=>Ae.has(Qt.id)),onCheckedChange:()=>gr()})}),e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{children:"Score"}),e.jsx(Ct,{children:"Contact Info"}),e.jsx(Ct,{children:"Types / Pipeline"}),e.jsx(Ct,{children:"Last Contact"}),e.jsx(Ct,{children:"Important Dates"}),e.jsx(Ct,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Bn,{children:h?e.jsx(ws,{children:e.jsx(ot,{colSpan:9,className:"text-center py-8",children:"Loading contacts..."})}):ss.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:L||$!=="all"||W!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):bs.map(Qt=>{var Pr;const{relationshipScore:lr}=Qt,Vr=g==null?void 0:g[Qt.id];return e.jsxs(ws,{className:`cursor-pointer hover:bg-accent/50 ${Ae.has(Qt.id)?"bg-accent/30":""}`,onClick:()=>{const on=new URLSearchParams;L&&on.set("search",L),$!=="all"&&on.set("type",$),W!=="all"&&on.set("status",W);const cs=on.toString();t(`/mission-control/contacts/${Qt.id}${cs?`?${cs}`:""}`)},children:[e.jsx(ot,{onClick:on=>on.stopPropagation(),children:e.jsx(Do,{checked:Ae.has(Qt.id),onCheckedChange:()=>Rt(Qt.id)})}),e.jsxs(ot,{className:"font-medium",children:[Qt.first_name," ",Qt.last_name]}),e.jsx(ot,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(Whe,{score:lr,size:"sm"}),e.jsx(Wge,{contact:Qt})]})}),e.jsx(ot,{children:e.jsx(Whe,{score:lr,size:"sm",showScore:!0})}),e.jsx(ot,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Qt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(zr,{className:"h-3 w-3"}),Qt.email]}),Qt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Ha,{className:"h-3 w-3"}),Qt.phone]})]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[Qt.lead_source&&e.jsx(ct,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:Qt.lead_source}),(Pr=Qt.tags)==null?void 0:Pr.map(on=>{var cs;return e.jsx(ct,{variant:"secondary",className:"text-xs",children:(cs=on.relationship_type)==null?void 0:cs.name},on.id)}),e.jsx(HMe,{contactId:Qt.id,tags:_==null?void 0:_.filter(on=>on.contact_id===Qt.id)}),e.jsx(VMe,{deal:Vr})]})}),e.jsx(ot,{children:e.jsx("div",{className:"text-sm",children:lr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ca,{className:"h-3 w-3"}),Bs(new Date(lr.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(ot,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(qMe,{birthday:Qt.birthday,homeAnniversary:Qt.home_anniversary,contactId:Qt.id,contactName:`${Qt.first_name}${Qt.last_name?" "+Qt.last_name:""}`,contactAddress:[Qt.address,Qt.city,Qt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Qt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),Bs(new Date(Qt.birthday),"MMM d")]}),Qt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Zn,{className:"h-3 w-3"}),Bs(new Date(Qt.home_anniversary),"MMM d")]})]})]})}),e.jsx(ot,{children:e.jsx($Me,{contact:Qt,onEdit:oe,onDelete:Ia,onSnooze:(on,cs)=>{ye(on),Ke(cs)},showLeadPondAction:at,onSendToLeadPond:qe,showTransferAction:Fe,onTransfer:xt})})]},Qt.id)})})]})})}),fs>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 ",(yt-1)*wt+1,"–",Math.min(yt*wt,fs)," of ",fs.toLocaleString()," contacts"]}),e.jsxs(er,{value:String(wt),onValueChange:Qt=>{Ie(Number(Qt)),Ge(1)},children:[e.jsx(Qs,{className:"w-[80px] h-8",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"50",children:"50"}),e.jsx(Et,{value:"100",children:"100"}),e.jsx(Et,{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(Y,{variant:"outline",size:"sm",disabled:yt<=1,onClick:()=>Ge(1),children:"First"}),e.jsx(Y,{variant:"outline",size:"sm",disabled:yt<=1,onClick:()=>Ge(Qt=>Qt-1),children:e.jsx(hc,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",yt," of ",fr]}),e.jsx(Y,{variant:"outline",size:"sm",disabled:yt>=fr,onClick:()=>Ge(Qt=>Qt+1),children:e.jsx(Ri,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"outline",size:"sm",disabled:yt>=fr,onClick:()=>Ge(fr),children:"Last"})]})]}),e.jsx(js,{open:ie||!!de,onOpenChange:Qt=>{Qt||(ee(!1),oe(null),za())},children:e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:de?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:go,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"first_name",children:"First Name *"}),e.jsx(Be,{id:"first_name",value:Kt.first_name,onChange:Qt=>Xt({...Kt,first_name:Qt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Be,{id:"last_name",value:Kt.last_name,onChange:Qt=>Xt({...Kt,last_name:Qt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"email",children:"Email"}),e.jsx(Be,{id:"email",type:"email",value:Kt.email,onChange:Qt=>Xt({...Kt,email:Qt.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"phone",children:"Phone"}),e.jsx(Be,{id:"phone",value:Kt.phone,onChange:Qt=>Xt({...Kt,phone:Qt.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"address",children:"Address"}),e.jsx(Be,{id:"address",value:Kt.address,onChange:Qt=>Xt({...Kt,address:Qt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"city",children:"City"}),e.jsx(Be,{id:"city",value:Kt.city,onChange:Qt=>Xt({...Kt,city:Qt.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"state",children:"State"}),e.jsx(Be,{id:"state",value:Kt.state,onChange:Qt=>Xt({...Kt,state:Qt.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Be,{id:"zip_code",value:Kt.zip_code,onChange:Qt=>Xt({...Kt,zip_code:Qt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Be,{id:"birthday",type:"date",value:Kt.birthday,onChange:Qt=>Xt({...Kt,birthday:Qt.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Be,{id:"home_anniversary",type:"date",value:Kt.home_anniversary,onChange:Qt=>Xt({...Kt,home_anniversary:Qt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"spouse_name",children:"Spouse/Partner Name"}),e.jsx(Be,{id:"spouse_name",value:Kt.spouse_name,onChange:Qt=>Xt({...Kt,spouse_name:Qt.target.value}),placeholder:"Spouse/partner name"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"spouse_email",children:"Spouse/Partner Email"}),e.jsx(Be,{id:"spouse_email",type:"email",value:Kt.spouse_email,onChange:Qt=>Xt({...Kt,spouse_email:Qt.target.value}),placeholder:"Spouse/partner email"})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:f==null?void 0:f.filter(Qt=>Qt.active).map(Qt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Do,{checked:Kt.tagIds.includes(Qt.id),onCheckedChange:lr=>{Xt(lr?{...Kt,tagIds:[...Kt.tagIds,Qt.id]}:{...Kt,tagIds:Kt.tagIds.filter(Vr=>Vr!==Qt.id)})}}),e.jsx("span",{className:"text-sm",children:Qt.name})]},Qt.id))})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"notes",children:"Notes"}),e.jsx(Rr,{id:"notes",value:Kt.notes,onChange:Qt=>Xt({...Kt,notes:Qt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>{ee(!1),oe(null),za()},children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:S.isPending||E.isPending,children:[de?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(M6t,{open:ue,onOpenChange:ce,relationshipTypes:(f==null?void 0:f.filter(Qt=>Qt.active))||[],onSuccess:()=>{ce(!1)}}),e.jsx(E6t,{open:ge,onOpenChange:Te,onComplete:()=>Te(!1)}),e.jsx(Ooe,{open:!!ve,onOpenChange:Qt=>{Qt||ye(null)},contactId:ve||"",contactName:Se}),e.jsx(V6t,{open:We,onOpenChange:et}),e.jsx(XVe,{open:tt,onOpenChange:ut,contactIds:it,contactNames:it.map(Qt=>{const lr=ss.find(Vr=>Vr.id===Qt);return lr?`${lr.first_name} ${lr.last_name||""}`.trim():""}),onComplete:()=>{dt([]),Ee(new Set),Ue(!1)}})]})]})})}function W6t(){return zt({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await Z.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function G6t(t){return zt({queryKey:["video-scripts",t],queryFn:async()=>{let s=Z.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 K6t(){const{user:t}=Ys();return zt({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await Z.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 Z6t(){const{user:t}=Ys(),s=vs();return Wt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await Z.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 Y6t(t){const{user:s}=Ys();return zt({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=Z.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 X6t(t){return zt({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await Z.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 TN(){const{user:t}=Ys(),s=vs();return Wt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await Z.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 Q6t(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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 J6t(){const t=vs();return Wt({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 Z.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 Z.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await Z.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 Boe(){const{user:t}=Ys();return zt({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await Z.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 PHe(){const{data:t,isLoading:s}=Boe(),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 sL(t){const{data:s,error:r}=await Z.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function rL(t){const{data:s,error:r}=await Z.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function X5(t){const{data:s,error:r}=await Z.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function eLt(){const{user:t}=Ys(),s=vs();return Wt({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await Z.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 Z.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 tLt(t){return zt({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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 sLt({videoId:t}){var l;const{data:s,isLoading:r,error:n}=X6t(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"w-full aspect-video rounded-lg"}),e.jsx(ys,{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(Lu,{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 rLt({contactId:t}){const s=Yr(),[r,n]=T.useState(!1),{data:a,isLoading:o}=zt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:g,error:v}=await Z.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 Z.from("deal_tasks").update({status:_,completed_at:_==="done"?new Date().toISOString():null}).eq("id",g),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=zt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:g,error:v}=await Z.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:"🟢"},h=(a==null?void 0:a.filter(g=>g.status!=="done"))||[],f=(a==null?void 0:a.filter(g=>g.status==="done"))||[];return e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx(ma,{className:"h-4 w-4"}),"Tasks",h.length>0&&e.jsx(ct,{variant:"secondary",className:"text-xs",children:h.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(ar,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx($e,{className:"space-y-1",children:o?e.jsx(ys,{className:"h-8 w-full"}):h.length===0&&f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tasks yet"}):e.jsxs(e.Fragment,{children:[h.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:Bs(new Date(g.due_date),"MMM d")})]},g.id)),f.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:[f.length," completed"]})})]})}),r&&e.jsx(nLt,{contactId:t,open:r,onOpenChange:g=>{n(g),g||i()}})]})}function nLt({contactId:t,open:s,onOpenChange:r}){const[n,a]=T.useState(""),[o,l]=T.useState("medium"),[i,d]=T.useState(),{data:h}=zt({queryKey:["session"],queryFn:async()=>{const{data:g}=await Z.auth.getSession();return g.session}}),f=async()=>{var v;if(!n.trim()||!((v=h==null?void 0:h.user)!=null&&v.id))return;const{error:g}=await Z.from("deal_tasks").insert([{owner_user_id:h.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?Bs(i,"yyyy-MM-dd"):null}]);if(g){console.error("Task create error:",g);return}r(!1)};return e.jsx(js,{open:s,onOpenChange:r,children:e.jsxs(_s,{className:"sm:max-w-[400px]",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Title"}),e.jsx(Be,{value:n,onChange:g=>a(g.target.value),placeholder:"Task title...",onKeyDown:g=>g.key==="Enter"&&f()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{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(je,{children:"Due Date"}),e.jsx(Be,{type:"date",value:i?Bs(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(Y,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(Y,{onClick:f,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function aLt({contactId:t}){const s=Yr(),{data:r,isLoading:n}=zt({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await Z.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(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx(Fu,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx($e,{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(ct,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(ct,{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(qi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function iLt(){var st,he;const{contactId:t}=wl(),s=Yr(),[r]=Oc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=ywt(t||""),{data:d}=Ag(),{data:h}=A1e(),{data:f}=ooe(365),{data:g}=Foe(365),{data:v}=tLt(t),{contactsWithScores:_}=P1e(),j=P9e(),w=T1e(),k=D9e(),[M,S]=T.useState(!1),[E,D]=T.useState({}),[L,B]=T.useState(!1),[$,V]=T.useState(null),[W,G]=T.useState(""),[J,ne]=T.useState(null),[ie,ee]=T.useState(!1),[de,oe]=T.useState(null),{isGmailConnected:ue,gmailEmail:ce}=MN(),{data:ge}=zt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:We,error:et}=await Z.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(et)throw et;return We},enabled:!!t}),Te=We=>{if(!We)return null;const et=We.match(/Video ID:\s*([a-f0-9-]+)/i);return et?et[1]:null},ve=T.useMemo(()=>{if(!_)return[];let We=_.filter(et=>{var at,Fe,it;const Ye=n===""||`${et.first_name} ${et.last_name}`.toLowerCase().includes(n.toLowerCase())||((at=et.email)==null?void 0:at.toLowerCase().includes(n.toLowerCase()))||((Fe=et.phone)==null?void 0:Fe.includes(n)),ke=a==="all"||((it=et.tags)==null?void 0:it.some(dt=>dt.relationship_type_id===a));return Ye&&ke});return o==="not-touched-90"?We=We.filter(et=>{const Ye=et.relationshipScore.daysSinceTouch;return Ye===null||Ye>90}):o==="at-risk"?We=We.filter(et=>et.relationshipScore.status==="at-risk"):o==="cooling"?We=We.filter(et=>et.relationshipScore.status==="cooling"):o==="warm"&&(We=We.filter(et=>et.relationshipScore.status==="warm")),We.map(et=>et.id)},[_,n,a,o]),ye=ve.indexOf(t||""),Se=ye>0?ve[ye-1]:null,Ke=ye1&&ye!==-1,Ee=We=>{const et=new URLSearchParams;n&&et.set("search",n),a!=="all"&&et.set("type",a),o!=="all"&&et.set("status",o);const Ye=et.toString();return`/mission-control/contacts/${We}${Ye?`?${Ye}`:""}`},He=T.useMemo(()=>{const We=((f==null?void 0:f.filter(Ye=>Ye.contact_id===t))||[]).map(Ye=>{var at,Fe;const ke=Te(Ye.notes);return{id:Ye.id,type:"touch",completed_at:Ye.completed_at,name:((at=Ye.action_type)==null?void 0:at.name)||"Touch",color:((Fe=Ye.action_type)==null?void 0:Fe.color)||"#3B82F6",notes:Ye.notes,videoId:ke}}),et=((g==null?void 0:g.filter(Ye=>Ye.contact_id===t))||[]).map(Ye=>({id:Ye.id,type:"popby",completed_at:Ye.completed_at,name:"Pop-by",color:"#F97316",notes:Ye.notes,videoId:null}));return[...We,...et].sort((Ye,ke)=>new Date(ke.completed_at).getTime()-new Date(Ye.completed_at).getTime())},[f,g,t]),Ue=()=>{var We;l&&(D({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||"",notes:l.notes||"",tagIds:((We=l.tags)==null?void 0:We.map(et=>et.relationship_type_id))||[]}),S(!0))},De=async()=>{await j.mutateAsync({id:t,...E}),S(!1)},Ge=async()=>{confirm("Are you sure you want to delete this contact?")&&(await w.mutateAsync(t),s("/mission-control/contacts"))},wt=async()=>{$&&(await k.mutateAsync({contactId:t,actionTypeId:$,notes:W}),B(!1),V(null),G(""))},Ie=(We,et)=>{ue&&l?(oe({email:We,name:et||`${l.first_name} ${l.last_name||""}`.trim()}),ee(!0)):window.location.href=`mailto:${We}`};return i?e.jsx(Vs,{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(Vs,{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(Y,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/contacts"),children:[e.jsx(hc,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),Ae&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>Se&&s(Ee(Se)),disabled:!Se,className:"px-2",children:[e.jsx(hc,{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:[ye+1," of ",ve.length]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>Ke&&s(Ee(Ke)),disabled:!Ke,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(Ri,{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(Y,{variant:"outline",onClick:()=>Ie(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(zr,{className:"h-4 w-4 mr-1"}),"Email"]}),e.jsxs(Y,{variant:"default",onClick:()=>s(`/mission-control/video/record?contact_id=${t}`),className:"bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(Wn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(js,{open:L,onOpenChange:B,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{variant:"outline",children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:h==null?void 0:h.filter(We=>We.active).map(We=>e.jsxs("button",{onClick:()=>V(We.id),className:` p-3 rounded-lg border text-left transition-all ${$===We.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:We.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:We.description})]},We.id))})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Rr,{id:"action-notes",value:W,onChange:We=>G(We.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(Y,{onClick:wt,disabled:!$||k.isPending,className:"w-full",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(Y,{variant:"outline",onClick:Ue,children:[e.jsx(_c,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(Y,{variant:"destructive",size:"icon",onClick:Ge,children:e.jsx(Ir,{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("h1",{className:"text-2xl sm:text-3xl font-bold",children:[l.first_name," ",l.last_name||""]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-2 text-muted-foreground",children:[l.email&&e.jsxs("button",{onClick:()=>Ie(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(zr,{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(Ha,{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(Wge,{contact:l}),(st=l.tags)==null?void 0:st.map(We=>{const et=d==null?void 0:d.find(Ye=>Ye.id===We.relationship_type_id);return et?e.jsx(ct,{variant:"secondary",className:"text-xs",children:et.name},We.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(q6t,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Oe,{className:"md:col-span-2",children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Contact Information"})}),e.jsx($e,{children:M?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(je,{htmlFor:"first_name",children:"First Name"}),e.jsx(Be,{id:"first_name",value:E.first_name,onChange:We=>D({...E,first_name:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Be,{id:"last_name",value:E.last_name,onChange:We=>D({...E,last_name:We.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"email",children:"Email"}),e.jsx(Be,{id:"email",type:"email",value:E.email,onChange:We=>D({...E,email:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"phone",children:"Phone"}),e.jsx(Be,{id:"phone",value:E.phone,onChange:We=>D({...E,phone:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"address",children:"Street Address"}),e.jsx(Be,{id:"address",value:E.address,onChange:We=>D({...E,address:We.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(je,{htmlFor:"city",children:"City"}),e.jsx(Be,{id:"city",value:E.city,onChange:We=>D({...E,city:We.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"state",children:"State"}),e.jsx(Be,{id:"state",value:E.state,onChange:We=>D({...E,state:We.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(Be,{id:"zip_code",value:E.zip_code,onChange:We=>D({...E,zip_code:We.target.value}),placeholder:"12345"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Be,{id:"birthday",type:"date",value:E.birthday,onChange:We=>D({...E,birthday:We.target.value})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Be,{id:"home_anniversary",type:"date",value:E.home_anniversary,onChange:We=>D({...E,home_anniversary:We.target.value})})]})]}),e.jsx(ud,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"spouse_name",children:"Spouse/Partner Name"}),e.jsx(Be,{id:"spouse_name",value:E.spouse_name,onChange:We=>D({...E,spouse_name:We.target.value}),placeholder:"Enter spouse name"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"spouse_email",children:"Spouse/Partner Email"}),e.jsx(Be,{id:"spouse_email",type:"email",value:E.spouse_email,onChange:We=>D({...E,spouse_email:We.target.value}),placeholder:"Enter spouse email"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"company_name",children:"Company"}),e.jsx(Be,{id:"company_name",value:E.company_name,onChange:We=>D({...E,company_name:We.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"job_title",children:"Job Title"}),e.jsx(Be,{id:"job_title",value:E.job_title,onChange:We=>D({...E,job_title:We.target.value}),placeholder:"Enter job title"})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d==null?void 0:d.filter(We=>We.active).map(We=>{var et;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Do,{checked:(et=E.tagIds)==null?void 0:et.includes(We.id),onCheckedChange:Ye=>{var ke;D(Ye?{...E,tagIds:[...E.tagIds||[],We.id]}:{...E,tagIds:(ke=E.tagIds)==null?void 0:ke.filter(at=>at!==We.id)})}}),e.jsx("span",{className:"text-sm",children:We.name})]},We.id)})})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"notes",children:"Notes"}),e.jsx(Rr,{id:"notes",value:E.notes,onChange:We=>D({...E,notes:We.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{onClick:De,disabled:j.isPending,children:"Save Changes"}),e.jsx(Y,{variant:"outline",onClick:()=>S(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[He.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",Bs(new Date(He[0].completed_at),"MMM d, yyyy")," ","(",He[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(zr,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>Ie(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(Ha,{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(Gi,{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(xn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",Bs(new Date(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",Bs(new Date(l.home_anniversary),"MMMM d")]})]})]}),(l.spouse_name||l.spouse_email||l.company_name||l.job_title)&&e.jsxs(e.Fragment,{children:[e.jsx(ud,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(l.spouse_name||l.spouse_email)&&e.jsxs("div",{className:"space-y-1",children:[l.spouse_name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Spouse: ",l.spouse_name]})]}),l.spouse_email&&e.jsxs("div",{className:"flex items-center gap-2 ml-6",children:[e.jsx(zr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("button",{onClick:()=>Ie(l.spouse_email,l.spouse_name||void 0),className:"text-primary hover:underline text-left",children:l.spouse_email})]})]}),(l.company_name||l.job_title)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ya,{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(ud,{}),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:(he=l.tags)!=null&&he.length?l.tags.map(We=>{var et;return e.jsx(ct,{variant:"secondary",children:(et=We.relationship_type)==null?void 0:et.name},We.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(ud,{}),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(k6t,{contact:l,onLogTouch:()=>B(!0)}),e.jsx(aLt,{contactId:t}),e.jsx(rLt,{contactId:t}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Activity Log"})}),e.jsx($e,{children:He.length>0?e.jsx("div",{className:"space-y-4",children:He.map(We=>{var et;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[e.jsx("div",{className:"h-8 w-8 rounded-full flex items-center justify-center text-white text-xs",style:{backgroundColor:We.color},children:We.type==="popby"?e.jsx(oo,{className:"h-4 w-4"}):(et=We.name)==null?void 0:et.charAt(0)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:We.name}),We.videoId&&e.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ne(We.videoId),children:[e.jsx(Kl,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Bs(new Date(We.completed_at),"MMM d, yyyy h:mm a")}),We.notes&&!We.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:We.notes})]})]},We.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),v&&v.length>0&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Eo,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx($e,{children:e.jsx("div",{className:"space-y-4",children:v.map(We=>{var et,Ye;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(et=We.video)!=null&&et.thumbnail_url?e.jsx("img",{src:We.video.thumbnail_url,alt:We.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>ne(We.video_id)}):e.jsx("div",{className:"h-12 w-16 bg-muted rounded flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>ne(We.video_id),children:e.jsx(Wn,{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: ",((Ye=We.video)==null?void 0:Ye.title)||"Untitled Video"]}),e.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ne(We.video_id),children:[e.jsx(Kl,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Bs(new Date(We.created_at),"MMM d, yyyy h:mm a")}),We.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',We.message,'"']})]})]},We.id)})})})]}),ge&&ge.length>0&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Wa,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx($e,{children:e.jsx("div",{className:"space-y-4",children:ge.map(We=>e.jsxs("details",{className:"group pb-3 border-b last:border-0",children:[e.jsxs("summary",{className:"flex items-start gap-3 cursor-pointer list-none",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(zr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:We.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",We.to_email," · ",Bs(new Date(We.sent_at),"MMM d, yyyy h:mm a")]})]})]}),e.jsx("div",{className:"mt-2 ml-11 p-3 bg-muted/30 rounded-lg text-sm whitespace-pre-wrap",children:We.body})]},We.id))})})]})]}),e.jsx(js,{open:!!J,onOpenChange:We=>!We&&ne(null),children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Video Preview"})}),J&&e.jsx(sLt,{videoId:J})]})})]})]})}),ue&&l&&de&&e.jsx(Roe,{open:ie,onOpenChange:ee,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:de.email},gmailEmail:ce})]}):e.jsx(Vs,{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(Y,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const WMe={Crown:kh,FileText:Yn,Users:br,Globe:pg,Star:qn,Phone:Ha,MessageSquare:Eo,PenTool:Tk,Video:Wn,Gift:oo},Ghe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function oLt(){var ut,xt;const t=Yr(),{user:s}=Ys(),{data:r}=Ag(),{data:n}=_wt(),{data:a}=Cwt(),{data:o}=I9e(),{data:l}=A1e(),{data:i}=vwt(),d=Mwt(),h=bwt(),f=jwt(),g=kwt(),v=Nwt(),_=Swt(),j=wwt(),[w,k]=T.useState(null),[M,S]=T.useState(!1),[E,D]=T.useState(null),[L,B]=T.useState(""),[$,V]=T.useState(""),[W,G]=T.useState([]),[J,ne]=T.useState(null),[ie,ee]=T.useState(null),[de,oe]=T.useState(!1),[ue,ce]=T.useState(""),[ge,Te]=T.useState(""),[ve,ye]=T.useState(""),[Se,Ke]=T.useState(""),Ae=(_t,qe)=>a==null?void 0:a.some(Lt=>Lt.plan_id===_t&&Lt.relationship_type_id===qe&&Lt.active),Ee=_t=>a==null?void 0:a.find(qe=>qe.relationship_type_id===_t&&qe.active),He=async(_t,qe)=>{const Lt=Ae(_t,qe);await d.mutateAsync({planId:_t,relationshipTypeId:qe,active:!Lt})},Ue=(n==null?void 0:n.filter(_t=>_t.active&&!_t.owner_user_id))||[],De=(n==null?void 0:n.filter(_t=>_t.owner_user_id===(s==null?void 0:s.id)))||[],Ge=r==null?void 0:r.find(_t=>_t.id===w),wt=w?Ee(w):null,Ie=n==null?void 0:n.find(_t=>_t.id===(wt==null?void 0:wt.plan_id)),st=async()=>{if(!L.trim())return;const _t=await h.mutateAsync({name:L,description:$});_t&&W.length>0&&await v.mutateAsync({planId:_t.id,items:W}),et()},he=async()=>{!L.trim()||!E||(await f.mutateAsync({id:E,name:L,description:$}),await v.mutateAsync({planId:E,items:W}),et())},We=_t=>{var qe;D(_t.id),B(_t.name),V(_t.description||""),G(((qe=_t.items)==null?void 0:qe.map(Lt=>({month_number:Lt.month_number,action_type_id:Lt.action_type_id,default_script_id:Lt.default_script_id||void 0,notes:Lt.notes||void 0})))||[]),S(!0)},et=()=>{S(!1),D(null),B(""),V(""),G([])},Ye=(_t,qe)=>{ee(qe)},ke=(_t,qe,Lt)=>{G(Rt=>[...Rt.filter(Xt=>Xt.month_number!==_t),{month_number:_t,action_type_id:qe,default_script_id:Lt}]),ne(null),ee(null)},at=_t=>{G(qe=>qe.filter(Lt=>Lt.month_number!==_t))},Fe=async()=>{if(!ue.trim()||!ge.trim()||!ie)return;const _t=await _.mutateAsync({actionTypeId:ie,title:ue,scriptBody:ge,emailSubject:ve||void 0,tone:Se||void 0});_t&&J!==null&&ke(J,ie,_t.id),oe(!1),ce(""),Te(""),ye(""),Ke("")},it=ie?i==null?void 0:i.filter(_t=>_t.action_type_id===ie&&_t.active):[],dt=_t=>WMe[_t||"Phone"]||Ha,tt=_t=>WMe[_t||"Users"]||br;return e.jsxs(Vs,{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(Y,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(hc,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(Y,{onClick:()=>S(!0),className:"w-full sm:w-auto",children:[e.jsx(ar,{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(_t=>_t.active).map(_t=>{const qe=tt(_t.icon),Lt=(o==null?void 0:o[_t.id])||0,Rt=Ee(_t.id),Kt=n==null?void 0:n.find(ss=>ss.id===(Rt==null?void 0:Rt.plan_id)),Xt=w===_t.id;return e.jsxs("button",{onClick:()=>k(_t.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Xt?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(qe,{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:_t.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Lt," contacts"]})]}),Kt?e.jsxs(ct,{variant:"secondary",className:"text-xs",children:[e.jsx(yi,{className:"h-3 w-3 mr-1"}),Kt.name.split(" ")[0]]}):e.jsx(ct,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},_t.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:w&&Ge?e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[(()=>{const _t=tt(Ge.icon);return e.jsx(_t,{className:"h-5 w-5"})})(),Ge.name," Touchpoint Plan"]}),e.jsxs(Tr,{children:["Choose a plan for your ",Ge.name," contacts"]})]}),e.jsxs($e,{className:"space-y-6",children:[Ie&&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(yi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",Ie.name]}),Ie.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ie.description})]}),e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>He(Ie.id,w),children:"Disable"})]}),Ie.items&&Ie.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(xn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:Ghe.map((_t,qe)=>{var Xt,ss;const Lt=((Xt=Ie.items)==null?void 0:Xt.filter(fs=>fs.month_number===qe+1))||[],Rt=(ss=Lt[0])==null?void 0:ss.action_type,Kt=Rt?dt(Rt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Lt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:_t}),Kt&&e.jsx(Kt,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Rt==null?void 0:Rt.color)||"#3B82F6"}})]},qe)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:Ie?"Switch to a Different Plan":"Choose a Plan"}),Ue.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"}),Ue.map(_t=>{var Lt;const qe=(Ie==null?void 0:Ie.id)===_t.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${qe?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:_t.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Lt=_t.items)==null?void 0:Lt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:j.isPending,onClick:()=>{const Rt=`${_t.name} (Copy)`;j.mutate({sourcePlanId:_t.id,newName:Rt})},children:e.jsx(Di,{className:"h-4 w-4"})}),e.jsx(Y,{size:"sm",variant:qe?"outline":"default",disabled:qe||d.isPending,onClick:()=>He(_t.id,w),children:qe?"Active":"Use This"})]})]},_t.id)})]}),De.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),De.map(_t=>{var Lt;const qe=(Ie==null?void 0:Ie.id)===_t.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${qe?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:_t.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Lt=_t.items)==null?void 0:Lt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>We(_t),children:e.jsx(Iv,{className:"h-4 w-4"})}),e.jsx(Y,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>g.mutate(_t.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})}),e.jsx(Y,{size:"sm",variant:qe?"outline":"default",disabled:qe||d.isPending,onClick:()=>He(_t.id,w),children:qe?"Active":"Use This"})]})]},_t.id)})]}),Ue.length===0&&De.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(Oe,{children:e.jsxs($e,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(xn,{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(Oe,{className:"bg-muted/50",children:e.jsx($e,{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(js,{open:M,onOpenChange:_t=>{_t?S(!0):et()},children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:E?"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(je,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(Be,{id:"plan-name",value:L,onChange:_t=>B(_t.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Rr,{id:"plan-description",value:$,onChange:_t=>V(_t.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(je,{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:Ghe.map((_t,qe)=>{const Lt=qe+1,Rt=W.find(ss=>ss.month_number===Lt),Kt=Rt?l==null?void 0:l.find(ss=>ss.id===Rt.action_type_id):null,Xt=Kt?dt(Kt.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>ne(J===Lt?null:Lt),className:` w-full p-3 rounded-lg border text-center transition-all ${Rt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${J===Lt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:_t}),Xt?e.jsx(Xt,{className:"h-5 w-5 mx-auto mt-1",style:{color:(Kt==null?void 0:Kt.color)||"#3B82F6"}}):e.jsx(ar,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Rt&&e.jsx("button",{type:"button",onClick:ss=>{ss.stopPropagation(),at(Lt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Xr,{className:"h-3 w-3"})})]},qe)})}),J!==null&&!ie&&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 ",Ghe[J-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(_t=>_t.active).map(_t=>{const qe=dt(_t.icon);return e.jsxs("button",{type:"button",onClick:()=>Ye(J,_t.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(qe,{className:"h-4 w-4",style:{color:_t.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:_t.name})]},_t.id)})})]}),J!==null&&ie&&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(Y,{variant:"ghost",size:"sm",onClick:()=>ee(null),children:[e.jsx(hc,{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(J,ie),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"})]})}),it==null?void 0:it.map(_t=>e.jsx("button",{type:"button",onClick:()=>ke(J,ie,_t.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:_t.title}),_t.tone&&e.jsx(ct,{variant:"secondary",className:"text-xs mt-1",children:_t.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[_t.script_body.substring(0,100),"..."]})]})},_t.id)),e.jsxs("button",{type:"button",onClick:()=>oe(!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(ar,{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"})]})]})]})]})]}),W.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[W.length," touchpoint",W.length!==1?"s":""," per year"]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:et,children:"Cancel"}),e.jsxs(Y,{onClick:E?he:st,disabled:!L.trim()||h.isPending||f.isPending,children:[e.jsx(um,{className:"h-4 w-4 mr-2"}),E?"Save Changes":"Create Plan"]})]})]})}),e.jsx(js,{open:de,onOpenChange:oe,children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{htmlFor:"script-title",children:"Script Title"}),e.jsx(Be,{id:"script-title",value:ue,onChange:_t=>ce(_t.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(er,{value:Se,onValueChange:Ke,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select tone..."})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"friendly",children:"Friendly"}),e.jsx(Et,{value:"professional",children:"Professional"}),e.jsx(Et,{value:"casual",children:"Casual"}),e.jsx(Et,{value:"formal",children:"Formal"})]})]})]}),((xt=(ut=l==null?void 0:l.find(_t=>_t.id===ie))==null?void 0:ut.name)==null?void 0:xt.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(je,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(Be,{id:"script-email-subject",value:ve,onChange:_t=>ye(_t.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(je,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Rr,{id:"script-body",value:ge,onChange:_t=>Te(_t.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(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>oe(!1),children:"Cancel"}),e.jsxs(Y,{onClick:Fe,disabled:!ue.trim()||!ge.trim()||_.isPending,children:[e.jsx(um,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const lLt="0dde5abb-0005-4c8c-a471-30d0cbc9e280",cLt=[{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 dLt(){const t=Yr(),s=THe(),{data:r}=SHe(),{data:n}=Ag(),{data:a}=G_e(),{data:o}=Foe(90),{data:l}=of(),i=w6t(),d=AHe(),h=_6t(),f=b6t(),{data:g=[],isLoading:v}=zt({queryKey:["popby-templates"],queryFn:async()=>{const{data:de,error:oe}=await Z.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",lLt).order("publish_date",{ascending:!1});if(oe)throw oe;const{data:ue}=await Z.from("template_likes").select("template_id"),{data:ce}=await Z.from("template_comments").select("template_id"),ge=new Map;ue==null||ue.forEach(ve=>{ge.set(ve.template_id,(ge.get(ve.template_id)||0)+1)});const Te=new Map;return ce==null||ce.forEach(ve=>{Te.set(ve.template_id,(Te.get(ve.template_id)||0)+1)}),(de||[]).map(ve=>({...ve,likesCount:ge.get(ve.id)||0,commentsCount:Te.get(ve.id)||0}))}}),_=de=>{const oe=l==null?void 0:l.find(ue=>ue.id===de);return oe?`${oe.first_name} ${oe.last_name||""}`.trim():"Unknown"},j=de=>{if(!de)return null;const oe=r==null?void 0:r.find(ue=>ue.id===de);return(oe==null?void 0:oe.name)||null},[w,k]=T.useState(null),[M,S]=T.useState(!1),[E,D]=T.useState(!1),[L,B]=T.useState(!1),[$,V]=T.useState({popby_item_id:"",notes:""}),[W,G]=T.useState({name:"",description:""}),J=async()=>{w&&(await d.mutateAsync({contact_id:w.id,popby_item_id:$.popby_item_id||void 0,notes:$.notes||void 0}),S(!1),k(null),V({popby_item_id:"",notes:""}))},ne=async()=>{W.name.trim()&&(await h.mutateAsync({name:W.name.trim(),description:W.description.trim()||void 0}),B(!1),G({name:"",description:""}))},ie=async(de,oe)=>{await f.mutateAsync({relationship_type_id:de,frequency_days:parseInt(oe)})},ee=de=>{var ue;const oe=a==null?void 0:a.find(ce=>ce.relationship_type_id===de);return((ue=oe==null?void 0:oe.frequency_days)==null?void 0:ue.toString())||"90"};return e.jsx(Vs,{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(Oe,{children:e.jsxs($e,{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(Oe,{children:e.jsxs($e,{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(Oe,{children:e.jsxs($e,{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(Y,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(Gi,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(Y,{variant:"outline",onClick:()=>D(!0),children:[e.jsx(Ic,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(Y,{variant:"outline",onClick:()=>B(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(Qa,{defaultValue:"due",children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"due",children:"Due for Popby"}),e.jsx(Fs,{value:"activity",children:"Recent Activity"}),e.jsx(Fs,{value:"library",children:"Popby Library"}),e.jsx(Fs,{value:"templates",children:"Popby Templates"})]}),e.jsx(Zs,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(Oe,{children:e.jsxs($e,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(oo,{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(Oe,{className:"hover:shadow-md transition-shadow",children:e.jsx($e,{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(ct,{variant:"destructive",className:"text-xs",children:[de.daysOverdue,"+ days overdue"]}),de.daysSinceLastPopby===null&&e.jsx(ct,{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(Gi,{className:"h-3 w-3"}),de.city||de.address]}),de.tags&&de.tags.length>0&&e.jsx("span",{children:de.tags.map(oe=>{var ue;return(ue=oe.relationship_type)==null?void 0:ue.name}).join(", ")})]}),de.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",Bs(new Date(de.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[de.phone&&e.jsx(Y,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${de.phone}`,children:e.jsx(Ha,{className:"h-4 w-4"})})}),e.jsxs(Y,{size:"sm",onClick:()=>{k(de),S(!0)},children:[e.jsx(yi,{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(Oe,{children:e.jsxs($e,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(ca,{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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx($e,{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(oo,{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)}),j(de.popby_item_id)&&e.jsx(ct,{variant:"secondary",className:"text-xs",children:j(de.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Bs(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(Oe,{children:e.jsx($e,{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(oo,{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(ct,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},de.id)),e.jsx(Oe,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>B(!0),children:e.jsx($e,{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(ar,{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,oe)=>e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsx(ys,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ys,{className:"h-5 w-3/4 mb-2"}),e.jsx(ys,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ys,{className:"h-5 w-16"}),e.jsx(ys,{className:"h-5 w-20"})]})]})},oe))}),!v&&g.length===0&&e.jsx(Oe,{children:e.jsxs($e,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(mc,{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(Oe,{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($e,{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:pie(de.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(ct,{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(Ed,{className:"h-3.5 w-3.5"}),de.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gl,{className:"h-3.5 w-3.5"}),de.commentsCount]})]}),e.jsxs(Y,{size:"sm",className:"w-full gap-2",onClick:oe=>{oe.stopPropagation(),t(`/templates/${de.id}`)},children:[e.jsx(bn,{className:"h-4 w-4"}),"View Template"]})]})]},de.id))})]})]}),e.jsx(js,{open:M,onOpenChange:S,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsxs(Ps,{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(je,{children:"Popby Item (optional)"}),e.jsxs(er,{value:$.popby_item_id,onValueChange:de=>V(oe=>({...oe,popby_item_id:de})),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select a popby item..."})}),e.jsx(Js,{children:r==null?void 0:r.map(de=>e.jsx(Et,{value:de.id,children:de.name},de.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Notes (optional)"}),e.jsx(Rr,{placeholder:"Any notes about this popby...",value:$.notes,onChange:de=>V(oe=>({...oe,notes:de.target.value}))})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(Y,{onClick:J,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(js,{open:E,onOpenChange:D,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{className:"font-medium",children:de.name}),e.jsxs(er,{value:ee(de.id),onValueChange:oe=>ie(de.id,oe),children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{})}),e.jsx(Js,{children:cLt.map(oe=>e.jsx(Et,{value:oe.value,children:oe.label},oe.value))})]})]},de.id))]}),e.jsx(Hn,{children:e.jsx(Y,{onClick:()=>D(!1),children:"Done"})})]})}),e.jsx(js,{open:L,onOpenChange:B,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Name *"}),e.jsx(Be,{placeholder:"e.g., Homemade cookies",value:W.name,onChange:de=>G(oe=>({...oe,name:de.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Rr,{placeholder:"Optional description...",value:W.description,onChange:de=>G(oe=>({...oe,description:de.target.value}))})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>B(!1),children:"Cancel"}),e.jsx(Y,{onClick:ne,disabled:!W.name.trim()||h.isPending,children:"Add Item"})]})]})})]})})}function uLt(){const t=Yr(),{isAdmin:s}=Ys(),r=T.useRef(null),n=T.useRef(null),a=T.useRef([]),o=MHe(),{data:l}=SHe(),i=AHe(),[d,h]=T.useState(""),[f,g]=T.useState(""),[v,_]=T.useState(!0),[j,w]=T.useState(null),[k,M]=T.useState(null),[S,E]=T.useState(!1),[D,L]=T.useState({popby_item_id:"",notes:""}),B=o.filter(G=>G.address||G.city&&G.state);T.useEffect(()=>{(async()=>{_(!0);try{const{data:J}=await Z.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();J!=null&&J.value&&h(J.value)}catch(J){console.error("Error fetching mapbox token:",J)}_(!1)})()},[]),T.useEffect(()=>{"geolocation"in navigator&&navigator.geolocation.getCurrentPosition(G=>{w([G.coords.longitude,G.coords.latitude])},G=>{console.log("Could not get location:",G)})},[]),T.useEffect(()=>{if(!(!r.current||!d||n.current))return Mc.accessToken=d,n.current=new Mc.Map({container:r.current,style:"mapbox://styles/mapbox/streets-v12",zoom:j?12:4,center:j||[-98.5795,39.8283]}),n.current.addControl(new Mc.NavigationControl,"top-right"),()=>{var G;(G=n.current)==null||G.remove(),n.current=null}},[d,j]),T.useEffect(()=>{!n.current||!d||(a.current.forEach(G=>G.remove()),a.current=[],B.forEach(async G=>{var ne;const J=[G.address,G.city,G.state,G.zip].filter(Boolean).join(", ");if(J)try{const ee=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(J)}.json?access_token=${d}`)).json();if(ee.features&&ee.features.length>0){const[de,oe]=ee.features[0].center,ue=document.createElement("div");ue.className="cursor-pointer",ue.innerHTML=`
${G.first_name[0]}${((ne=G.last_name)==null?void 0:ne[0])||""}
${G.isDue?'
':""}
`;const ce=new Mc.Marker(ue).setLngLat([de,oe]).addTo(n.current);ue.addEventListener("click",()=>{M(G)}),a.current.push(ce)}}catch(ie){console.error("Geocoding error for",G.first_name,ie)}}))},[B,d]);const $=()=>{j&&n.current?n.current.flyTo({center:j,zoom:13}):pn({title:"Location not available",description:"Please enable location services",variant:"destructive"})},V=async()=>{k&&(await i.mutateAsync({contact_id:k.id,popby_item_id:D.popby_item_id||void 0,notes:D.notes||void 0,latitude:j==null?void 0:j[1],longitude:j==null?void 0:j[0]}),E(!1),M(null),L({popby_item_id:"",notes:""}))},W=async()=>{if(f.trim())try{await Z.from("settings").upsert({key:"mapbox_public_token",value:f.trim()}),h(f.trim()),pn({title:"Mapbox token saved!"})}catch{pn({title:"Error saving token",variant:"destructive"})}};return v?e.jsx(Vs,{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(Vs,{title:"Popby Map",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Y,{variant:"ghost",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(bi,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]}),e.jsxs(Y,{onClick:$,children:[e.jsx(TE,{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"}),B.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."})]})})]}),k&&e.jsx(Oe,{className:"fixed bottom-4 left-4 right-4 md:left-auto md:right-4 md:w-96 z-50 shadow-xl",children:e.jsxs($e,{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:[k.first_name," ",k.last_name]}),k.address&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[k.city,", ",k.state]})]}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>M(null),children:"×"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[k.isDue?e.jsxs(ct,{variant:"destructive",children:[k.daysOverdue,"+ days overdue"]}):e.jsx(ct,{variant:"secondary",children:"Up to date"}),k.lastPopby&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last: ",Bs(new Date(k.lastPopby),"MMM d")]})]}),e.jsxs("div",{className:"flex gap-2",children:[k.phone&&e.jsx(Y,{size:"sm",variant:"outline",asChild:!0,className:"flex-1",children:e.jsxs("a",{href:`tel:${k.phone}`,children:[e.jsx(Ha,{className:"h-4 w-4 mr-1"}),"Call"]})}),k.address&&e.jsxs(Y,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const G=[k.address,k.city,k.state,k.zip].filter(Boolean).join(", ");window.open(`https://maps.google.com/maps?daddr=${encodeURIComponent(G)}`,"_blank")},children:[e.jsx(OE,{className:"h-4 w-4 mr-1"}),"Navigate"]}),e.jsxs(Y,{size:"sm",className:"flex-1",onClick:()=>E(!0),children:[e.jsx(oo,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})}),e.jsx(js,{open:S,onOpenChange:E,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:["Log Popby for ",k==null?void 0:k.first_name," ",k==null?void 0:k.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Popby Item (optional)"}),e.jsxs(er,{value:D.popby_item_id,onValueChange:G=>L(J=>({...J,popby_item_id:G})),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select a popby item..."})}),e.jsx(Js,{children:l==null?void 0:l.map(G=>e.jsx(Et,{value:G.id,children:G.name},G.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Notes (optional)"}),e.jsx(Rr,{placeholder:"Any notes about this popby...",value:D.notes,onChange:G=>L(J=>({...J,notes:G.target.value}))})]}),j&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Gi,{className:"h-3 w-3"}),"Your current location will be recorded"]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),e.jsxs(Y,{onClick:V,disabled:i.isPending,children:[e.jsx(yi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})]})}):s?e.jsx(Vs,{title:"Popby Map",children:e.jsx("div",{className:"max-w-md mx-auto mt-8",children:e.jsx(Oe,{children:e.jsxs($e,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx(Gi,{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(je,{children:"Mapbox Public Token"}),e.jsx(Be,{placeholder:"pk.eyJ1I...",value:f,onChange:G=>g(G.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(Y,{onClick:W,className:"w-full",children:"Save Token"}),e.jsxs(Y,{variant:"outline",className:"w-full",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(bi,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})}):e.jsx(Vs,{title:"Popby Map",children:e.jsx("div",{className:"max-w-md mx-auto mt-8",children:e.jsx(Oe,{children:e.jsxs($e,{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(Y,{variant:"outline",className:"w-full",onClick:()=>t("/mission-control/popbys"),children:[e.jsx(bi,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})})}const hLt=u_({property_address:Uo().min(1,"Property address is required"),city:Uo().optional(),state:Uo().optional(),zip:Uo().optional(),transaction_type:lBe(["buyer","seller"]),close_date:Uo().min(1,"Close date is required"),sale_price:nI().min(0,"Sale price must be positive"),commission_amount:nI().optional(),lead_source_id:Uo().optional(),client_type_id:Uo().optional(),contact_id:Uo().optional(),notes:Uo().optional(),is_win:wvt()});function LHe({open:t,onOpenChange:s,transaction:r}){const[n,a]=T.useState(!1),[o,l]=T.useState(""),[i,d]=T.useState(!1),[h,f]=T.useState(""),g=coe(),v=Qwt(),{data:_}=loe(),{data:j}=Ag(),{data:w}=of(),k=M1e(),M=Xwt(),{data:S}=doe(),E=(S==null?void 0:S.show_commission)??!0,D=Jie({resolver:eoe(hLt),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}});T.useEffect(()=>{r?D.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}):D.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,D]);const L=async W=>{const G={property_address:W.property_address,transaction_type:W.transaction_type,close_date:W.close_date,sale_price:W.sale_price,is_win:W.is_win,commission_amount:W.commission_amount||null,lead_source_id:W.lead_source_id||null,client_type_id:W.client_type_id||null,contact_id:W.contact_id||null,city:W.city||null,state:W.state||null,zip:W.zip||null,notes:W.notes||null};r?await v.mutateAsync({id:r.id,...G}):await g.mutateAsync(G),s(!1)},B=async()=>{if(!o.trim())return;const[W,...G]=o.trim().split(" "),J=G.join(" ")||null,ne=await k.mutateAsync({first_name:W,last_name:J,tagIds:[]});ne&&(D.setValue("contact_id",ne.id),l(""),d(!1),a(!1))},$=async()=>{if(!h.trim())return;const W=await M.mutateAsync(h.trim());W&&(D.setValue("lead_source_id",W.id),f(""))},V=w==null?void 0:w.find(W=>W.id===D.watch("contact_id"));return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(po,{className:"max-h-[70vh] pr-4",children:e.jsx(toe,{...D,children:e.jsxs("form",{onSubmit:D.handleSubmit(L),className:"space-y-4",children:[e.jsx(Jl,{control:D.control,name:"property_address",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Property Address *"}),e.jsx($l,{children:e.jsx(Be,{placeholder:"123 Main St",...W})}),e.jsx(gh,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Jl,{control:D.control,name:"city",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"City"}),e.jsx($l,{children:e.jsx(Be,{placeholder:"City",...W})})]})}),e.jsx(Jl,{control:D.control,name:"state",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"State"}),e.jsx($l,{children:e.jsx(Be,{placeholder:"TX",...W})})]})}),e.jsx(Jl,{control:D.control,name:"zip",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Zip"}),e.jsx($l,{children:e.jsx(Be,{placeholder:"75001",...W})})]})})]}),e.jsx(Jl,{control:D.control,name:"transaction_type",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Transaction Type *"}),e.jsxs(er,{onValueChange:W.onChange,value:W.value,children:[e.jsx($l,{children:e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select type"})})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"buyer",children:"Buyer"}),e.jsx(Et,{value:"seller",children:"Seller"})]})]}),e.jsx(gh,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Jl,{control:D.control,name:"close_date",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Close Date *"}),e.jsx($l,{children:e.jsx(Be,{type:"date",...W})}),e.jsx(gh,{})]})}),e.jsx(Jl,{control:D.control,name:"sale_price",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Sale Price *"}),e.jsx($l,{children:e.jsx(Be,{type:"number",placeholder:"0",...W,onChange:G=>W.onChange(Number(G.target.value))})}),e.jsx(gh,{})]})})]}),E&&e.jsx(Jl,{control:D.control,name:"commission_amount",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Commission"}),e.jsx($l,{children:e.jsx(Be,{type:"number",placeholder:"0",...W,value:W.value??"",onChange:G=>W.onChange(G.target.value?Number(G.target.value):void 0)})})]})}),e.jsx(Jl,{control:D.control,name:"lead_source_id",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Lead Source"}),e.jsxs(er,{onValueChange:W.onChange,value:W.value||"",children:[e.jsx($l,{children:e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select source"})})}),e.jsx(Js,{children:_==null?void 0:_.map(G=>e.jsx(Et,{value:G.id,children:G.name},G.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{placeholder:"Add custom source...",value:h,onChange:W=>f(W.target.value),className:"flex-1"}),e.jsx(Y,{type:"button",variant:"outline",size:"icon",onClick:$,disabled:!h.trim(),children:e.jsx(ar,{className:"h-4 w-4"})})]}),e.jsx(Jl,{control:D.control,name:"client_type_id",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Client Type"}),e.jsxs(er,{onValueChange:W.onChange,value:W.value||"",children:[e.jsx($l,{children:e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select client type"})})}),e.jsx(Js,{children:j==null?void 0:j.map(G=>e.jsx(Et,{value:G.id,children:G.name},G.id))})]})]})}),e.jsx(Jl,{control:D.control,name:"contact_id",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Client Contact"}),e.jsxs(_l,{open:n,onOpenChange:a,children:[e.jsx(bl,{asChild:!0,children:e.jsx($l,{children:e.jsxs(Y,{variant:"outline",role:"combobox",className:$t("w-full justify-between",!W.value&&"text-muted-foreground"),children:[V?`${V.first_name} ${V.last_name||""}`.trim():"Select contact",e.jsx(mg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(nl,{className:"w-full p-0",align:"start",children:[e.jsxs(wg,{children:[e.jsx(jg,{placeholder:"Search contacts..."}),e.jsxs(kg,{children:[e.jsx(Ng,{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(Y,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Sg,{children:w==null?void 0:w.map(G=>e.jsxs(Vm,{value:`${G.first_name} ${G.last_name||""}`,onSelect:()=>{W.onChange(G.id),a(!1)},children:[e.jsx(ma,{className:$t("mr-2 h-4 w-4",G.id===W.value?"opacity-100":"opacity-0")}),G.first_name," ",G.last_name||""]},G.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(Be,{placeholder:"Enter contact name...",value:o,onChange:G=>l(G.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{size:"sm",onClick:B,disabled:!o.trim()||k.isPending,children:"Add Contact"}),e.jsx(Y,{size:"sm",variant:"outline",onClick:()=>{d(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Jl,{control:D.control,name:"notes",render:({field:W})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Notes"}),e.jsx($l,{children:e.jsx(Rr,{placeholder:"Any notes about this transaction...",...W})})]})}),e.jsx(Jl,{control:D.control,name:"is_win",render:({field:W})=>e.jsxs(zl,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Bl,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx($l,{children:e.jsx(ln,{checked:W.value,onCheckedChange:W.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:g.isPending||v.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function DHe({transactions:t,showCommission:s,isLoading:r}){const[n,a]=T.useState(null),[o,l]=T.useState(null),[i,d]=T.useState(""),[h,f]=T.useState("all"),[g,v]=T.useState("all"),[_,j]=T.useState("all"),[w,k]=T.useState(!1),M=Jwt(),S=coe(),{data:E}=loe(),{data:D}=Ag(),L=Q3(),B=W=>{const{id:G,created_at:J,updated_at:ne,lead_source:ie,client_type:ee,contact:de,...oe}=W;S.mutate(oe)},$=()=>{o&&(M.mutate(o),l(null))},V=t.filter(W=>{var de,oe,ue,ce;const G=i===""||W.property_address.toLowerCase().includes(i.toLowerCase())||((oe=(de=W.contact)==null?void 0:de.first_name)==null?void 0:oe.toLowerCase().includes(i.toLowerCase()))||((ce=(ue=W.contact)==null?void 0:ue.last_name)==null?void 0:ce.toLowerCase().includes(i.toLowerCase())),J=h==="all"||W.transaction_type===h,ne=g==="all"||W.lead_source_id===g,ie=_==="all"||W.client_type_id===_,ee=!w||W.is_win;return G&&J&&ne&&ie&&ee});return r?e.jsx(Oe,{children:e.jsx($e,{className:"p-6 space-y-4",children:[1,2,3].map(W=>e.jsx(ys,{className:"h-16 w-full"},W))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{children:[e.jsx(Ht,{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(Gt,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search...",value:i,onChange:W=>d(W.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(er,{value:h,onValueChange:f,children:[e.jsx(Qs,{className:"w-[100px]",children:e.jsx(tr,{placeholder:"Type"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Types"}),e.jsx(Et,{value:"buyer",children:"Buyer"}),e.jsx(Et,{value:"seller",children:"Seller"})]})]}),e.jsxs(er,{value:g,onValueChange:v,children:[e.jsx(Qs,{className:"w-[130px]",children:e.jsx(tr,{placeholder:"Lead Source"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Sources"}),E==null?void 0:E.map(W=>e.jsx(Et,{value:W.id,children:W.name},W.id))]})]}),e.jsxs(Y,{variant:w?"default":"outline",size:"sm",onClick:()=>k(!w),children:[e.jsx(nc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx($e,{children:V.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):L?e.jsx("div",{className:"space-y-3",children:V.map(W=>e.jsxs(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-1",children:[e.jsx("span",{className:"font-medium truncate",children:W.property_address}),W.is_win&&e.jsx(nc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[W.city,W.state?`, ${W.state}`:""]})]}),e.jsx(ct,{variant:W.transaction_type==="buyer"?"default":"secondary",children:W.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: "}),XSe(W.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),fu(W.sale_price)]}),s&&W.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),fu(W.commission_amount)]}),W.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),W.lead_source.name]}),W.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),W.contact.first_name," ",W.contact.last_name]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>a(W),children:e.jsx(_c,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>B(W),children:e.jsx(Di,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>l(W.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})]},W.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Property"}),e.jsx(Ct,{children:"Type"}),e.jsx(Ct,{children:"Close Date"}),e.jsx(Ct,{children:"Sale Price"}),s&&e.jsx(Ct,{children:"Commission"}),e.jsx(Ct,{children:"Lead Source"}),e.jsx(Ct,{children:"Client"}),e.jsx(Ct,{className:"w-[50px]"})]})}),e.jsx(Bn,{children:V.map(W=>{var G;return e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[W.is_win&&e.jsx(nc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:W.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[W.city,W.state?`, ${W.state}`:""]})]})]})}),e.jsx(ot,{children:e.jsx(ct,{variant:W.transaction_type==="buyer"?"default":"secondary",children:W.transaction_type})}),e.jsx(ot,{children:XSe(W.close_date)}),e.jsx(ot,{children:fu(W.sale_price)}),s&&e.jsx(ot,{children:W.commission_amount?fu(W.commission_amount):"-"}),e.jsx(ot,{children:((G=W.lead_source)==null?void 0:G.name)||"-"}),e.jsx(ot,{children:W.contact?`${W.contact.first_name} ${W.contact.last_name||""}`.trim():"-"}),e.jsx(ot,{children:e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",children:e.jsx(hx,{className:"h-4 w-4"})})}),e.jsxs(ju,{align:"end",children:[e.jsxs(Va,{onClick:()=>a(W),children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Va,{onClick:()=>B(W),children:[e.jsx(Di,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Va,{onClick:()=>l(W.id),className:"text-destructive",children:[e.jsx(Ir,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},W.id)})})]})})})]}),e.jsx(LHe,{open:!!n,onOpenChange:W=>!W&&a(null),transaction:n||void 0}),e.jsx(Ec,{open:!!o,onOpenChange:W=>!W&&l(null),children:e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Delete Transaction?"}),e.jsx(cc,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:$,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function OHe({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 j=Math.min(v/_*100,100),w=Math.max(_-v,0),k=l>0?w/l:0,M=o/12*100,S=j>=M?"ahead":j>=M*.8?"on-track":"behind";return{percent:j,remaining:w,pace:k,status:S}},d=i(s.totalTransactions,t.transactions_goal),h=i(s.totalVolume,t.volume_goal),f=n?i(s.totalCommission,t.gci_goal):null,g=v=>{switch(v){case"ahead":return e.jsxs(ct,{className:"bg-green-500 text-white",children:[e.jsx(Jd,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(ct,{variant:"secondary",children:[e.jsx(T1,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(ct,{variant:"destructive",children:[e.jsx(Pk,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hm,{className:"h-5 w-5 text-primary"}),e.jsxs(Gt,{children:[r," Goals Progress"]})]})}),e.jsx($e,{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(rl,{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&&h&&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(h.status)]}),e.jsx(rl,{value:h.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[fu(s.totalVolume,!0)," of ",fu(t.volume_goal,!0)]}),e.jsxs("span",{children:[Math.round(h.percent),"%"]})]}),h.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",fu(h.pace,!0),"/month"]})]}),n&&t.gci_goal&&f&&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(f.status)]}),e.jsx(rl,{value:f.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[fu(s.totalCommission,!0)," of ",fu(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(f.percent),"%"]})]}),f.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",fu(f.pace,!0),"/month"]})]})]})})]})}var mLt=Array.isArray,xm=mLt,pLt=typeof By=="object"&&By&&By.Object===Object&&By,RHe=pLt,fLt=RHe,gLt=typeof self=="object"&&self&&self.Object===Object&&self,xLt=fLt||gLt||Function("return this")(),Yx=xLt,yLt=Yx,vLt=yLt.Symbol,nL=vLt,GMe=nL,FHe=Object.prototype,_Lt=FHe.hasOwnProperty,bLt=FHe.toString,IA=GMe?GMe.toStringTag:void 0;function wLt(t){var s=_Lt.call(t,IA),r=t[IA];try{t[IA]=void 0;var n=!0}catch{}var a=bLt.call(t);return n&&(s?t[IA]=r:delete t[IA]),a}var jLt=wLt,kLt=Object.prototype,NLt=kLt.toString;function SLt(t){return NLt.call(t)}var CLt=SLt,KMe=nL,MLt=jLt,TLt=CLt,ALt="[object Null]",ELt="[object Undefined]",ZMe=KMe?KMe.toStringTag:void 0;function ILt(t){return t==null?t===void 0?ELt:ALt:ZMe&&ZMe in Object(t)?MLt(t):TLt(t)}var S0=ILt;function PLt(t){return t!=null&&typeof t=="object"}var C0=PLt,LLt=S0,DLt=C0,OLt="[object Symbol]";function RLt(t){return typeof t=="symbol"||DLt(t)&&LLt(t)==OLt}var J3=RLt,FLt=xm,zLt=J3,BLt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$Lt=/^\w*$/;function ULt(t,s){if(FLt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||zLt(t)?!0:$Lt.test(t)||!BLt.test(t)||s!=null&&t in Object(s)}var Z_e=ULt;function qLt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var x_=qLt;const eM=fo(x_);var VLt=S0,HLt=x_,WLt="[object AsyncFunction]",GLt="[object Function]",KLt="[object GeneratorFunction]",ZLt="[object Proxy]";function YLt(t){if(!HLt(t))return!1;var s=VLt(t);return s==GLt||s==KLt||s==WLt||s==ZLt}var Y_e=YLt;const hi=fo(Y_e);var XLt=Yx,QLt=XLt["__core-js_shared__"],JLt=QLt,Khe=JLt,YMe=function(){var t=/[^.]+$/.exec(Khe&&Khe.keys&&Khe.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function eDt(t){return!!YMe&&YMe in t}var tDt=eDt,sDt=Function.prototype,rDt=sDt.toString;function nDt(t){if(t!=null){try{return rDt.call(t)}catch{}try{return t+""}catch{}}return""}var zHe=nDt,aDt=Y_e,iDt=tDt,oDt=x_,lDt=zHe,cDt=/[\\^$.*+?()[\]{}|]/g,dDt=/^\[object .+?Constructor\]$/,uDt=Function.prototype,hDt=Object.prototype,mDt=uDt.toString,pDt=hDt.hasOwnProperty,fDt=RegExp("^"+mDt.call(pDt).replace(cDt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function gDt(t){if(!oDt(t)||iDt(t))return!1;var s=aDt(t)?fDt:dDt;return s.test(lDt(t))}var xDt=gDt;function yDt(t,s){return t==null?void 0:t[s]}var vDt=yDt,_Dt=xDt,bDt=vDt;function wDt(t,s){var r=bDt(t,s);return _Dt(r)?r:void 0}var AN=wDt,jDt=AN,kDt=jDt(Object,"create"),$oe=kDt,XMe=$oe;function NDt(){this.__data__=XMe?XMe(null):{},this.size=0}var SDt=NDt;function CDt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var MDt=CDt,TDt=$oe,ADt="__lodash_hash_undefined__",EDt=Object.prototype,IDt=EDt.hasOwnProperty;function PDt(t){var s=this.__data__;if(TDt){var r=s[t];return r===ADt?void 0:r}return IDt.call(s,t)?s[t]:void 0}var LDt=PDt,DDt=$oe,ODt=Object.prototype,RDt=ODt.hasOwnProperty;function FDt(t){var s=this.__data__;return DDt?s[t]!==void 0:RDt.call(s,t)}var zDt=FDt,BDt=$oe,$Dt="__lodash_hash_undefined__";function UDt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=BDt&&s===void 0?$Dt:s,this}var qDt=UDt,VDt=SDt,HDt=MDt,WDt=LDt,GDt=zDt,KDt=qDt;function tM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var uOt=dOt,hOt=Uoe;function mOt(t,s){var r=this.__data__,n=hOt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var pOt=mOt,fOt=XDt,gOt=aOt,xOt=lOt,yOt=uOt,vOt=pOt;function sM(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},Jj=function(s){return hN(s)&&s.indexOf("%")===s.length-1},Zr=function(s){return z8t(s)&&!aL(s)},q8t=function(s){return Wi(s)},Md=function(s){return Zr(s)||hN(s)},V8t=0,iL=function(s){var r=++V8t;return"".concat(s||"").concat(r)},vh=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(!Zr(s)&&!hN(s))return n;var o;if(Jj(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return aL(o)&&(o=n),a&&o>r&&(o=r),o},Kv=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},H8t=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 Q8t(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 nTe={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"},l0=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},aTe=null,Yhe=null,ibe=function t(s){if(s===aTe&&Array.isArray(Yhe))return Yhe;var r=[];return T.Children.forEach(s,function(n){Wi(n)||(L8t.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Yhe=r,aTe=s,r};function Jp(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return l0(a)}):n=[l0(s)],ibe(t).forEach(function(a){var o=rp(a,"type.displayName")||rp(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function Lm(t,s){var r=Jp(t,s);return r&&r[0]}var iTe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!Zr(n)||n<=0||!Zr(a)||a<=0)},J8t=["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"],eRt=function(s){return s&&s.type&&hN(s.type)&&J8t.indexOf(s.type)>=0},tRt=function(s,r,n,a){var o,l=(o=Zhe==null?void 0:Zhe[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!hi(s)&&(a&&l.includes(r)||K8t.includes(r))||n&&abe.includes(r)},ni=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(T.isValidElement(s)&&(a=s.props),!eM(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;tRt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},Zge=function t(s,r){if(s===r)return!0;var n=T.Children.count(s);if(n!==T.Children.count(r))return!1;if(n===0)return!0;if(n===1)return oTe(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 iRt(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 Xge(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,h=aRt(t,nRt),f=a||{width:r,height:n,x:0,y:0},g=Ai("recharts-surface",o);return lt.createElement("svg",Yge({},ni(h,!0,"svg"),{className:g,width:r,height:n,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height)}),lt.createElement("title",null,i),lt.createElement("desc",null,d),s)}var oRt=["children","className"];function Qge(){return Qge=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 cRt(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 Vo=lt.forwardRef(function(t,s){var r=t.children,n=t.className,a=lRt(t,oRt),o=Ai("recharts-layer",n);return lt.createElement("g",Qge({className:o},ni(a,!0),{ref:s}),r)}),gg=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:hRt(t,s,r)}var pRt=mRt,fRt="\\ud800-\\udfff",gRt="\\u0300-\\u036f",xRt="\\ufe20-\\ufe2f",yRt="\\u20d0-\\u20ff",vRt=gRt+xRt+yRt,_Rt="\\ufe0e\\ufe0f",bRt="\\u200d",wRt=RegExp("["+bRt+fRt+vRt+_Rt+"]");function jRt(t){return wRt.test(t)}var ZHe=jRt;function kRt(t){return t.split("")}var NRt=kRt,YHe="\\ud800-\\udfff",SRt="\\u0300-\\u036f",CRt="\\ufe20-\\ufe2f",MRt="\\u20d0-\\u20ff",TRt=SRt+CRt+MRt,ARt="\\ufe0e\\ufe0f",ERt="["+YHe+"]",Jge="["+TRt+"]",exe="\\ud83c[\\udffb-\\udfff]",IRt="(?:"+Jge+"|"+exe+")",XHe="[^"+YHe+"]",QHe="(?:\\ud83c[\\udde6-\\uddff]){2}",JHe="[\\ud800-\\udbff][\\udc00-\\udfff]",PRt="\\u200d",eWe=IRt+"?",tWe="["+ARt+"]?",LRt="(?:"+PRt+"(?:"+[XHe,QHe,JHe].join("|")+")"+tWe+eWe+")*",DRt=tWe+eWe+LRt,ORt="(?:"+[XHe+Jge+"?",Jge,QHe,JHe,ERt].join("|")+")",RRt=RegExp(exe+"(?="+exe+")|"+ORt+DRt,"g");function FRt(t){return t.match(RRt)||[]}var zRt=FRt,BRt=NRt,$Rt=ZHe,URt=zRt;function qRt(t){return $Rt(t)?URt(t):BRt(t)}var VRt=qRt,HRt=pRt,WRt=ZHe,GRt=VRt,KRt=qHe;function ZRt(t){return function(s){s=KRt(s);var r=WRt(s)?GRt(s):void 0,n=r?r[0]:s.charAt(0),a=r?HRt(r,1).join(""):s.slice(1);return n[t]()+a}}var YRt=ZRt,XRt=YRt,QRt=XRt("toUpperCase"),JRt=QRt;const sle=fo(JRt);function pl(t){return function(){return t}}const sWe=Math.cos,Vne=Math.sin,Pg=Math.sqrt,Hne=Math.PI,rle=2*Hne,txe=Math.PI,sxe=2*txe,Lj=1e-6,eFt=sxe-Lj;function rWe(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return rWe;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;aLj)if(!(Math.abs(g*d-h*f)>Lj)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let _=n-l,j=a-i,w=d*d+h*h,k=_*_+j*j,M=Math.sqrt(w),S=Math.sqrt(v),E=o*Math.tan((txe-Math.acos((w+v-k)/(2*M*S)))/2),D=E/S,L=E/M;Math.abs(D-1)>Lj&&this._append`L${s+D*f},${r+D*g}`,this._append`A${o},${o},0,0,${+(g*_>f*j)},${this._x1=s+L*d},${this._y1=r+L*h}`}}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),h=s+i,f=r+d,g=1^l,v=l?a-o:o-a;this._x1===null?this._append`M${h},${f}`:(Math.abs(this._x1-h)>Lj||Math.abs(this._y1-f)>Lj)&&this._append`L${h},${f}`,n&&(v<0&&(v=v%sxe+sxe),v>eFt?this._append`A${n},${n},0,1,${g},${s-i},${r-d}A${n},${n},0,1,${g},${this._x1=h},${this._y1=f}`:v>Lj&&this._append`A${n},${n},0,${+(v>=txe)},${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 obe(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 sFt(s)}function lbe(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function nWe(t){this._context=t}nWe.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 nle(t){return new nWe(t)}function aWe(t){return t[0]}function iWe(t){return t[1]}function oWe(t,s){var r=pl(!0),n=null,a=nle,o=null,l=obe(i);t=typeof t=="function"?t:t===void 0?aWe:pl(t),s=typeof s=="function"?s:s===void 0?iWe:pl(s);function i(d){var h,f=(d=lbe(d)).length,g,v=!1,_;for(n==null&&(o=a(_=l())),h=0;h<=f;++h)!(h=_;--j)i.point(E[j],D[j]);i.lineEnd(),i.areaEnd()}M&&(E[v]=+t(k,v,g),D[v]=+s(k,v,g),i.point(n?+n(k,v,g):E[v],r?+r(k,v,g):D[v]))}if(S)return i=null,S+""||null}function f(){return oWe().defined(a).curve(l).context(o)}return h.x=function(g){return arguments.length?(t=typeof g=="function"?g:pl(+g),n=null,h):t},h.x0=function(g){return arguments.length?(t=typeof g=="function"?g:pl(+g),h):t},h.x1=function(g){return arguments.length?(n=g==null?null:typeof g=="function"?g:pl(+g),h):n},h.y=function(g){return arguments.length?(s=typeof g=="function"?g:pl(+g),r=null,h):s},h.y0=function(g){return arguments.length?(s=typeof g=="function"?g:pl(+g),h):s},h.y1=function(g){return arguments.length?(r=g==null?null:typeof g=="function"?g:pl(+g),h):r},h.lineX0=h.lineY0=function(){return f().x(t).y(s)},h.lineY1=function(){return f().x(t).y(r)},h.lineX1=function(){return f().x(n).y(s)},h.defined=function(g){return arguments.length?(a=typeof g=="function"?g:pl(!!g),h):a},h.curve=function(g){return arguments.length?(l=g,o!=null&&(i=l(o)),h):l},h.context=function(g){return arguments.length?(g==null?o=i=null:i=l(o=g),h):o},h}class lWe{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 rFt(t){return new lWe(t,!0)}function nFt(t){return new lWe(t,!1)}const cbe={draw(t,s){const r=Pg(s/Hne);t.moveTo(r,0),t.arc(0,0,r,0,rle)}},aFt={draw(t,s){const r=Pg(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()}},cWe=Pg(1/3),iFt=cWe*2,oFt={draw(t,s){const r=Pg(s/iFt),n=r*cWe;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},lFt={draw(t,s){const r=Pg(s),n=-r/2;t.rect(n,n,r,r)}},cFt=.8908130915292852,dWe=Vne(Hne/10)/Vne(7*Hne/10),dFt=Vne(rle/10)*dWe,uFt=-sWe(rle/10)*dWe,hFt={draw(t,s){const r=Pg(s*cFt),n=dFt*r,a=uFt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=rle*o/5,i=sWe(l),d=Vne(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},Xhe=Pg(3),mFt={draw(t,s){const r=-Pg(s/(Xhe*3));t.moveTo(0,r*2),t.lineTo(-Xhe*r,-r),t.lineTo(Xhe*r,-r),t.closePath()}},Sp=-.5,Cp=Pg(3)/2,rxe=1/Pg(12),pFt=(rxe/2+1)*3,fFt={draw(t,s){const r=Pg(s/pFt),n=r/2,a=r*rxe,o=n,l=r*rxe+r,i=-o,d=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,d),t.lineTo(Sp*n-Cp*a,Cp*n+Sp*a),t.lineTo(Sp*o-Cp*l,Cp*o+Sp*l),t.lineTo(Sp*i-Cp*d,Cp*i+Sp*d),t.lineTo(Sp*n+Cp*a,Sp*a-Cp*n),t.lineTo(Sp*o+Cp*l,Sp*l-Cp*o),t.lineTo(Sp*i+Cp*d,Sp*d-Cp*i),t.closePath()}};function gFt(t,s){let r=null,n=obe(a);t=typeof t=="function"?t:pl(t||cbe),s=typeof s=="function"?s:pl(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:pl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:pl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function Wne(){}function Gne(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 uWe(t){this._context=t}uWe.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:Gne(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:Gne(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function xFt(t){return new uWe(t)}function hWe(t){this._context=t}hWe.prototype={areaStart:Wne,areaEnd:Wne,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:Gne(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function yFt(t){return new hWe(t)}function mWe(t){this._context=t}mWe.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:Gne(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function vFt(t){return new mWe(t)}function pWe(t){this._context=t}pWe.prototype={areaStart:Wne,areaEnd:Wne,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 _Ft(t){return new pWe(t)}function cTe(t){return t<0?-1:1}function dTe(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(cTe(o)+cTe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function uTe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Qhe(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 Kne(t){this._context=t}Kne.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:Qhe(this,this._t0,uTe(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,Qhe(this,uTe(this,r=dTe(this,t,s)),r);break;default:Qhe(this,this._t0,r=dTe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function fWe(t){this._context=new gWe(t)}(fWe.prototype=Object.create(Kne.prototype)).point=function(t,s){Kne.prototype.point.call(this,s,t)};function gWe(t){this._context=t}gWe.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 bFt(t){return new Kne(t)}function wFt(t){return new fWe(t)}function xWe(t){this._context=t}xWe.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=hTe(t),a=hTe(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 kFt(t){return new ale(t,.5)}function NFt(t){return new ale(t,0)}function SFt(t){return new ale(t,1)}function Q5(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 CFt(t,s){return t[s]}function MFt(t){const s=[];return s.key=t,s}function TFt(){var t=pl([]),s=nxe,r=Q5,n=CFt;function a(o){var l=Array.from(t.apply(this,arguments),MFt),i,d=l.length,h=-1,f;for(const g of o)for(i=0,++h;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 FFt(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 yWe={symbolCircle:cbe,symbolCross:aFt,symbolDiamond:oFt,symbolSquare:lFt,symbolStar:hFt,symbolTriangle:mFt,symbolWye:fFt},zFt=Math.PI/180,BFt=function(s){var r="symbol".concat(sle(s));return yWe[r]||cbe},$Ft=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*zFt;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}},UFt=function(s,r){yWe["symbol".concat(sle(s))]=r},dbe=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=RFt(s,PFt),h=pTe(pTe({},d),{},{type:n,size:o,sizeType:i}),f=function(){var k=BFt(n),M=gFt().type(k).size($Ft(o,i,n));return M()},g=h.className,v=h.cx,_=h.cy,j=ni(h,!0);return v===+v&&_===+_&&o===+o?lt.createElement("path",axe({},j,{className:Ai("recharts-symbols",g),transform:"translate(".concat(v,", ").concat(_,")"),d:f()})):null};dbe.registerSymbol=UFt;function J5(t){"@babel/helpers - typeof";return J5=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},J5(t)}function ixe(){return ixe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var S=_.inactive?h:_.color;return lt.createElement("li",ixe({className:k,style:g,key:"legend-item-".concat(j)},mN(n.props,_,j)),lt.createElement(Xge,{width:l,height:l,viewBox:f,style:v},n.renderIcon(_)),lt.createElement("span",{className:"recharts-legend-item-text",style:{color:S}},w?w(M,_,j):M))})}},{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 lt.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(T.PureComponent);MP(ube,"displayName","Legend");MP(ube,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var QFt=qoe;function JFt(){this.__data__=new QFt,this.size=0}var ezt=JFt;function tzt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var szt=tzt;function rzt(t){return this.__data__.get(t)}var nzt=rzt;function azt(t){return this.__data__.has(t)}var izt=azt,ozt=qoe,lzt=Q_e,czt=J_e,dzt=200;function uzt(t,s){var r=this.__data__;if(r instanceof ozt){var n=r.__data__;if(!lzt||n.lengthi))return!1;var h=o.get(t),f=o.get(s);if(h&&f)return h==s&&f==t;var g=-1,v=!0,_=r&Pzt?new Tzt:void 0;for(o.set(t,s),o.set(s,t);++g-1&&t%1==0&&t-1&&t%1==0&&t<=R7t}var fbe=F7t,z7t=S0,B7t=fbe,$7t=C0,U7t="[object Arguments]",q7t="[object Array]",V7t="[object Boolean]",H7t="[object Date]",W7t="[object Error]",G7t="[object Function]",K7t="[object Map]",Z7t="[object Number]",Y7t="[object Object]",X7t="[object RegExp]",Q7t="[object Set]",J7t="[object String]",eBt="[object WeakMap]",tBt="[object ArrayBuffer]",sBt="[object DataView]",rBt="[object Float32Array]",nBt="[object Float64Array]",aBt="[object Int8Array]",iBt="[object Int16Array]",oBt="[object Int32Array]",lBt="[object Uint8Array]",cBt="[object Uint8ClampedArray]",dBt="[object Uint16Array]",uBt="[object Uint32Array]",Al={};Al[rBt]=Al[nBt]=Al[aBt]=Al[iBt]=Al[oBt]=Al[lBt]=Al[cBt]=Al[dBt]=Al[uBt]=!0;Al[U7t]=Al[q7t]=Al[tBt]=Al[V7t]=Al[sBt]=Al[H7t]=Al[W7t]=Al[G7t]=Al[K7t]=Al[Z7t]=Al[Y7t]=Al[X7t]=Al[Q7t]=Al[J7t]=Al[eBt]=!1;function hBt(t){return $7t(t)&&B7t(t.length)&&!!Al[z7t(t)]}var mBt=hBt;function pBt(t){return function(s){return t(s)}}var TWe=pBt,Qne={exports:{}};Qne.exports;(function(t,s){var r=RHe,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})(Qne,Qne.exports);var fBt=Qne.exports,gBt=mBt,xBt=TWe,bTe=fBt,wTe=bTe&&bTe.isTypedArray,yBt=wTe?xBt(wTe):gBt,AWe=yBt,vBt=w7t,_Bt=mbe,bBt=xm,wBt=MWe,jBt=pbe,kBt=AWe,NBt=Object.prototype,SBt=NBt.hasOwnProperty;function CBt(t,s){var r=bBt(t),n=!r&&_Bt(t),a=!r&&!n&&wBt(t),o=!r&&!n&&!a&&kBt(t),l=r||n||a||o,i=l?vBt(t.length,String):[],d=i.length;for(var h in t)(s||SBt.call(t,h))&&!(l&&(h=="length"||a&&(h=="offset"||h=="parent")||o&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||jBt(h,d)))&&i.push(h);return i}var MBt=CBt,TBt=Object.prototype;function ABt(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||TBt;return t===r}var EBt=ABt;function IBt(t,s){return function(r){return t(s(r))}}var EWe=IBt,PBt=EWe,LBt=PBt(Object.keys,Object),DBt=LBt,OBt=EBt,RBt=DBt,FBt=Object.prototype,zBt=FBt.hasOwnProperty;function BBt(t){if(!OBt(t))return RBt(t);var s=[];for(var r in Object(t))zBt.call(t,r)&&r!="constructor"&&s.push(r);return s}var $Bt=BBt,UBt=Y_e,qBt=fbe;function VBt(t){return t!=null&&qBt(t.length)&&!UBt(t)}var oL=VBt,HBt=MBt,WBt=$Bt,GBt=oL;function KBt(t){return GBt(t)?HBt(t):WBt(t)}var ile=KBt,ZBt=d7t,YBt=_7t,XBt=ile;function QBt(t){return ZBt(t,XBt,YBt)}var JBt=QBt,jTe=JBt,e9t=1,t9t=Object.prototype,s9t=t9t.hasOwnProperty;function r9t(t,s,r,n,a,o){var l=r&e9t,i=jTe(t),d=i.length,h=jTe(s),f=h.length;if(d!=f&&!l)return!1;for(var g=d;g--;){var v=i[g];if(!(l?v in s:s9t.call(s,v)))return!1}var _=o.get(t),j=o.get(s);if(_&&j)return _==s&&j==t;var w=!0;o.set(t,s),o.set(s,t);for(var k=l;++g-1}var tUt=eUt;function sUt(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=xUt){var h=s?null:fUt(t);if(h)return gUt(h);l=!1,a=pUt,d=new uUt}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function PUt(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 LUt(t){return t.value}function DUt(t,s){if(lt.isValidElement(t))return lt.cloneElement(t,s);if(typeof t=="function")return lt.createElement(t,s);s.ref;var r=IUt(s,kUt);return lt.createElement(ube,r)}var zTe=1,o5=function(t){function s(){var r;NUt(this,s);for(var n=arguments.length,a=new Array(n),o=0;ozTe||Math.abs(a.height-this.lastBoundingBox.height)>zTe)&&(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?Sy({},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,h=a.chartWidth,f=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:((h||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 j=this.getBBoxSnapshot();v={top:((f||0)-j.height)/2}}else v=i==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return Sy(Sy({},g),v)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,d=a.wrapperStyle,h=a.payloadUniqBy,f=a.payload,g=Sy(Sy({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(d)),d);return lt.createElement("div",{className:"recharts-legend-wrapper",style:g,ref:function(_){n.wrapperNode=_}},DUt(o,Sy(Sy({},this.props),{},{payload:FWe(f,h,LUt)})))}}],[{key:"getWithHeight",value:function(n,a){var o=Sy(Sy({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&Zr(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(T.PureComponent);ole(o5,"displayName","Legend");ole(o5,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var BTe=nL,OUt=mbe,RUt=xm,$Te=BTe?BTe.isConcatSpreadable:void 0;function FUt(t){return RUt(t)||OUt(t)||!!($Te&&t&&t[$Te])}var zUt=FUt,BUt=SWe,$Ut=zUt;function $We(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=$Ut),a||(a=[]);++o0&&r(i)?s>1?$We(i,s-1,r,n,a):BUt(a,i):n||(a[a.length]=i)}return a}var UWe=$We;function UUt(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 qUt=UUt,VUt=qUt,HUt=VUt(),WUt=HUt,GUt=WUt,KUt=ile;function ZUt(t,s){return t&&GUt(t,s,KUt)}var qWe=ZUt,YUt=oL;function XUt(t,s){return function(r,n){if(r==null)return r;if(!YUt(r))return t(r,n);for(var a=r.length,o=s?a:-1,l=Object(r);(s?o--:++os||o&&l&&d&&!i&&!h||n&&l&&d||!r&&d||!a)return 1;if(!n&&!o&&!h&&t=i)return d;var h=r[n];return d*(h=="desc"?-1:1)}}return t.index-s.index}var uqt=dqt,sme=tbe,hqt=sbe,mqt=Xx,pqt=VWe,fqt=iqt,gqt=TWe,xqt=uqt,yqt=iM,vqt=xm;function _qt(t,s,r){s.length?s=sme(s,function(o){return vqt(o)?function(l){return hqt(l,o.length===1?o[0]:o)}:o}):s=[yqt];var n=-1;s=sme(s,gqt(mqt));var a=pqt(t,function(o,l,i){var d=sme(s,function(h){return h(o)});return{criteria:d,index:++n,value:o}});return fqt(a,function(o,l){return xqt(o,l,r)})}var bqt=_qt;function wqt(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 jqt=wqt,kqt=jqt,qTe=Math.max;function Nqt(t,s,r){return s=qTe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=qTe(n.length-s,0),l=Array(o);++a0){if(++s>=Dqt)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var zqt=Fqt,Bqt=Lqt,$qt=zqt,Uqt=$qt(Bqt),qqt=Uqt,Vqt=iM,Hqt=Sqt,Wqt=qqt;function Gqt(t,s){return Wqt(Hqt(t,s,Vqt),t+"")}var Kqt=Gqt,Zqt=X_e,Yqt=oL,Xqt=pbe,Qqt=x_;function Jqt(t,s,r){if(!Qqt(r))return!1;var n=typeof s;return(n=="number"?Yqt(r)&&Xqt(s,r.length):n=="string"&&s in r)?Zqt(r[s],t):!1}var lle=Jqt,eVt=UWe,tVt=bqt,sVt=Kqt,HTe=lle,rVt=sVt(function(t,s){if(t==null)return[];var r=s.length;return r>1&&HTe(t,s[0],s[1])?s=[]:r>2&&HTe(s[0],s[1],s[2])&&(s=[s[0]]),tVt(t,eVt(s,1),[])}),nVt=rVt;const ybe=fo(nVt);function TP(t){"@babel/helpers - typeof";return TP=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},TP(t)}function pxe(){return pxe=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(PA,"-left"),Zr(r)&&s&&Zr(s.x)&&r=s.y),"".concat(PA,"-top"),Zr(n)&&s&&Zr(s.y)&&nw?Math.max(f,d[n]):Math.max(g,d[n])}function vVt(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 _Vt(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,h,f,g;return l.height>0&&l.width>0&&r?(f=KTe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),g=KTe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),h=vVt({translateX:f,translateY:g,useTranslate3d:i})):h=xVt,{cssProperties:h,cssClasses:yVt({translateX:f,translateY:g,coordinate:r})}}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 ZTe(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 YTe(t){for(var s=1;sXTe||Math.abs(n.height-this.state.lastBoundingBox.height)>XTe)&&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,h=a.children,f=a.coordinate,g=a.hasPayload,v=a.isAnimationActive,_=a.offset,j=a.position,w=a.reverseDirection,k=a.useTranslate3d,M=a.viewBox,S=a.wrapperStyle,E=_Vt({allowEscapeViewBox:l,coordinate:f,offsetTopLeft:_,position:j,reverseDirection:w,tooltipBox:this.state.lastBoundingBox,useTranslate3d:k,viewBox:M}),D=E.cssClasses,L=E.cssProperties,B=YTe(YTe({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},S);return lt.createElement("div",{tabIndex:-1,className:D,style:B,ref:function(V){n.wrapperNode=V}},h)}}])}(T.PureComponent),AVt=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},oM={isSsr:AVt()};function s3(t){"@babel/helpers - typeof";return s3=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},s3(t)}function QTe(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 JTe(t){for(var s=1;s0;return lt.createElement(TVt,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:v,active:o,coordinate:f,hasPayload:B,offset:_,position:k,reverseDirection:M,useTranslate3d:S,viewBox:E,wrapperStyle:D},BVt(h,JTe(JTe({},this.props),{},{payload:L})))}}])}(T.PureComponent);vbe(Xf,"displayName","Tooltip");vbe(Xf,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!oM.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 $Vt=Yx,UVt=function(){return $Vt.Date.now()},qVt=UVt,VVt=/\s/;function HVt(t){for(var s=t.length;s--&&VVt.test(t.charAt(s)););return s}var WVt=HVt,GVt=WVt,KVt=/^\s+/;function ZVt(t){return t&&t.slice(0,GVt(t)+1).replace(KVt,"")}var YVt=ZVt,XVt=YVt,eAe=x_,QVt=J3,tAe=NaN,JVt=/^[-+]0x[0-9a-f]+$/i,eHt=/^0b[01]+$/i,tHt=/^0o[0-7]+$/i,sHt=parseInt;function rHt(t){if(typeof t=="number")return t;if(QVt(t))return tAe;if(eAe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=eAe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=XVt(t);var r=eHt.test(t);return r||tHt.test(t)?sHt(t.slice(2),r?2:8):JVt.test(t)?tAe:+t}var YWe=rHt,nHt=x_,nme=qVt,sAe=YWe,aHt="Expected a function",iHt=Math.max,oHt=Math.min;function lHt(t,s,r){var n,a,o,l,i,d,h=0,f=!1,g=!1,v=!0;if(typeof t!="function")throw new TypeError(aHt);s=sAe(s)||0,nHt(r)&&(f=!!r.leading,g="maxWait"in r,o=g?iHt(sAe(r.maxWait)||0,s):o,v="trailing"in r?!!r.trailing:v);function _(B){var $=n,V=a;return n=a=void 0,h=B,l=t.apply(V,$),l}function j(B){return h=B,i=setTimeout(M,s),f?_(B):l}function w(B){var $=B-d,V=B-h,W=s-$;return g?oHt(W,o-V):W}function k(B){var $=B-d,V=B-h;return d===void 0||$>=s||$<0||g&&V>=o}function M(){var B=nme();if(k(B))return S(B);i=setTimeout(M,w(B))}function S(B){return i=void 0,v&&n?_(B):(n=a=void 0,l)}function E(){i!==void 0&&clearTimeout(i),h=0,n=d=a=i=void 0}function D(){return i===void 0?l:S(nme())}function L(){var B=nme(),$=k(B);if(n=arguments,a=this,d=B,$){if(i===void 0)return j(d);if(g)return clearTimeout(i),i=setTimeout(M,s),_(d)}return i===void 0&&(i=setTimeout(M,s)),l}return L.cancel=E,L.flush=D,L}var cHt=lHt,dHt=cHt,uHt=x_,hHt="Expected a function";function mHt(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(hHt);return uHt(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),dHt(t,s,{leading:n,maxWait:s,trailing:a})}var pHt=mHt;const XWe=fo(pHt);function EP(t){"@babel/helpers - typeof";return EP=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},EP(t)}function rAe(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 _8(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(ie=XWe(ie,w,{trailing:!0,leading:!1}));var ee=new ResizeObserver(ie),de=L.current.getBoundingClientRect(),oe=de.width,ue=de.height;return J(oe,ue),ee.observe(L.current),function(){ee.disconnect()}},[J,w]);var ne=T.useMemo(function(){var ie=W.containerWidth,ee=W.containerHeight;if(ie<0||ee<0)return null;gg(Jj(l)||Jj(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),gg(!r||r>0,"The aspect(%s) must be greater than zero.",r);var de=Jj(l)?ie:l,oe=Jj(d)?ee:d;r&&r>0&&(de?oe=de/r:oe&&(de=oe*r),v&&oe>v&&(oe=v)),gg(de>0||oe>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,oe,l,d,f,g,r);var ue=!Array.isArray(_)&&l0(_.type).endsWith("Chart");return lt.Children.map(_,function(ce){return lt.isValidElement(ce)?T.cloneElement(ce,_8({width:de,height:oe},ue?{style:_8({height:"100%",width:"100%",maxHeight:oe,maxWidth:de},ce.props.style)}:{})):ce})},[r,_,d,v,g,f,W,l]);return lt.createElement("div",{id:k?"".concat(k):void 0,className:Ai("recharts-responsive-container",M),style:_8(_8({},D),{},{width:l,height:d,minWidth:f,minHeight:g,maxHeight:v}),ref:L},ne)}),cle=function(s){return null};cle.displayName="Cell";function IP(t){"@babel/helpers - typeof";return IP=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},IP(t)}function aAe(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 vxe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||oM.isSsr)return{width:0,height:0};var n=MHt(r),a=JSON.stringify({text:s,copyStyle:n});if(PC.widthCache[a])return PC.widthCache[a];try{var o=document.getElementById(iAe);o||(o=document.createElement("span"),o.setAttribute("id",iAe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=vxe(vxe({},CHt),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return PC.widthCache[a]=d,++PC.cacheCount>SHt&&(PC.cacheCount=0,PC.widthCache={}),d}catch{return{width:0,height:0}}},THt=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function PP(t){"@babel/helpers - typeof";return PP=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},PP(t)}function sae(t,s){return PHt(t)||IHt(t,s)||EHt(t,s)||AHt()}function AHt(){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 EHt(t,s){if(t){if(typeof t=="string")return oAe(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 oAe(t,s)}}function oAe(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 GHt(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 mAe(t,s){return XHt(t)||YHt(t,s)||ZHt(t,s)||KHt()}function KHt(){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 ZHt(t,s){if(t){if(typeof t=="string")return pAe(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 pAe(t,s)}}function pAe(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(oe,ue){var ce=ue.word,ge=ue.width,Te=oe[oe.length-1];if(Te&&(a==null||o||Te.width+ge+nue.width?oe:ue})};if(!f)return _;for(var w="…",k=function(de){var oe=g.slice(0,de),ue=tGe({breakAll:h,style:d,children:oe+w}).wordsWithComputedWidth,ce=v(ue),ge=ce.length>l||j(ce).width>Number(a);return[ge,ce]},M=0,S=g.length-1,E=0,D;M<=S&&E<=g.length-1;){var L=Math.floor((M+S)/2),B=L-1,$=k(B),V=mAe($,2),W=V[0],G=V[1],J=k(L),ne=mAe(J,1),ie=ne[0];if(!W&&!ie&&(M=L+1),W&&ie&&(S=L-1),!W&&ie){D=G;break}E++}return D||_},fAe=function(s){var r=Wi(s)?[]:s.toString().split(eGe);return[{words:r}]},JHt=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!oM.isSsr){var d,h,f=tGe({breakAll:l,children:a,style:o});if(f){var g=f.wordsWithComputedWidth,v=f.spaceWidth;d=g,h=v}else return fAe(a);return QHt({breakAll:l,children:a,maxLines:i,style:o},d,h,r,n)}return fAe(a)},gAe="#808080",pN=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,h=d===void 0?"0.71em":d,f=s.scaleToFit,g=f===void 0?!1:f,v=s.textAnchor,_=v===void 0?"start":v,j=s.verticalAnchor,w=j===void 0?"end":j,k=s.fill,M=k===void 0?gAe:k,S=hAe(s,HHt),E=T.useMemo(function(){return JHt({breakAll:S.breakAll,children:S.children,maxLines:S.maxLines,scaleToFit:g,style:S.style,width:S.width})},[S.breakAll,S.children,S.maxLines,g,S.style,S.width]),D=S.dx,L=S.dy,B=S.angle,$=S.className,V=S.breakAll,W=hAe(S,WHt);if(!Md(n)||!Md(o))return null;var G=n+(Zr(D)?D:0),J=o+(Zr(L)?L:0),ne;switch(w){case"start":ne=ame("calc(".concat(h,")"));break;case"middle":ne=ame("calc(".concat((E.length-1)/2," * -").concat(i," + (").concat(h," / 2))"));break;default:ne=ame("calc(".concat(E.length-1," * -").concat(i,")"));break}var ie=[];if(g){var ee=E[0].width,de=S.width;ie.push("scale(".concat((Zr(de)?de/ee:1)/ee,")"))}return B&&ie.push("rotate(".concat(B,", ").concat(G,", ").concat(J,")")),ie.length&&(W.transform=ie.join(" ")),lt.createElement("text",_xe({},ni(W,!0),{x:G,y:J,className:Ai("recharts-text",$),textAnchor:_,fill:M.includes("url")?gAe:M}),E.map(function(oe,ue){var ce=oe.words.join(V?"":" ");return lt.createElement("tspan",{x:G,dy:ue===0?ne:i,key:"".concat(ce,"-").concat(ue)},ce)}))};function U1(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function eWt(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function _be(t){let s,r,n;t.length!==2?(s=U1,r=(i,d)=>U1(t(i),d),n=(i,d)=>t(i)-d):(s=t===U1||t===eWt?t:tWt,r=t,n=t);function a(i,d,h=0,f=i.length){if(h>>1;r(i[g],d)<0?h=g+1:f=g}while(h>>1;r(i[g],d)<=0?h=g+1:f=g}while(hh&&n(i[g-1],d)>-n(i[g],d)?g-1:g}return{left:a,center:l,right:o}}function tWt(){return 0}function sGe(t){return t===null?NaN:+t}function*sWt(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const rWt=_be(U1),lL=rWt.right;_be(sGe).center;class xAe extends Map{constructor(s,r=iWt){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(yAe(this,s))}has(s){return super.has(yAe(this,s))}set(s,r){return super.set(nWt(this,s),r)}delete(s){return super.delete(aWt(this,s))}}function yAe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function nWt({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function aWt({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function iWt(t){return t!==null&&typeof t=="object"?t.valueOf():t}function oWt(t=U1){if(t===U1)return rGe;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 rGe(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const lWt=Math.sqrt(50),cWt=Math.sqrt(10),dWt=Math.sqrt(2);function rae(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>=lWt?10:o>=cWt?5:o>=dWt?2:1;let i,d,h;return a<0?(h=Math.pow(10,-a)/l,i=Math.round(t*h),d=Math.round(s*h),i/hs&&--d,h=-h):(h=Math.pow(10,a)*l,i=Math.round(t/h),d=Math.round(s/h),i*hs&&--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 h=0;h=n)&&(r=n);return r}function _Ae(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function nGe(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?rGe:oWt(a);n>r;){if(n-r>600){const d=n-r+1,h=s-r+1,f=Math.log(d),g=.5*Math.exp(2*f/3),v=.5*Math.sqrt(f*g*(d-g)/d)*(h-d/2<0?-1:1),_=Math.max(r,Math.floor(s-h*g/d+v)),j=Math.min(n,Math.floor(s+(d-h)*g/d+v));nGe(t,s,_,j,a)}const o=t[s];let l=r,i=n;for(LA(t,r,s),a(t[n],o)>0&&LA(t,r,n);l0;)--i}a(t[r],o)===0?LA(t,r,i):(++i,LA(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function LA(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function uWt(t,s,r){if(t=Float64Array.from(sWt(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return _Ae(t);if(s>=1)return vAe(t);var n,a=(n-1)*s,o=Math.floor(a),l=vAe(nGe(t,o).subarray(0,o+1)),i=_Ae(t.subarray(o+1));return l+(i-l)*(a-o)}}function hWt(t,s,r=sGe){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 mWt(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?w8(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?w8(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=fWt.exec(t))?new rm(s[1],s[2],s[3],1):(s=gWt.exec(t))?new rm(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=xWt.exec(t))?w8(s[1],s[2],s[3],s[4]):(s=yWt.exec(t))?w8(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=vWt.exec(t))?CAe(s[1],s[2]/100,s[3]/100,1):(s=_Wt.exec(t))?CAe(s[1],s[2]/100,s[3]/100,s[4]):bAe.hasOwnProperty(t)?kAe(bAe[t]):t==="transparent"?new rm(NaN,NaN,NaN,0):null}function kAe(t){return new rm(t>>16&255,t>>8&255,t&255,1)}function w8(t,s,r,n){return n<=0&&(t=s=r=NaN),new rm(t,s,r,n)}function jWt(t){return t instanceof cL||(t=RP(t)),t?(t=t.rgb(),new rm(t.r,t.g,t.b,t.opacity)):new rm}function Nxe(t,s,r,n){return arguments.length===1?jWt(t):new rm(t,s,r,n??1)}function rm(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}wbe(rm,Nxe,iGe(cL,{brighter(t){return t=t==null?nae:Math.pow(nae,t),new rm(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?DP:Math.pow(DP,t),new rm(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new rm(qk(this.r),qk(this.g),qk(this.b),aae(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:NAe,formatHex:NAe,formatHex8:kWt,formatRgb:SAe,toString:SAe}));function NAe(){return`#${ek(this.r)}${ek(this.g)}${ek(this.b)}`}function kWt(){return`#${ek(this.r)}${ek(this.g)}${ek(this.b)}${ek((isNaN(this.opacity)?1:this.opacity)*255)}`}function SAe(){const t=aae(this.opacity);return`${t===1?"rgb(":"rgba("}${qk(this.r)}, ${qk(this.g)}, ${qk(this.b)}${t===1?")":`, ${t})`}`}function aae(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function qk(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ek(t){return t=qk(t),(t<16?"0":"")+t.toString(16)}function CAe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new rg(t,s,r,n)}function oGe(t){if(t instanceof rg)return new rg(t.h,t.s,t.l,t.opacity);if(t instanceof cL||(t=RP(t)),!t)return new rg;if(t instanceof rg)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 rg(l,i,d,t.opacity)}function NWt(t,s,r,n){return arguments.length===1?oGe(t):new rg(t,s,r,n??1)}function rg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}wbe(rg,NWt,iGe(cL,{brighter(t){return t=t==null?nae:Math.pow(nae,t),new rg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?DP:Math.pow(DP,t),new rg(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 rm(ime(t>=240?t-240:t+120,a,n),ime(t,a,n),ime(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new rg(MAe(this.h),j8(this.s),j8(this.l),aae(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=aae(this.opacity);return`${t===1?"hsl(":"hsla("}${MAe(this.h)}, ${j8(this.s)*100}%, ${j8(this.l)*100}%${t===1?")":`, ${t})`}`}}));function MAe(t){return t=(t||0)%360,t<0?t+360:t}function j8(t){return Math.max(0,Math.min(1,t||0))}function ime(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 jbe=t=>()=>t;function SWt(t,s){return function(r){return t+r*s}}function CWt(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 MWt(t){return(t=+t)==1?lGe:function(s,r){return r-s?CWt(s,r,t):jbe(isNaN(s)?r:s)}}function lGe(t,s){var r=s-t;return r?SWt(t,r):jbe(isNaN(t)?s:t)}const TAe=function t(s){var r=MWt(s);function n(a,o){var l=r((a=Nxe(a)).r,(o=Nxe(o)).r),i=r(a.g,o.g),d=r(a.b,o.b),h=lGe(a.opacity,o.opacity);return function(f){return a.r=l(f),a.g=i(f),a.b=d(f),a.opacity=h(f),a+""}}return n.gamma=t,n}(1);function TWt(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:iae(n,a)})),r=ome.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function BWt(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?$Wt:BWt,d=h=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((h||(h=i(s,t.map(n),iae)))(v)))},g.domain=function(v){return arguments.length?(t=Array.from(v,oae),f()):t.slice()},g.range=function(v){return arguments.length?(s=Array.from(v),f()):s.slice()},g.rangeRound=function(v){return s=Array.from(v),r=kbe,f()},g.clamp=function(v){return arguments.length?(l=v?!0:_h,f()):l!==_h},g.interpolate=function(v){return arguments.length?(r=v,f()):r},g.unknown=function(v){return arguments.length?(o=v,g):o},function(v,_){return n=v,a=_,f()}}function Nbe(){return dle()(_h,_h)}function UWt(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function lae(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 r3(t){return t=lae(Math.abs(t)),t?t[1]:NaN}function qWt(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 VWt(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var HWt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function FP(t){if(!(s=HWt.exec(t)))throw new Error("invalid format: "+t);var s;return new Sbe({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]})}FP.prototype=Sbe.prototype;function Sbe(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+""}Sbe.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 WWt(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 cGe;function GWt(t,s){var r=lae(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(cGe=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")+lae(t,Math.max(0,s+o-1))[0]}function EAe(t,s){var r=lae(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 IAe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:UWt,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)=>EAe(t*100,s),r:EAe,s:GWt,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function PAe(t){return t}var LAe=Array.prototype.map,DAe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function KWt(t){var s=t.grouping===void 0||t.thousands===void 0?PAe:qWt(LAe.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?PAe:VWt(LAe.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 h(g){g=FP(g);var v=g.fill,_=g.align,j=g.sign,w=g.symbol,k=g.zero,M=g.width,S=g.comma,E=g.precision,D=g.trim,L=g.type;L==="n"?(S=!0,L="g"):IAe[L]||(E===void 0&&(E=12),D=!0,L="g"),(k||v==="0"&&_==="=")&&(k=!0,v="0",_="=");var B=w==="$"?r:w==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():"",$=w==="$"?n:/[%p]/.test(L)?l:"",V=IAe[L],W=/[defgprs%]/.test(L);E=E===void 0?6:/[gprs]/.test(L)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function G(J){var ne=B,ie=$,ee,de,oe;if(L==="c")ie=V(J)+ie,J="";else{J=+J;var ue=J<0||1/J<0;if(J=isNaN(J)?d:V(Math.abs(J),E),D&&(J=WWt(J)),ue&&+J==0&&j!=="+"&&(ue=!1),ne=(ue?j==="("?j:i:j==="-"||j==="("?"":j)+ne,ie=(L==="s"?DAe[8+cGe/3]:"")+ie+(ue&&j==="("?")":""),W){for(ee=-1,de=J.length;++eeoe||oe>57){ie=(oe===46?a+J.slice(ee+1):J.slice(ee))+ie,J=J.slice(0,ee);break}}}S&&!k&&(J=s(J,1/0));var ce=ne.length+J.length+ie.length,ge=ce>1)+ne+J+ie+ge.slice(ce);break;default:J=ge+ne+J+ie;break}return o(J)}return G.toString=function(){return g+""},G}function f(g,v){var _=h((g=FP(g),g.type="f",g)),j=Math.max(-8,Math.min(8,Math.floor(r3(v)/3)))*3,w=Math.pow(10,-j),k=DAe[8+j/3];return function(M){return _(w*M)+k}}return{format:h,formatPrefix:f}}var k8,Cbe,dGe;ZWt({thousands:",",grouping:[3],currency:["$",""]});function ZWt(t){return k8=KWt(t),Cbe=k8.format,dGe=k8.formatPrefix,k8}function YWt(t){return Math.max(0,-r3(Math.abs(t)))}function XWt(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(r3(s)/3)))*3-r3(Math.abs(t)))}function QWt(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,r3(s)-r3(t))+1}function uGe(t,s,r,n){var a=jxe(t,s,r),o;switch(n=FP(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=XWt(a,l))&&(n.precision=o),dGe(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=QWt(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=YWt(a))&&(n.precision=o-(n.type==="%")*2);break}}return Cbe(n)}function y_(t){var s=t.domain;return t.ticks=function(r){var n=s();return bxe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return uGe(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,h,f=10;for(i0;){if(h=wxe(l,i,r),h===d)return n[a]=l,n[o]=i,s(n);if(h>0)l=Math.floor(l/h)*h,i=Math.ceil(i/h)*h;else if(h<0)l=Math.ceil(l*h)/h,i=Math.floor(i*h)/h;else break;d=h}return t},t}function cae(){var t=Nbe();return t.copy=function(){return dL(t,cae())},cf.apply(t,arguments),y_(t)}function hGe(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,oae),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return hGe(t).unknown(s)},t=arguments.length?Array.from(t,oae):[0,1],y_(r)}function mGe(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 rGt(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 FAe(t){return(s,r)=>-t(-s,r)}function Mbe(t){const s=t(OAe,RAe),r=s.domain;let n=10,a,o;function l(){return a=rGt(n),o=sGt(n),r()[0]<0?(a=FAe(a),o=FAe(o),t(JWt,eGt)):t(OAe,RAe),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 h=d[0],f=d[d.length-1];const g=f0){for(;v<=_;++v)for(j=1;jf)break;M.push(w)}}else for(;v<=_;++v)for(j=n-1;j>=1;--j)if(w=v>0?j/o(-v):j*o(v),!(wf)break;M.push(w)}M.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=FP(d)).precision==null&&(d.trim=!0),d=Cbe(d)),i===1/0)return d;const h=Math.max(1,n*i/s.ticks().length);return f=>{let g=f/o(Math.round(a(f)));return g*nr(mGe(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function pGe(){const t=Mbe(dle()).domain([1,10]);return t.copy=()=>dL(t,pGe()).base(t.base()),cf.apply(t,arguments),t}function zAe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function BAe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function Tbe(t){var s=1,r=t(zAe(s),BAe(s));return r.constant=function(n){return arguments.length?t(zAe(s=+n),BAe(s)):s},y_(r)}function fGe(){var t=Tbe(dle());return t.copy=function(){return dL(t,fGe()).constant(t.constant())},cf.apply(t,arguments)}function $Ae(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function nGt(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function aGt(t){return t<0?-t*t:t*t}function Abe(t){var s=t(_h,_h),r=1;function n(){return r===1?t(_h,_h):r===.5?t(nGt,aGt):t($Ae(r),$Ae(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},y_(s)}function Ebe(){var t=Abe(dle());return t.copy=function(){return dL(t,Ebe()).exponent(t.exponent())},cf.apply(t,arguments),t}function iGt(){return Ebe.apply(null,arguments).exponent(.5)}function UAe(t){return Math.sign(t)*t*t}function oGt(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function gGe(){var t=Nbe(),s=[0,1],r=!1,n;function a(o){var l=oGt(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(UAe(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,oae)).map(UAe)),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 gGe(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},cf.apply(a,arguments),y_(a)}function xGe(){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[h-1],n[h]]},l.unknown=function(d){return arguments.length&&(o=d),l},l.thresholds=function(){return n.slice()},l.copy=function(){return yGe().domain([t,s]).range(a).unknown(o)},cf.apply(y_(l),arguments)}function vGe(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[lL(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 vGe().domain(t).range(s).unknown(r)},cf.apply(a,arguments)}const lme=new Date,cme=new Date;function Ld(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 h;do d.push(h=new Date(+o)),s(o,i),t(o);while(hLd(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)=>(lme.setTime(+o),cme.setTime(+l),t(lme),t(cme),Math.floor(r(lme,cme))),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 dae=Ld(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);dae.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ld(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):dae);dae.range;const Hy=1e3,Up=Hy*60,Wy=Up*60,v0=Wy*24,Ibe=v0*7,qAe=v0*30,dme=v0*365,tk=Ld(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*Hy)},(t,s)=>(s-t)/Hy,t=>t.getUTCSeconds());tk.range;const Pbe=Ld(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Hy)},(t,s)=>{t.setTime(+t+s*Up)},(t,s)=>(s-t)/Up,t=>t.getMinutes());Pbe.range;const Lbe=Ld(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*Up)},(t,s)=>(s-t)/Up,t=>t.getUTCMinutes());Lbe.range;const Dbe=Ld(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Hy-t.getMinutes()*Up)},(t,s)=>{t.setTime(+t+s*Wy)},(t,s)=>(s-t)/Wy,t=>t.getHours());Dbe.range;const Obe=Ld(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*Wy)},(t,s)=>(s-t)/Wy,t=>t.getUTCHours());Obe.range;const uL=Ld(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*Up)/v0,t=>t.getDate()-1);uL.range;const ule=Ld(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/v0,t=>t.getUTCDate()-1);ule.range;const _Ge=Ld(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/v0,t=>Math.floor(t/v0));_Ge.range;function EN(t){return Ld(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())*Up)/Ibe)}const hle=EN(0),uae=EN(1),lGt=EN(2),cGt=EN(3),n3=EN(4),dGt=EN(5),uGt=EN(6);hle.range;uae.range;lGt.range;cGt.range;n3.range;dGt.range;uGt.range;function IN(t){return Ld(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)/Ibe)}const mle=IN(0),hae=IN(1),hGt=IN(2),mGt=IN(3),a3=IN(4),pGt=IN(5),fGt=IN(6);mle.range;hae.range;hGt.range;mGt.range;a3.range;pGt.range;fGt.range;const Rbe=Ld(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());Rbe.range;const Fbe=Ld(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());Fbe.range;const _0=Ld(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());_0.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ld(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)});_0.range;const b0=Ld(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());b0.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ld(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)});b0.range;function bGe(t,s,r,n,a,o){const l=[[tk,1,Hy],[tk,5,5*Hy],[tk,15,15*Hy],[tk,30,30*Hy],[o,1,Up],[o,5,5*Up],[o,15,15*Up],[o,30,30*Up],[a,1,Wy],[a,3,3*Wy],[a,6,6*Wy],[a,12,12*Wy],[n,1,v0],[n,2,2*v0],[r,1,Ibe],[s,1,qAe],[s,3,3*qAe],[t,1,dme]];function i(h,f,g){const v=fk).right(l,v);if(_===l.length)return t.every(jxe(h/dme,f/dme,g));if(_===0)return dae.every(Math.max(jxe(h,f,g),1));const[j,w]=l[v/l[_-1][2]53)return null;"w"in Ie||(Ie.w=1),"Z"in Ie?(he=hme(DA(Ie.y,0,1)),We=he.getUTCDay(),he=We>4||We===0?hae.ceil(he):hae(he),he=ule.offset(he,(Ie.V-1)*7),Ie.y=he.getUTCFullYear(),Ie.m=he.getUTCMonth(),Ie.d=he.getUTCDate()+(Ie.w+6)%7):(he=ume(DA(Ie.y,0,1)),We=he.getDay(),he=We>4||We===0?uae.ceil(he):uae(he),he=uL.offset(he,(Ie.V-1)*7),Ie.y=he.getFullYear(),Ie.m=he.getMonth(),Ie.d=he.getDate()+(Ie.w+6)%7)}else("W"in Ie||"U"in Ie)&&("w"in Ie||(Ie.w="u"in Ie?Ie.u%7:"W"in Ie?1:0),We="Z"in Ie?hme(DA(Ie.y,0,1)).getUTCDay():ume(DA(Ie.y,0,1)).getDay(),Ie.m=0,Ie.d="W"in Ie?(Ie.w+6)%7+Ie.W*7-(We+5)%7:Ie.w+Ie.U*7-(We+6)%7);return"Z"in Ie?(Ie.H+=Ie.Z/100|0,Ie.M+=Ie.Z%100,hme(Ie)):ume(Ie)}}function V(De,Ge,wt,Ie){for(var st=0,he=Ge.length,We=wt.length,et,Ye;st=We)return-1;if(et=Ge.charCodeAt(st++),et===37){if(et=Ge.charAt(st++),Ye=L[et in VAe?Ge.charAt(st++):et],!Ye||(Ie=Ye(De,wt,Ie))<0)return-1}else if(et!=wt.charCodeAt(Ie++))return-1}return Ie}function W(De,Ge,wt){var Ie=h.exec(Ge.slice(wt));return Ie?(De.p=f.get(Ie[0].toLowerCase()),wt+Ie[0].length):-1}function G(De,Ge,wt){var Ie=_.exec(Ge.slice(wt));return Ie?(De.w=j.get(Ie[0].toLowerCase()),wt+Ie[0].length):-1}function J(De,Ge,wt){var Ie=g.exec(Ge.slice(wt));return Ie?(De.w=v.get(Ie[0].toLowerCase()),wt+Ie[0].length):-1}function ne(De,Ge,wt){var Ie=M.exec(Ge.slice(wt));return Ie?(De.m=S.get(Ie[0].toLowerCase()),wt+Ie[0].length):-1}function ie(De,Ge,wt){var Ie=w.exec(Ge.slice(wt));return Ie?(De.m=k.get(Ie[0].toLowerCase()),wt+Ie[0].length):-1}function ee(De,Ge,wt){return V(De,s,Ge,wt)}function de(De,Ge,wt){return V(De,r,Ge,wt)}function oe(De,Ge,wt){return V(De,n,Ge,wt)}function ue(De){return l[De.getDay()]}function ce(De){return o[De.getDay()]}function ge(De){return d[De.getMonth()]}function Te(De){return i[De.getMonth()]}function ve(De){return a[+(De.getHours()>=12)]}function ye(De){return 1+~~(De.getMonth()/3)}function Se(De){return l[De.getUTCDay()]}function Ke(De){return o[De.getUTCDay()]}function Ae(De){return d[De.getUTCMonth()]}function Ee(De){return i[De.getUTCMonth()]}function He(De){return a[+(De.getUTCHours()>=12)]}function Ue(De){return 1+~~(De.getUTCMonth()/3)}return{format:function(De){var Ge=B(De+="",E);return Ge.toString=function(){return De},Ge},parse:function(De){var Ge=$(De+="",!1);return Ge.toString=function(){return De},Ge},utcFormat:function(De){var Ge=B(De+="",D);return Ge.toString=function(){return De},Ge},utcParse:function(De){var Ge=$(De+="",!0);return Ge.toString=function(){return De},Ge}}}var VAe={"-":"",_:" ",0:"0"},ru=/^\s*\d+/,bGt=/^%/,wGt=/[\\^$*+?|[\]().{}]/g;function So(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function kGt(t,s,r){var n=ru.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function NGt(t,s,r){var n=ru.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function SGt(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function CGt(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function MGt(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function HAe(t,s,r){var n=ru.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function WAe(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function TGt(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 AGt(t,s,r){var n=ru.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function EGt(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function GAe(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function IGt(t,s,r){var n=ru.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function KAe(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function PGt(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function LGt(t,s,r){var n=ru.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function DGt(t,s,r){var n=ru.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function OGt(t,s,r){var n=ru.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function RGt(t,s,r){var n=bGt.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function FGt(t,s,r){var n=ru.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function zGt(t,s,r){var n=ru.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function ZAe(t,s){return So(t.getDate(),s,2)}function BGt(t,s){return So(t.getHours(),s,2)}function $Gt(t,s){return So(t.getHours()%12||12,s,2)}function UGt(t,s){return So(1+uL.count(_0(t),t),s,3)}function wGe(t,s){return So(t.getMilliseconds(),s,3)}function qGt(t,s){return wGe(t,s)+"000"}function VGt(t,s){return So(t.getMonth()+1,s,2)}function HGt(t,s){return So(t.getMinutes(),s,2)}function WGt(t,s){return So(t.getSeconds(),s,2)}function GGt(t){var s=t.getDay();return s===0?7:s}function KGt(t,s){return So(hle.count(_0(t)-1,t),s,2)}function jGe(t){var s=t.getDay();return s>=4||s===0?n3(t):n3.ceil(t)}function ZGt(t,s){return t=jGe(t),So(n3.count(_0(t),t)+(_0(t).getDay()===4),s,2)}function YGt(t){return t.getDay()}function XGt(t,s){return So(uae.count(_0(t)-1,t),s,2)}function QGt(t,s){return So(t.getFullYear()%100,s,2)}function JGt(t,s){return t=jGe(t),So(t.getFullYear()%100,s,2)}function eKt(t,s){return So(t.getFullYear()%1e4,s,4)}function tKt(t,s){var r=t.getDay();return t=r>=4||r===0?n3(t):n3.ceil(t),So(t.getFullYear()%1e4,s,4)}function sKt(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+So(s/60|0,"0",2)+So(s%60,"0",2)}function YAe(t,s){return So(t.getUTCDate(),s,2)}function rKt(t,s){return So(t.getUTCHours(),s,2)}function nKt(t,s){return So(t.getUTCHours()%12||12,s,2)}function aKt(t,s){return So(1+ule.count(b0(t),t),s,3)}function kGe(t,s){return So(t.getUTCMilliseconds(),s,3)}function iKt(t,s){return kGe(t,s)+"000"}function oKt(t,s){return So(t.getUTCMonth()+1,s,2)}function lKt(t,s){return So(t.getUTCMinutes(),s,2)}function cKt(t,s){return So(t.getUTCSeconds(),s,2)}function dKt(t){var s=t.getUTCDay();return s===0?7:s}function uKt(t,s){return So(mle.count(b0(t)-1,t),s,2)}function NGe(t){var s=t.getUTCDay();return s>=4||s===0?a3(t):a3.ceil(t)}function hKt(t,s){return t=NGe(t),So(a3.count(b0(t),t)+(b0(t).getUTCDay()===4),s,2)}function mKt(t){return t.getUTCDay()}function pKt(t,s){return So(hae.count(b0(t)-1,t),s,2)}function fKt(t,s){return So(t.getUTCFullYear()%100,s,2)}function gKt(t,s){return t=NGe(t),So(t.getUTCFullYear()%100,s,2)}function xKt(t,s){return So(t.getUTCFullYear()%1e4,s,4)}function yKt(t,s){var r=t.getUTCDay();return t=r>=4||r===0?a3(t):a3.ceil(t),So(t.getUTCFullYear()%1e4,s,4)}function vKt(){return"+0000"}function XAe(){return"%"}function QAe(t){return+t}function JAe(t){return Math.floor(+t/1e3)}var LC,SGe,CGe;_Kt({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 _Kt(t){return LC=_Gt(t),SGe=LC.format,LC.parse,CGe=LC.utcFormat,LC.utcParse,LC}function bKt(t){return new Date(t)}function wKt(t){return t instanceof Date?+t:+new Date(+t)}function zbe(t,s,r,n,a,o,l,i,d,h){var f=Nbe(),g=f.invert,v=f.domain,_=h(".%L"),j=h(":%S"),w=h("%I:%M"),k=h("%I %p"),M=h("%a %d"),S=h("%b %d"),E=h("%B"),D=h("%Y");function L(B){return(d(B)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>uWt(t,o/n))},r.copy=function(){return EGe(s).domain(t)},M0.apply(r,arguments)}function fle(){var t=0,s=.5,r=1,n=1,a,o,l,i,d,h=_h,f,g=!1,v;function _(w){return isNaN(w=+w)?v:(w=.5+((w=+f(w))-o)*(n*ws}var DGe=TKt,AKt=gle,EKt=DGe,IKt=iM;function PKt(t){return t&&t.length?AKt(t,IKt,EKt):void 0}var LKt=PKt;const xle=fo(LKt);function DKt(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};Vn.decimalPlaces=Vn.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*Il;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};Vn.dividedBy=Vn.div=function(t){return c0(this,new this.constructor(t))};Vn.dividedToIntegerBy=Vn.idiv=function(t){var s=this,r=s.constructor;return sl(c0(s,new r(t),0,1),r.precision)};Vn.equals=Vn.eq=function(t){return!this.cmp(t)};Vn.exponent=function(){return pd(this)};Vn.greaterThan=Vn.gt=function(t){return this.cmp(t)>0};Vn.greaterThanOrEqualTo=Vn.gte=function(t){return this.cmp(t)>=0};Vn.isInteger=Vn.isint=function(){return this.e>this.d.length-2};Vn.isNegative=Vn.isneg=function(){return this.s<0};Vn.isPositive=Vn.ispos=function(){return this.s>0};Vn.isZero=function(){return this.s===0};Vn.lessThan=Vn.lt=function(t){return this.cmp(t)<0};Vn.lessThanOrEqualTo=Vn.lte=function(t){return this.cmp(t)<1};Vn.logarithm=Vn.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(Um))throw Error(rf+"NaN");if(r.s<1)throw Error(rf+(r.s?"NaN":"-Infinity"));return r.eq(Um)?new n(0):(Wl=!1,s=c0(zP(r,o),zP(t,o),o),Wl=!0,sl(s,a))};Vn.minus=Vn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?BGe(s,t):FGe(s,(t.s=-t.s,t))};Vn.modulo=Vn.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(rf+"NaN");return r.s?(Wl=!1,s=c0(r,t,0,1).times(t),Wl=!0,r.minus(s)):sl(new n(r),a)};Vn.naturalExponential=Vn.exp=function(){return zGe(this)};Vn.naturalLogarithm=Vn.ln=function(){return zP(this)};Vn.negated=Vn.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Vn.plus=Vn.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?FGe(s,t):BGe(s,(t.s=-t.s,t))};Vn.precision=Vn.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Vk+t);if(s=pd(a)+1,n=a.d.length-1,r=n*Il+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};Vn.squareRoot=Vn.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(rf+"NaN")}for(t=pd(i),Wl=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=vx(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=dM((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(c0(i,o,l+2)).times(.5),vx(o.d).slice(0,l)===(s=vx(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(sl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return Wl=!0,sl(n,r)};Vn.times=Vn.mul=function(t){var s,r,n,a,o,l,i,d,h,f=this,g=f.constructor,v=f.d,_=(t=new g(t)).d;if(!f.s||!t.s)return new g(0);for(t.s*=f.s,r=f.e+t.e,d=v.length,h=_.length,d=0;){for(s=0,a=d+n;a>n;)i=o[a]+_[n]*v[a-n-1]+s,o[a--]=i%Vd|0,s=i/Vd|0;o[a]=(o[a]+s)%Vd|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,Wl?sl(t,g.precision):t};Vn.toDecimalPlaces=Vn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(qx(t,0,cM),s===void 0?s=n.rounding:qx(s,0,8),sl(r,t+pd(r)+1,s))};Vn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=fN(n,!0):(qx(t,0,cM),s===void 0?s=a.rounding:qx(s,0,8),n=sl(new a(n),t+1,s),r=fN(n,!0,t+1)),r};Vn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?fN(a):(qx(t,0,cM),s===void 0?s=o.rounding:qx(s,0,8),n=sl(new o(a),t+pd(a)+1,s),r=fN(n.abs(),!1,t+pd(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Vn.toInteger=Vn.toint=function(){var t=this,s=t.constructor;return sl(new s(t),pd(t)+1,s.rounding)};Vn.toNumber=function(){return+this};Vn.toPower=Vn.pow=function(t){var s,r,n,a,o,l,i=this,d=i.constructor,h=12,f=+(t=new d(t));if(!t.s)return new d(Um);if(i=new d(i),!i.s){if(t.s<1)throw Error(rf+"Infinity");return i}if(i.eq(Um))return i;if(n=d.precision,t.eq(Um))return sl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=f<0?-f:f)<=RGe){for(a=new d(Um),s=Math.ceil(n/Il+4),Wl=!1;r%2&&(a=a.times(i),sEe(a.d,s)),r=dM(r/2),r!==0;)i=i.times(i),sEe(i.d,s);return Wl=!0,t.s<0?new d(Um).div(a):sl(a,n)}}else if(o<0)throw Error(rf+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,Wl=!1,a=t.times(zP(i,n+h)),Wl=!0,a=zGe(a),a.s=o,a};Vn.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=pd(a),n=fN(a,r<=o.toExpNeg||r>=o.toExpPos)):(qx(t,1,cM),s===void 0?s=o.rounding:qx(s,0,8),a=sl(new o(a),t,s),r=pd(a),n=fN(a,t<=r||r<=o.toExpNeg,t)),n};Vn.toSignificantDigits=Vn.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(qx(t,1,cM),s===void 0?s=n.rounding:qx(s,0,8)),sl(new n(r),t,s)};Vn.toString=Vn.valueOf=Vn.val=Vn.toJSON=Vn[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=pd(t),r=t.constructor;return fN(t,s<=r.toExpNeg||s>=r.toExpPos)};function FGe(t,s){var r,n,a,o,l,i,d,h,f=t.constructor,g=f.precision;if(!t.s||!s.s)return s.s||(s=new f(t)),Wl?sl(s,g):s;if(d=t.d,h=s.d,l=t.e,a=s.e,d=d.slice(),o=l-a,o){for(o<0?(n=d,o=-o,i=h.length):(n=h,a=l,i=d.length),l=Math.ceil(g/Il),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=h.length,i-o<0&&(o=i,n=h,h=d,d=n),r=0;o;)r=(d[--o]=d[o]+h[o]+r)/Vd|0,d[o]%=Vd;for(r&&(d.unshift(r),++a),i=d.length;d[--i]==0;)d.pop();return s.d=d,s.e=a,Wl?sl(s,g):s}function qx(t,s,r){if(t!==~~t||tr)throw Error(Vk+t)}function vx(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,h,f,g,v,_,j,w,k,M,S,E,D,L,B,$,V,W=n.constructor,G=n.s==a.s?1:-1,J=n.d,ne=a.d;if(!n.s)return new W(n);if(!a.s)throw Error(rf+"Division by zero");for(d=n.e-a.e,$=ne.length,L=J.length,_=new W(G),j=_.d=[],h=0;ne[h]==(J[h]||0);)++h;if(ne[h]>(J[h]||0)&&--d,o==null?S=o=W.precision:l?S=o+(pd(n)-pd(a))+1:S=o,S<0)return new W(0);if(S=S/Il+2|0,h=0,$==1)for(f=0,ne=ne[0],S++;(h1&&(ne=t(ne,f),J=t(J,f),$=ne.length,L=J.length),D=$,w=J.slice(0,$),k=w.length;k<$;)w[k++]=0;V=ne.slice(),V.unshift(0),B=ne[0],ne[1]>=Vd/2&&++B;do f=0,i=s(ne,w,$,k),i<0?(M=w[0],$!=k&&(M=M*Vd+(w[1]||0)),f=M/B|0,f>1?(f>=Vd&&(f=Vd-1),g=t(ne,f),v=g.length,k=w.length,i=s(g,w,v,k),i==1&&(f--,r(g,$16)throw Error(Ube+pd(t));if(!t.s)return new f(Um);for(Wl=!1,i=g,l=new f(.03125);t.abs().gte(.1);)t=t.times(l),h+=5;for(n=Math.log(Oj(2,h))/Math.LN10*2+5|0,i+=n,r=a=o=new f(Um),f.precision=i;;){if(a=sl(a.times(t),i),r=r.times(++d),l=o.plus(c0(a,r,i)),vx(l.d).slice(0,i)===vx(o.d).slice(0,i)){for(;h--;)o=sl(o.times(o),i);return f.precision=g,s==null?(Wl=!0,sl(o,g)):o}o=l}}function pd(t){for(var s=t.e*Il,r=t.d[0];r>=10;r/=10)s++;return s}function mme(t,s,r){if(s>t.LN10.sd())throw Wl=!0,r&&(t.precision=r),Error(rf+"LN10 precision limit exceeded");return sl(new t(t.LN10),s)}function $v(t){for(var s="";t--;)s+="0";return s}function zP(t,s){var r,n,a,o,l,i,d,h,f,g=1,v=10,_=t,j=_.d,w=_.constructor,k=w.precision;if(_.s<1)throw Error(rf+(_.s?"NaN":"-Infinity"));if(_.eq(Um))return new w(0);if(s==null?(Wl=!1,h=k):h=s,_.eq(10))return s==null&&(Wl=!0),mme(w,h);if(h+=v,w.precision=h,r=vx(j),n=r.charAt(0),o=pd(_),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)_=_.times(t),r=vx(_.d),n=r.charAt(0),g++;o=pd(_),n>1?(_=new w("0."+r),o++):_=new w(n+"."+r.slice(1))}else return d=mme(w,h+2,k).times(o+""),_=zP(new w(n+"."+r.slice(1)),h-v).plus(d),w.precision=k,s==null?(Wl=!0,sl(_,k)):_;for(i=l=_=c0(_.minus(Um),_.plus(Um),h),f=sl(_.times(_),h),a=3;;){if(l=sl(l.times(f),h),d=i.plus(c0(l,new w(a),h)),vx(d.d).slice(0,h)===vx(i.d).slice(0,h))return i=i.times(2),o!==0&&(i=i.plus(mme(w,h+2,k).times(o+""))),i=c0(i,new w(g),h),w.precision=k,s==null?(Wl=!0,sl(i,k)):i;i=d,a+=2}}function tEe(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=dM(r/Il),t.d=[],n=(r+1)%Il,r<0&&(n+=Il),nmae||t.e<-mae))throw Error(Ube+r)}else t.s=0,t.e=0,t.d=[0];return t}function sl(t,s,r){var n,a,o,l,i,d,h,f,g=t.d;for(l=1,o=g[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=Il,a=s,h=g[f=0];else{if(f=Math.ceil((n+1)/Il),o=g.length,f>=o)return t;for(h=o=g[f],l=1;o>=10;o/=10)l++;n%=Il,a=n-Il+l}if(r!==void 0&&(o=Oj(10,l-a-1),i=h/o%10|0,d=s<0||g[f+1]!==void 0||h%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?h/Oj(10,l-a):0:g[f-1])%10&1||r==(t.s<0?8:7))),s<1||!g[0])return d?(o=pd(t),g.length=1,s=s-o-1,g[0]=Oj(10,(Il-s%Il)%Il),t.e=dM(-s/Il)||0):(g.length=1,g[0]=t.e=t.s=0),t;if(n==0?(g.length=f,o=1,f--):(g.length=f+1,o=Oj(10,Il-n),g[f]=a>0?(h/Oj(10,l-a)%Oj(10,a)|0)*o:0),d)for(;;)if(f==0){(g[0]+=o)==Vd&&(g[0]=1,++t.e);break}else{if(g[f]+=o,g[f]!=Vd)break;g[f--]=0,o=1}for(n=g.length;g[--n]===0;)g.pop();if(Wl&&(t.e>mae||t.e<-mae))throw Error(Ube+pd(t));return t}function BGe(t,s){var r,n,a,o,l,i,d,h,f,g,v=t.constructor,_=v.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new v(t),Wl?sl(s,_):s;if(d=t.d,g=s.d,n=s.e,h=t.e,d=d.slice(),l=h-n,l){for(f=l<0,f?(r=d,l=-l,i=g.length):(r=g,n=h,i=d.length),a=Math.max(Math.ceil(_/Il),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,f=a0;--a)d[i++]=0;for(a=g.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+$v(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+$v(-a-1)+o,r&&(n=r-l)>0&&(o+=$v(n))):a>=l?(o+=$v(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+$v(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=$v(n))),t.s<0?"-"+o:o}function sEe(t,s){if(t.length>s)return t.length=s,!0}function $Ge(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(Vk+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 tEe(l,o.toString())}else if(typeof o!="string")throw Error(Vk+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,sZt.test(o))tEe(l,o);else throw Error(Vk+o)}if(a.prototype=Vn,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=$Ge,a.config=a.set=rZt,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(Vk+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(Vk+r+": "+n);return this}var qbe=$Ge(tZt);Um=new qbe(1);const Xo=qbe;function nZt(t){return lZt(t)||oZt(t)||iZt(t)||aZt()}function aZt(){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 iZt(t,s){if(t){if(typeof t=="string")return Mxe(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 Mxe(t,s)}}function oZt(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function lZt(t){if(Array.isArray(t))return Mxe(t)}function Mxe(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,rEe(function(){for(var i=arguments.length,d=new Array(i),h=0;ht.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 jZt(t){if(Array.isArray(t))return t}function WGe(t){var s=BP(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function GGe(t,s,r){if(t.lte(0))return new Xo(0);var n=ble.getDigitCount(t.toNumber()),a=new Xo(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new Xo(Math.ceil(o.div(l).toNumber())).add(r).mul(l),d=i.mul(a);return s?d:new Xo(Math.ceil(d))}function kZt(t,s,r){var n=1,a=new Xo(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new Xo(10).pow(ble.getDigitCount(t)-1),a=new Xo(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new Xo(Math.floor(t)))}else t===0?a=new Xo(Math.floor((s-1)/2)):r||(a=new Xo(Math.floor(t)));var l=Math.floor((s-1)/2),i=hZt(uZt(function(d){return a.add(new Xo(d-l).mul(n)).toNumber()}),Txe);return i(0,s)}function KGe(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 Xo(0),tickMin:new Xo(0),tickMax:new Xo(0)};var o=GGe(new Xo(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new Xo(0):(l=new Xo(t).add(s).div(2),l=l.sub(new Xo(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),d=Math.ceil(new Xo(s).sub(l).div(o).toNumber()),h=i+d+1;return h>r?KGe(t,s,r,n,a+1):(h0?d+(r-h):d,i=s>0?i:i+(r-h)),{step:o,tickMin:l.sub(new Xo(i).mul(o)),tickMax:l.add(new Xo(d).mul(o))})}function NZt(t){var s=BP(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=WGe([r,n]),d=BP(i,2),h=d[0],f=d[1];if(h===-1/0||f===1/0){var g=f===1/0?[h].concat(Exe(Txe(0,a-1).map(function(){return 1/0}))):[].concat(Exe(Txe(0,a-1).map(function(){return-1/0})),[f]);return r>n?Axe(g):g}if(h===f)return kZt(h,a,o);var v=KGe(h,f,l,o),_=v.step,j=v.tickMin,w=v.tickMax,k=ble.rangeStep(j,w.add(new Xo(.1).mul(_)),_);return r>n?Axe(k):k}function SZt(t,s){var r=BP(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=WGe([n,a]),i=BP(l,2),d=i[0],h=i[1];if(d===-1/0||h===1/0)return[n,a];if(d===h)return[d];var f=Math.max(s,2),g=GGe(new Xo(h).sub(d).div(f-1),o,0),v=[].concat(Exe(ble.rangeStep(new Xo(d),new Xo(h).sub(new Xo(.99).mul(g)),g)),[h]);return n>a?Axe(v):v}var CZt=VGe(NZt),MZt=VGe(SZt),TZt="Invariant failed";function gN(t,s){throw new Error(TZt)}var AZt=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function i3(t){"@babel/helpers - typeof";return i3=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},i3(t)}function pae(){return pae=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 RZt(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 FZt(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function zZt(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,h=0;h0?a[h-1].coordinate:a[i-1].coordinate,g=a[h].coordinate,v=h>=i-1?a[0].coordinate:a[h+1].coordinate,_=void 0;if(yh(g-f)!==yh(v-g)){var j=[];if(yh(v-g)===yh(d[1]-d[0])){_=v;var w=g+d[1]-d[0];j[0]=Math.min(w,(w+f)/2),j[1]=Math.max(w,(w+f)/2)}else{_=f;var k=v+d[1]-d[0];j[0]=Math.min(g,(k+g)/2),j[1]=Math.max(g,(k+g)/2)}var M=[Math.min(g,(_+g)/2),Math.max(g,(_+g)/2)];if(s>M[0]&&s<=M[1]||s>=j[0]&&s<=j[1]){l=a[h].index;break}}else{var S=Math.min(f,v),E=Math.max(f,v);if(s>(S+g)/2&&s<=(E+g)/2){l=a[h].index;break}}}else for(var D=0;D0&&D(n[D].coordinate+n[D-1].coordinate)/2&&s<=(n[D].coordinate+n[D+1].coordinate)/2||D===i-1&&s>(n[D].coordinate+n[D-1].coordinate)/2){l=n[D].index;break}return l},Vbe=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?jc(jc({},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},sYt=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,h=i.length;d=0});if(M&&M.length){var S=M[0].type.defaultProps,E=S!==void 0?jc(jc({},S),M[0].props):M[0].props,D=E.barSize,L=E[k];l[L]||(l[L]=[]);var B=Wi(D)?r:D;l[L].push({item:M[0],stackList:M.slice(1),barSize:Wi(B)?void 0:vh(B,n,0)})}}return l},rYt=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 h=vh(r,a,0,!0),f,g=[];if(l[0].barSize===+l[0].barSize){var v=!1,_=a/d,j=l.reduce(function(D,L){return D+L.barSize||0},0);j+=(d-1)*h,j>=a&&(j-=(d-1)*h,h=0),j>=a&&_>0&&(v=!0,_*=.9,j=d*_);var w=(a-j)/2>>0,k={offset:w-h,size:0};f=l.reduce(function(D,L){var B={item:L.item,position:{offset:k.offset+k.size+h,size:v?_:L.barSize}},$=[].concat(iEe(D),[B]);return k=$[$.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(V){$.push({item:V,position:k})}),$},g)}else{var M=vh(n,a,0,!0);a-2*M-(d-1)*h<=0&&(h=0);var S=(a-2*M-(d-1)*h)/d;S>1&&(S>>=0);var E=i===+i?Math.min(S,i):S;f=l.reduce(function(D,L,B){var $=[].concat(iEe(D),[{item:L.item,position:{offset:M+(S+h)*B+(S-E)/2,size:E}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(V){$.push({item:V,position:$[$.length-1].position})}),$},g)}return f},nYt=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),h=QGe({children:o,legendWidth:d});if(h){var f=a||{},g=f.width,v=f.height,_=h.align,j=h.verticalAlign,w=h.layout;if((w==="vertical"||w==="horizontal"&&j==="middle")&&_!=="center"&&Zr(s[_]))return jc(jc({},s),{},c5({},_,s[_]+(g||0)));if((w==="horizontal"||w==="vertical"&&_==="center")&&j!=="middle"&&Zr(s[j]))return jc(jc({},s),{},c5({},j,s[j]+(v||0)))}return s},aYt=function(s,r,n){return Wi(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},JGe=function(s,r,n,a,o){var l=r.props.children,i=Jp(l,wle).filter(function(h){return aYt(a,o,h.props.direction)});if(i&&i.length){var d=i.map(function(h){return h.props.dataKey});return s.reduce(function(h,f){var g=Ou(f,n);if(Wi(g))return h;var v=Array.isArray(g)?[yle(g),xle(g)]:[g,g],_=d.reduce(function(j,w){var k=Ou(f,w,0),M=v[0]-Math.abs(Array.isArray(k)?k[0]:k),S=v[1]+Math.abs(Array.isArray(k)?k[1]:k);return[Math.min(M,j[0]),Math.max(S,j[1])]},[1/0,-1/0]);return[Math.min(_[0],h[0]),Math.max(_[1],h[1])]},[1/0,-1/0])}return null},iYt=function(s,r,n,a,o){var l=r.map(function(i){return JGe(s,i,n,o,a)}).filter(function(i){return!Wi(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},eKe=function(s,r,n,a,o){var l=r.map(function(d){var h=d.props.dataKey;return n==="number"&&h&&JGe(s,d,h,a)||jI(s,h,n,o)});if(n==="number")return l.reduce(function(d,h){return[Math.min(d[0],h[0]),Math.max(d[1],h[1])]},[1/0,-1/0]);var i={};return l.reduce(function(d,h){for(var f=0,g=h.length;f=2?yh(i[0]-i[1])*2*h:h,r&&(s.ticks||s.niceTicks)){var f=(s.ticks||s.niceTicks).map(function(g){var v=o?o.indexOf(g):g;return{coordinate:a(v)+h,value:g,offset:h}});return f.filter(function(g){return!aL(g.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(g,v){return{coordinate:a(g)+h,value:g,index:v,offset:h}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(g){return{coordinate:a(g)+h,value:g,offset:h}}):a.domain().map(function(g,v){return{coordinate:a(g)+h,value:o?o[g]:g,index:v,offset:h}})},pme=new WeakMap,N8=function(s,r){if(typeof r!="function")return s;pme.has(s)||pme.set(s,new WeakMap);var n=pme.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},rKe=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:LP(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:cae(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:wI(),realScaleType:"point"}:o==="category"?{scale:LP(),realScaleType:"band"}:{scale:cae(),realScaleType:"linear"};if(hN(a)){var d="scale".concat(sle(a));return{scale:(eEe[d]||wI)(),realScaleType:eEe[d]?d:"point"}}return hi(a)?{scale:a}:{scale:wI(),realScaleType:"point"}},lEe=1e-4,nKe=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])-lEe,l=Math.max(a[0],a[1])+lEe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},oYt=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])}},dYt=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)}},uYt={sign:cYt,expand:AFt,none:Q5,silhouette:EFt,wiggle:IFt,positive:dYt},hYt=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=uYt[n],l=TFt().keys(a).value(function(i,d){return+Ou(i,d,0)}).order(nxe).offset(o);return l(s)},mYt=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,d={},h=i.reduce(function(g,v){var _,j=(_=v.type)!==null&&_!==void 0&&_.defaultProps?jc(jc({},v.type.defaultProps),v.props):v.props,w=j.stackId,k=j.hide;if(k)return g;var M=j[n],S=g[M]||{hasStack:!1,stackGroups:{}};if(Md(w)){var E=S.stackGroups[w]||{numericAxisId:n,cateAxisId:a,items:[]};E.items.push(v),S.hasStack=!0,S.stackGroups[w]=E}else S.stackGroups[iL("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[v]};return jc(jc({},g),{},c5({},M,S))},d),f={};return Object.keys(h).reduce(function(g,v){var _=h[v];if(_.hasStack){var j={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(w,k){var M=_.stackGroups[k];return jc(jc({},w),{},c5({},k,{numericAxisId:n,cateAxisId:a,items:M.items,stackedData:hYt(s,M.items,o)}))},j)}return jc(jc({},g),{},c5({},v,_))},f)},aKe=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 h=s.domain();if(!h.length)return null;var f=CZt(h,o,i);return s.domain([yle(f),xle(f)]),{niceTicks:f}}if(o&&a==="number"){var g=s.domain(),v=MZt(g,o,i);return{niceTicks:v}}return null},cEe=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=Ou(l,r.dataKey,r.domain[i]);return Wi(d)?null:r.scale(d)-o/2+a},pYt=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]},fYt=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?jc(jc({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(Md(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},gYt=function(s){return s.reduce(function(r,n){return[yle(n.concat([r[0]]).filter(Zr)),xle(n.concat([r[1]]).filter(Zr))]},[1/0,-1/0])},iKe=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,d=i.reduce(function(h,f){var g=gYt(f.slice(r,n+1));return[Math.min(h[0],g[0]),Math.max(h[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})},dEe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,uEe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Dxe=function(s,r,n){if(hi(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(Zr(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(dEe.test(s[0])){var o=+dEe.exec(s[0])[1];a[0]=r[0]-o}else hi(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(Zr(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(uEe.test(s[1])){var l=+uEe.exec(s[1])[1];a[1]=r[1]+l}else hi(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},gae=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=ybe(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},NYt=function(s,r,n,a,o){var l=s.width,i=s.height,d=s.startAngle,h=s.endAngle,f=vh(s.cx,l,l/2),g=vh(s.cy,i,i/2),v=cKe(l,i,n),_=vh(s.innerRadius,v,0),j=vh(s.outerRadius,v,v*.8),w=Object.keys(r);return w.reduce(function(k,M){var S=r[M],E=S.domain,D=S.reversed,L;if(Wi(S.range))a==="angleAxis"?L=[d,h]:a==="radiusAxis"&&(L=[_,j]),D&&(L=[L[1],L[0]]);else{L=S.range;var B=L,$=vYt(B,2);d=$[0],h=$[1]}var V=rKe(S,o),W=V.realScaleType,G=V.scale;G.domain(E).range(L),nKe(G);var J=aKe(G,Py(Py({},S),{},{realScaleType:W})),ne=Py(Py(Py({},S),J),{},{range:L,radius:j,realScaleType:W,scale:G,cx:f,cy:g,innerRadius:_,outerRadius:j,startAngle:d,endAngle:h});return Py(Py({},k),{},lKe({},M,ne))},{})},SYt=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))},CYt=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=SYt({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var d=(n-o)/i,h=Math.acos(d);return a>l&&(h=2*Math.PI-h),{radius:i,angle:kYt(h),angleInRadian:h}},MYt=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}},TYt=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},fEe=function(s,r){var n=s.x,a=s.y,o=CYt({x:n,y:a},r),l=o.radius,i=o.angle,d=r.innerRadius,h=r.outerRadius;if(lh)return!1;if(l===0)return!0;var f=MYt(r),g=f.startAngle,v=f.endAngle,_=i,j;if(g<=v){for(;_>v;)_-=360;for(;_=g&&_<=v}else{for(;_>g;)_-=360;for(;_=v&&_<=g}return j?Py(Py({},r),{},{radius:l,angle:TYt(_,r)}):null},dKe=function(s){return!T.isValidElement(s)&&!hi(s)&&typeof s!="boolean"?s.className:""};function VP(t){"@babel/helpers - typeof";return VP=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},VP(t)}var AYt=["offset"];function EYt(t){return DYt(t)||LYt(t)||PYt(t)||IYt()}function IYt(){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 PYt(t,s){if(t){if(typeof t=="string")return Oxe(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 Oxe(t,s)}}function LYt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function DYt(t){if(Array.isArray(t))return Oxe(t)}function Oxe(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 RYt(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 gEe(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 vd(t){for(var s=1;s=0?1:-1,E,D;a==="insideStart"?(E=_+S*l,D=w):a==="insideEnd"?(E=j-S*l,D=!w):a==="end"&&(E=j+S*l,D=w),D=M<=0?D:!D;var L=xl(h,f,k,E),B=xl(h,f,k,E+(D?1:-1)*359),$="M".concat(L.x,",").concat(L.y,` A`).concat(k,",").concat(k,",0,1,").concat(D?0:1,`, `).concat(B.x,",").concat(B.y),V=Wi(s.id)?iL("recharts-radial-line-"):s.id;return lt.createElement("text",HP({},n,{dominantBaseline:"central",className:Ai("recharts-radial-bar-label",i)}),lt.createElement("defs",null,lt.createElement("path",{id:V,d:$})),lt.createElement("textPath",{xlinkHref:"#".concat(V)},r))},VYt=function(s){var r=s.viewBox,n=s.offset,a=s.position,o=r,l=o.cx,i=o.cy,d=o.innerRadius,h=o.outerRadius,f=o.startAngle,g=o.endAngle,v=(f+g)/2;if(a==="outside"){var _=xl(l,i,h+n,v),j=_.x,w=_.y;return{x:j,y:w,textAnchor:j>=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 k=(d+h)/2,M=xl(l,i,k,v),S=M.x,E=M.y;return{x:S,y:E,textAnchor:"middle",verticalAnchor:"middle"}},HYt=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,o=s.position,l=r,i=l.x,d=l.y,h=l.width,f=l.height,g=f>=0?1:-1,v=g*a,_=g>0?"end":"start",j=g>0?"start":"end",w=h>=0?1:-1,k=w*a,M=w>0?"end":"start",S=w>0?"start":"end";if(o==="top"){var E={x:i+h/2,y:d-g*a,textAnchor:"middle",verticalAnchor:_};return vd(vd({},E),n?{height:Math.max(d-n.y,0),width:h}:{})}if(o==="bottom"){var D={x:i+h/2,y:d+f+v,textAnchor:"middle",verticalAnchor:j};return vd(vd({},D),n?{height:Math.max(n.y+n.height-(d+f),0),width:h}:{})}if(o==="left"){var L={x:i-k,y:d+f/2,textAnchor:M,verticalAnchor:"middle"};return vd(vd({},L),n?{width:Math.max(L.x-n.x,0),height:f}:{})}if(o==="right"){var B={x:i+h+k,y:d+f/2,textAnchor:S,verticalAnchor:"middle"};return vd(vd({},B),n?{width:Math.max(n.x+n.width-B.x,0),height:f}:{})}var $=n?{width:h,height:f}:{};return o==="insideLeft"?vd({x:i+k,y:d+f/2,textAnchor:S,verticalAnchor:"middle"},$):o==="insideRight"?vd({x:i+h-k,y:d+f/2,textAnchor:M,verticalAnchor:"middle"},$):o==="insideTop"?vd({x:i+h/2,y:d+v,textAnchor:"middle",verticalAnchor:j},$):o==="insideBottom"?vd({x:i+h/2,y:d+f-v,textAnchor:"middle",verticalAnchor:_},$):o==="insideTopLeft"?vd({x:i+k,y:d+v,textAnchor:S,verticalAnchor:j},$):o==="insideTopRight"?vd({x:i+h-k,y:d+v,textAnchor:M,verticalAnchor:j},$):o==="insideBottomLeft"?vd({x:i+k,y:d+f-v,textAnchor:S,verticalAnchor:_},$):o==="insideBottomRight"?vd({x:i+h-k,y:d+f-v,textAnchor:M,verticalAnchor:_},$):eM(o)&&(Zr(o.x)||Jj(o.x))&&(Zr(o.y)||Jj(o.y))?vd({x:i+vh(o.x,h),y:d+vh(o.y,f),textAnchor:"end",verticalAnchor:"end"},$):vd({x:i+h/2,y:d+f/2,textAnchor:"middle",verticalAnchor:"middle"},$)},WYt=function(s){return"cx"in s&&Zr(s.cx)};function Zd(t){var s=t.offset,r=s===void 0?5:s,n=OYt(t,AYt),a=vd({offset:r},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,h=a.content,f=a.className,g=f===void 0?"":f,v=a.textBreakAll;if(!o||Wi(i)&&Wi(d)&&!T.isValidElement(h)&&!hi(h))return null;if(T.isValidElement(h))return T.cloneElement(h,a);var _;if(hi(h)){if(_=T.createElement(h,a),T.isValidElement(_))return _}else _=$Yt(a);var j=WYt(o),w=ni(a,!0);if(j&&(l==="insideStart"||l==="insideEnd"||l==="end"))return qYt(a,_,w);var k=j?VYt(a):HYt(a);return lt.createElement(pN,HP({className:Ai("recharts-label",g)},w,k,{breakAll:v}),_)}Zd.displayName="Label";var uKe=function(s){var r=s.cx,n=s.cy,a=s.angle,o=s.startAngle,l=s.endAngle,i=s.r,d=s.radius,h=s.innerRadius,f=s.outerRadius,g=s.x,v=s.y,_=s.top,j=s.left,w=s.width,k=s.height,M=s.clockWise,S=s.labelViewBox;if(S)return S;if(Zr(w)&&Zr(k)){if(Zr(g)&&Zr(v))return{x:g,y:v,width:w,height:k};if(Zr(_)&&Zr(j))return{x:_,y:j,width:w,height:k}}return Zr(g)&&Zr(v)?{x:g,y:v,width:0,height:0}:Zr(r)&&Zr(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:h||0,outerRadius:f||d||i||0,clockWise:M}:s.viewBox?s.viewBox:{}},GYt=function(s,r){return s?s===!0?lt.createElement(Zd,{key:"label-implicit",viewBox:r}):Md(s)?lt.createElement(Zd,{key:"label-implicit",viewBox:r,value:s}):T.isValidElement(s)?s.type===Zd?T.cloneElement(s,{key:"label-implicit",viewBox:r}):lt.createElement(Zd,{key:"label-implicit",content:s,viewBox:r}):hi(s)?lt.createElement(Zd,{key:"label-implicit",content:s,viewBox:r}):eM(s)?lt.createElement(Zd,HP({viewBox:r},s,{key:"label-implicit"})):null:null},KYt=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=uKe(s),l=Jp(a,Zd).map(function(d,h){return T.cloneElement(d,{viewBox:r||o,key:"label-".concat(h)})});if(!n)return l;var i=GYt(s.label,r||o);return[i].concat(EYt(l))};Zd.parseViewBox=uKe;Zd.renderCallByParent=KYt;function ZYt(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var YYt=ZYt;const XYt=fo(YYt);function WP(t){"@babel/helpers - typeof";return WP=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},WP(t)}var QYt=["valueAccessor"],JYt=["data","dataKey","clockWise","id","textBreakAll"];function eXt(t){return nXt(t)||rXt(t)||sXt(t)||tXt()}function tXt(){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 sXt(t,s){if(t){if(typeof t=="string")return Rxe(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 Rxe(t,s)}}function rXt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function nXt(t){if(Array.isArray(t))return Rxe(t)}function Rxe(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 lXt(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 cXt=function(s){return Array.isArray(s.value)?XYt(s.value):s.value};function q1(t){var s=t.valueAccessor,r=s===void 0?cXt:s,n=vEe(t,QYt),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,h=vEe(n,JYt);return!a||!a.length?null:lt.createElement(Vo,{className:"recharts-label-list"},a.map(function(f,g){var v=Wi(o)?r(f,g):Ou(f&&f.payload,o),_=Wi(i)?{}:{id:"".concat(i,"-").concat(g)};return lt.createElement(Zd,yae({},ni(f,!0),h,_,{parentViewBox:f.parentViewBox,value:v,textBreakAll:d,viewBox:Zd.parseViewBox(Wi(l)?f:yEe(yEe({},f),{},{clockWise:l})),key:"label-".concat(g),index:g}))}))}q1.displayName="LabelList";function dXt(t,s){return t?t===!0?lt.createElement(q1,{key:"labelList-implicit",data:s}):lt.isValidElement(t)||hi(t)?lt.createElement(q1,{key:"labelList-implicit",data:s,content:t}):eM(t)?lt.createElement(q1,yae({data:s},t,{key:"labelList-implicit"})):null:null}function uXt(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=Jp(n,q1).map(function(l,i){return T.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=dXt(t.label,s);return[o].concat(eXt(a))}q1.renderCallByParent=uXt;function GP(t){"@babel/helpers - typeof";return GP=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},GP(t)}function Fxe(){return Fxe=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>h),`, `).concat(g.x,",").concat(g.y,` `);if(a>0){var _=xl(r,n,a,l),j=xl(r,n,a,h);v+="L ".concat(j.x,",").concat(j.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(d)>180),",").concat(+(l<=h),`, `).concat(_.x,",").concat(_.y," Z")}else v+="L ".concat(r,",").concat(n," Z");return v},gXt=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,o=s.outerRadius,l=s.cornerRadius,i=s.forceCornerRadius,d=s.cornerIsExternal,h=s.startAngle,f=s.endAngle,g=yh(f-h),v=S8({cx:r,cy:n,radius:o,angle:h,sign:g,cornerRadius:l,cornerIsExternal:d}),_=v.circleTangency,j=v.lineTangency,w=v.theta,k=S8({cx:r,cy:n,radius:o,angle:f,sign:-g,cornerRadius:l,cornerIsExternal:d}),M=k.circleTangency,S=k.lineTangency,E=k.theta,D=d?Math.abs(h-f):Math.abs(h-f)-w-E;if(D<0)return i?"M ".concat(j.x,",").concat(j.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 `):hKe({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:h,endAngle:f});var L="M ".concat(j.x,",").concat(j.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(D>180),",").concat(+(g<0),",").concat(M.x,",").concat(M.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(S.x,",").concat(S.y,` `);if(a>0){var B=S8({cx:r,cy:n,radius:a,angle:h,sign:g,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),$=B.circleTangency,V=B.lineTangency,W=B.theta,G=S8({cx:r,cy:n,radius:a,angle:f,sign:-g,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),J=G.circleTangency,ne=G.lineTangency,ie=G.theta,ee=d?Math.abs(h-f):Math.abs(h-f)-W-ie;if(ee<0&&l===0)return"".concat(L,"L").concat(r,",").concat(n,"Z");L+="L".concat(ne.x,",").concat(ne.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(J.x,",").concat(J.y,` A`).concat(a,",").concat(a,",0,").concat(+(ee>180),",").concat(+(g>0),",").concat($.x,",").concat($.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(V.x,",").concat(V.y,"Z")}else L+="L".concat(r,",").concat(n,"Z");return L},xXt={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},mKe=function(s){var r=bEe(bEe({},xXt),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,d=r.forceCornerRadius,h=r.cornerIsExternal,f=r.startAngle,g=r.endAngle,v=r.className;if(l0&&Math.abs(f-g)<360?k=gXt({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(w,j/2),forceCornerRadius:d,cornerIsExternal:h,startAngle:f,endAngle:g}):k=hKe({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:f,endAngle:g}),lt.createElement("path",Fxe({},ni(r,!0),{className:_,d:k,role:"img"}))};function KP(t){"@babel/helpers - typeof";return KP=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},KP(t)}function zxe(){return zxe=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 OXt(t,s){return PN(t.getTime(),s.getTime())}function RXt(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function FXt(t,s){return t===s}function TEe(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 h=s.entries(),f=!1,g=0;(i=h.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)){f=a[g]=!0;break}g++}if(!f)return!1;d++}return!0}var zXt=PN;function BXt(t,s,r){var n=MEe(t),a=n.length;if(MEe(s).length!==a)return!1;for(;a-- >0;)if(!xKe(t,s,r,n[a]))return!1;return!0}function BA(t,s,r){var n=SEe(t),a=n.length;if(SEe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!xKe(t,s,r,o)||(l=CEe(t,o),i=CEe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function $Xt(t,s){return PN(t.valueOf(),s.valueOf())}function UXt(t,s){return t.source===s.source&&t.flags===s.flags}function AEe(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(),h=!1,f=0;(i=d.next())&&!i.done;){if(!a[f]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){h=a[f]=!0;break}f++}if(!h)return!1}return!0}function qXt(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 VXt(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 xKe(t,s,r,n){return(n===LXt||n===PXt||n===IXt)&&(t.$$typeof||s.$$typeof)?!0:EXt(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var HXt="[object Arguments]",WXt="[object Boolean]",GXt="[object Date]",KXt="[object Error]",ZXt="[object Map]",YXt="[object Number]",XXt="[object Object]",QXt="[object RegExp]",JXt="[object Set]",eQt="[object String]",tQt="[object URL]",sQt=Array.isArray,EEe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,IEe=Object.assign,rQt=Object.prototype.toString.call.bind(Object.prototype.toString);function nQt(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,h=t.areRegExpsEqual,f=t.areSetsEqual,g=t.areTypedArraysEqual,v=t.areUrlsEqual;return function(j,w,k){if(j===w)return!0;if(j==null||w==null)return!1;var M=typeof j;if(M!==typeof w)return!1;if(M!=="object")return M==="number"?l(j,w,k):M==="function"?a(j,w,k):!1;var S=j.constructor;if(S!==w.constructor)return!1;if(S===Object)return i(j,w,k);if(sQt(j))return s(j,w,k);if(EEe!=null&&EEe(j))return g(j,w,k);if(S===Date)return r(j,w,k);if(S===RegExp)return h(j,w,k);if(S===Map)return o(j,w,k);if(S===Set)return f(j,w,k);var E=rQt(j);return E===GXt?r(j,w,k):E===QXt?h(j,w,k):E===ZXt?o(j,w,k):E===JXt?f(j,w,k):E===XXt?typeof j.then!="function"&&typeof w.then!="function"&&i(j,w,k):E===tQt?v(j,w,k):E===KXt?n(j,w,k):E===HXt?i(j,w,k):E===WXt||E===YXt||E===eQt?d(j,w,k):!1}}function aQt(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?BA:DXt,areDatesEqual:OXt,areErrorsEqual:RXt,areFunctionsEqual:FXt,areMapsEqual:n?NEe(TEe,BA):TEe,areNumbersEqual:zXt,areObjectsEqual:n?BA:BXt,arePrimitiveWrappersEqual:$Xt,areRegExpsEqual:UXt,areSetsEqual:n?NEe(AEe,BA):AEe,areTypedArraysEqual:n?BA:qXt,areUrlsEqual:VXt};if(r&&(a=IEe({},a,r(a))),s){var o=M8(a.areArraysEqual),l=M8(a.areMapsEqual),i=M8(a.areObjectsEqual),d=M8(a.areSetsEqual);a=IEe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function iQt(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function oQt(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(d,h){var f=n(),g=f.cache,v=g===void 0?s?new WeakMap:void 0:g,_=f.meta;return r(d,h,{cache:v,equals:a,meta:_,strict:o})};if(s)return function(d,h){return r(d,h,{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,h){return r(d,h,l)}}var lQt=__();__({strict:!0});__({circular:!0});__({circular:!0,strict:!0});__({createInternalComparator:function(){return PN}});__({strict:!0,createInternalComparator:function(){return PN}});__({circular:!0,createInternalComparator:function(){return PN}});__({circular:!0,createInternalComparator:function(){return PN},strict:!0});function __(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=aQt(t),d=nQt(i),h=n?n(d):iQt(d);return oQt({circular:r,comparator:d,createState:a,equals:h,strict:l})}function cQt(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function PEe(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):cQt(a)};requestAnimationFrame(n)}function $xe(t){"@babel/helpers - typeof";return $xe=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},$xe(t)}function dQt(t){return pQt(t)||mQt(t)||hQt(t)||uQt()}function uQt(){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 hQt(t,s){if(t){if(typeof t=="string")return LEe(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 LEe(t,s)}}function LEe(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:M<0?0:M},w=function(M){for(var S=M>1?1:M,E=S,D=0;D<8;++D){var L=g(E)-S,B=_(E);if(Math.abs(L-S)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,d=function(f,g,v){var _=-(f-g)*n,j=v*o,w=v+(_-j)*i/1e3,k=v*i/1e3+f;return Math.abs(k-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 HQt(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 fme(t){return ZQt(t)||KQt(t)||GQt(t)||WQt()}function WQt(){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 GQt(t,s){if(t){if(typeof t=="string")return Wxe(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 Wxe(t,s)}}function KQt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ZQt(t){if(Array.isArray(t))return Wxe(t)}function Wxe(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 bae(t){return bae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},bae(t)}var w0=function(t){eJt(r,t);var s=tJt(r);function r(n,a){var o;YQt(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,d=l.attributeName,h=l.from,f=l.to,g=l.steps,v=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(Zxe(o)),o.changeStyle=o.changeStyle.bind(Zxe(o)),!i||_<=0)return o.state={style:{}},typeof v=="function"&&(o.state={style:f}),Kxe(o);if(g&&g.length)o.state={style:g[0].style};else if(h){if(typeof v=="function")return o.state={style:h},Kxe(o);o.state={style:d?iE({},d,h):h}}else o.state={style:{}};return o}return QQt(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,h=o.shouldReAnimate,f=o.to,g=o.from,v=this.state.style;if(i){if(!l){var _={style:d?iE({},d,f):f};this.state&&v&&(d&&v[d]!==f||!d&&v!==f)&&this.setState(_);return}if(!(lQt(a.to,f)&&a.canBegin&&a.isActive)){var j=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var w=j||h?g:a.to;if(this.state&&v){var k={style:d?iE({},d,w):w};(d&&v[d]!==w||!d&&v!==w)&&this.setState(k)}this.runAnimation(Ff(Ff({},this.props),{},{from:w,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,d=a.duration,h=a.easing,f=a.begin,g=a.onAnimationEnd,v=a.onAnimationStart,_=UQt(l,i,EQt(h),d,this.changeStyle),j=function(){o.stopJSAnimation=_()};this.manager.start([v,f,j,d,g])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,h=l[0],f=h.style,g=h.duration,v=g===void 0?0:g,_=function(w,k,M){if(M===0)return w;var S=k.duration,E=k.easing,D=E===void 0?"ease":E,L=k.style,B=k.properties,$=k.onAnimationEnd,V=M>0?l[M-1]:k,W=B||Object.keys(L);if(typeof D=="function"||D==="spring")return[].concat(fme(w),[o.runJSAnimation.bind(o,{from:V.style,to:L,duration:S,easing:D}),S]);var G=REe(W,S,D),J=Ff(Ff(Ff({},V.style),L),{},{transition:G});return[].concat(fme(w),[J,S,$]).filter(vQt)};return this.manager.start([d].concat(fme(l.reduce(_,[f,Math.max(v,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=fQt());var o=a.begin,l=a.duration,i=a.attributeName,d=a.to,h=a.easing,f=a.onAnimationStart,g=a.onAnimationEnd,v=a.steps,_=a.children,j=this.manager;if(this.unSubscribe=j.subscribe(this.handleStyleChange),typeof h=="function"||typeof _=="function"||h==="spring"){this.runJSAnimation(a);return}if(v.length>1){this.runStepAnimation(a);return}var w=i?iE({},i,d):d,k=REe(Object.keys(w),l,h);j.start([f,o,Ff(Ff({},w),{},{transition:k}),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=VQt(a,qQt),h=T.Children.count(o),f=this.state.style;if(typeof o=="function")return o(f);if(!i||h===0||l<=0)return o;var g=function(_){var j=_.props,w=j.style,k=w===void 0?{}:w,M=j.className,S=T.cloneElement(_,Ff(Ff({},d),{},{style:Ff(Ff({},k),f),className:M}));return S};return h===1?g(T.Children.only(o)):lt.createElement("div",null,T.Children.map(o,function(v){return g(v)}))}}]),r}(T.PureComponent);w0.displayName="Animate";w0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};w0.propTypes={from:Lo.oneOfType([Lo.object,Lo.string]),to:Lo.oneOfType([Lo.object,Lo.string]),attributeName:Lo.string,duration:Lo.number,begin:Lo.number,easing:Lo.oneOfType([Lo.string,Lo.func]),steps:Lo.arrayOf(Lo.shape({duration:Lo.number.isRequired,style:Lo.object.isRequired,easing:Lo.oneOfType([Lo.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Lo.func]),properties:Lo.arrayOf("string"),onAnimationEnd:Lo.func})),children:Lo.oneOfType([Lo.node,Lo.func]),isActive:Lo.bool,canBegin:Lo.bool,onAnimationEnd:Lo.func,shouldReAnimate:Lo.bool,onAnimationStart:Lo.func,onAnimationReStart:Lo.func};function XP(t){"@babel/helpers - typeof";return XP=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},XP(t)}function wae(){return wae=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,h=a>=0&&n>=0||a<0&&n<0?1:0,f;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];f="M".concat(s,",").concat(r+i*g[0]),g[0]>0&&(f+="A ".concat(g[0],",").concat(g[0],",0,0,").concat(h,",").concat(s+d*g[0],",").concat(r)),f+="L ".concat(s+n-d*g[1],",").concat(r),g[1]>0&&(f+="A ".concat(g[1],",").concat(g[1],",0,0,").concat(h,`, `).concat(s+n,",").concat(r+i*g[1])),f+="L ".concat(s+n,",").concat(r+a-i*g[2]),g[2]>0&&(f+="A ".concat(g[2],",").concat(g[2],",0,0,").concat(h,`, `).concat(s+n-d*g[2],",").concat(r+a)),f+="L ".concat(s+d*g[3],",").concat(r+a),g[3]>0&&(f+="A ".concat(g[3],",").concat(g[3],",0,0,").concat(h,`, `).concat(s,",").concat(r+a-i*g[3])),f+="Z"}else if(l>0&&o===+o&&o>0){var j=Math.min(l,o);f="M ".concat(s,",").concat(r+i*j,` A `).concat(j,",").concat(j,",0,0,").concat(h,",").concat(s+d*j,",").concat(r,` L `).concat(s+n-d*j,",").concat(r,` A `).concat(j,",").concat(j,",0,0,").concat(h,",").concat(s+n,",").concat(r+i*j,` L `).concat(s+n,",").concat(r+a-i*j,` A `).concat(j,",").concat(j,",0,0,").concat(h,",").concat(s+n-d*j,",").concat(r+a,` L `).concat(s+d*j,",").concat(r+a,` A `).concat(j,",").concat(j,",0,0,").concat(h,",").concat(s,",").concat(r+a-i*j," Z")}else f="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return f},uJt=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 h=Math.min(o,o+i),f=Math.max(o,o+i),g=Math.min(l,l+d),v=Math.max(l,l+d);return n>=h&&n<=f&&a>=g&&a<=v}return!1},hJt={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Hbe=function(s){var r=HEe(HEe({},hJt),s),n=T.useRef(),a=T.useState(-1),o=rJt(a,2),l=o[0],i=o[1];T.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var D=n.current.getTotalLength();D&&i(D)}catch{}},[]);var d=r.x,h=r.y,f=r.width,g=r.height,v=r.radius,_=r.className,j=r.animationEasing,w=r.animationDuration,k=r.animationBegin,M=r.isAnimationActive,S=r.isUpdateAnimationActive;if(d!==+d||h!==+h||f!==+f||g!==+g||f===0||g===0)return null;var E=Ai("recharts-rectangle",_);return S?lt.createElement(w0,{canBegin:l>0,from:{width:f,height:g,x:d,y:h},to:{width:f,height:g,x:d,y:h},duration:w,animationEasing:j,isActive:S},function(D){var L=D.width,B=D.height,$=D.x,V=D.y;return lt.createElement(w0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:k,duration:w,isActive:M,easing:j},lt.createElement("path",wae({},ni(r,!0),{className:E,d:WEe($,V,L,B,v),ref:n})))}):lt.createElement("path",wae({},ni(r,!0),{className:E,d:WEe(d,h,f,g,v)}))},mJt=["points","className","baseLinePoints","connectNulls"];function i4(){return i4=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 fJt(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 GEe(t){return vJt(t)||yJt(t)||xJt(t)||gJt()}function gJt(){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 xJt(t,s){if(t){if(typeof t=="string")return Yxe(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 Yxe(t,s)}}function yJt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function vJt(t){if(Array.isArray(t))return Yxe(t)}function Yxe(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){KEe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),KEe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},NI=function(s,r){var n=_Jt(s);r&&(n=[n.reduce(function(o,l){return[].concat(GEe(o),GEe(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},bJt=function(s,r,n){var a=NI(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(NI(r.reverse(),n).slice(1))},wJt=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=pJt(s,mJt);if(!r||!r.length)return null;var i=Ai("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",h=bJt(r,a,o);return lt.createElement("g",{className:i},lt.createElement("path",i4({},ni(l,!0),{fill:h.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:h})),d?lt.createElement("path",i4({},ni(l,!0),{fill:"none",d:NI(r,o)})):null,d?lt.createElement("path",i4({},ni(l,!0),{fill:"none",d:NI(a,o)})):null)}var f=NI(r,o);return lt.createElement("path",i4({},ni(l,!0),{fill:f.slice(-1)==="Z"?l.fill:"none",className:i,d:f}))};function Xxe(){return Xxe=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 TJt(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 AJt=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},EJt=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,h=d===void 0?0:d,f=s.width,g=f===void 0?0:f,v=s.height,_=v===void 0?0:v,j=s.className,w=MJt(s,jJt),k=kJt({x:n,y:o,top:i,left:h,width:g,height:_},w);return!Zr(n)||!Zr(o)||!Zr(g)||!Zr(_)||!Zr(i)||!Zr(h)?null:lt.createElement("path",Qxe({},ni(k,!0),{className:Ai("recharts-cross",j),d:AJt(n,o,g,_,i,h)}))},IJt=gle,PJt=DGe,LJt=Xx;function DJt(t,s){return t&&t.length?IJt(t,LJt(s),PJt):void 0}var OJt=DJt;const RJt=fo(OJt);var FJt=gle,zJt=Xx,BJt=OGe;function $Jt(t,s){return t&&t.length?FJt(t,zJt(s),BJt):void 0}var UJt=$Jt;const qJt=fo(UJt);var VJt=["cx","cy","angle","ticks","axisLine"],HJt=["ticks","tick","angle","tickFormatter","stroke"];function l3(t){"@babel/helpers - typeof";return l3=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},l3(t)}function SI(){return SI=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 WJt(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 GJt(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function QEe(t,s){for(var r=0;rtIe?l=a==="outer"?"start":"end":o<-tIe?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,h=gb(gb({},ni(this.props,!1)),{},{fill:"none"},ni(i,!1));if(d==="circle")return lt.createElement(Wbe,Uj({className:"recharts-polar-angle-axis-line"},h,{cx:a,cy:o,r:l}));var f=this.props.ticks,g=f.map(function(v){return xl(a,o,l,v.coordinate)});return lt.createElement(wJt,Uj({className:"recharts-polar-angle-axis-line"},h,{points:g}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,d=a.tickFormatter,h=a.stroke,f=ni(this.props,!1),g=ni(l,!1),v=gb(gb({},f),{},{fill:"none"},ni(i,!1)),_=o.map(function(j,w){var k=n.getTickLineCoord(j),M=n.getTickTextAnchor(j),S=gb(gb(gb({textAnchor:M},f),{},{stroke:"none",fill:h},g),{},{index:w,payload:j,x:k.x2,y:k.y2});return lt.createElement(Vo,Uj({className:Ai("recharts-polar-angle-axis-tick",dKe(l)),key:"tick-".concat(j.coordinate)},mN(n.props,j,w)),i&<.createElement("line",Uj({className:"recharts-polar-angle-axis-tick-line"},v,k)),l&&s.renderTickItem(l,S,d?d(j.value,w):j.value))});return lt.createElement(Vo,{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:lt.createElement(Vo,{className:Ai("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return lt.isValidElement(n)?l=lt.cloneElement(n,a):hi(n)?l=n(a):l=lt.createElement(pN,Uj({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(T.PureComponent);Nle(Sle,"displayName","PolarAngleAxis");Nle(Sle,"axisType","angleAxis");Nle(Sle,"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 les=EWe,ces=les(Object.getPrototypeOf,Object),des=ces,ues=S0,hes=des,mes=C0,pes="[object Object]",fes=Function.prototype,ges=Object.prototype,MKe=fes.toString,xes=ges.hasOwnProperty,yes=MKe.call(Object);function ves(t){if(!mes(t)||ues(t)!=pes)return!1;var s=hes(t);if(s===null)return!0;var r=xes.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&MKe.call(r)==yes}var _es=ves;const bes=fo(_es);var wes=S0,jes=C0,kes="[object Boolean]";function Nes(t){return t===!0||t===!1||jes(t)&&wes(t)==kes}var Ses=Nes;const Ces=fo(Ses);function JP(t){"@babel/helpers - typeof";return JP=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},JP(t)}function Nae(){return Nae=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:h},to:{upperWidth:f,lowerWidth:g,height:v,x:d,y:h},duration:w,animationEasing:j,isActive:M},function(E){var D=E.upperWidth,L=E.lowerWidth,B=E.height,$=E.x,V=E.y;return lt.createElement(w0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:k,duration:w,easing:j},lt.createElement("path",Nae({},ni(r,!0),{className:S,d:aIe($,V,D,L,B),ref:n})))}):lt.createElement("g",null,lt.createElement("path",Nae({},ni(r,!0),{className:S,d:aIe(d,h,f,g,v)})))},Fes=["option","shapeType","propTransformer","activeClassName","isActive"];function e6(t){"@babel/helpers - typeof";return e6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},e6(t)}function zes(t,s){if(t==null)return{};var r=Bes(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 Bes(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 iIe(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 Sae(t){for(var s=1;s0?rp(E,"paddingAngle",0):0;if(L){var $=Bv(L.endAngle-L.startAngle,E.endAngle-E.startAngle),V=ml(ml({},E),{},{startAngle:S+B,endAngle:S+$(w)+B});k.push(V),S=V.endAngle}else{var W=E.endAngle,G=E.startAngle,J=Bv(0,W-G),ne=J(w),ie=ml(ml({},E),{},{startAngle:S+B,endAngle:S+ne+B});k.push(ie),S=ie.endAngle}}),lt.createElement(Vo,null,n.renderSectorsStatically(k))})}},{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||!vle(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,h=a.cx,f=a.cy,g=a.innerRadius,v=a.outerRadius,_=a.isAnimationActive,j=this.state.isAnimationFinished;if(o||!l||!l.length||!Zr(h)||!Zr(f)||!Zr(g)||!Zr(v))return null;var w=Ai("recharts-pie",i);return lt.createElement(Vo,{tabIndex:this.props.rootTabIndex,className:w,ref:function(M){n.pieRef=M}},this.renderSectors(),d&&this.renderLabels(l),Zd.renderCallByParent(this.props,null,!1),(!_||j)&&q1.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?S:S-1)*d,D=k-S*_-E,L=a.reduce(function(V,W){var G=Ou(W,M,0);return V+(Zr(G)?G:0)},0),B;if(L>0){var $;B=a.map(function(V,W){var G=Ou(V,M,0),J=Ou(V,f,W),ne=(Zr(G)?G:0)/L,ie;W?ie=$.endAngle+yh(w)*d*(G!==0?1:0):ie=l;var ee=ie+yh(w)*((G!==0?_:0)+ne*D),de=(ie+ee)/2,oe=(j.innerRadius+j.outerRadius)/2,ue=[{name:J,value:G,payload:V,dataKey:M,type:v}],ce=xl(j.cx,j.cy,oe,de);return $=ml(ml(ml({percent:ne,cornerRadius:o,name:J,tooltipPayload:ue,midAngle:de,middleRadius:oe,tooltipPosition:ce},V),j),{},{value:Ou(V,M),startAngle:ie,endAngle:ee,payload:V,paddingAngle:yh(w)*d}),$})}return ml(ml({},j),{},{sectors:B,data:a})});var ots=Math.ceil,lts=Math.max;function cts(t,s,r,n){for(var a=-1,o=lts(ots((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var dts=cts,uts=YWe,dIe=1/0,hts=17976931348623157e292;function mts(t){if(!t)return t===0?t:0;if(t=uts(t),t===dIe||t===-dIe){var s=t<0?-1:1;return s*hts}return t===t?t:0}var IKe=mts,pts=dts,fts=lle,gme=IKe;function gts(t){return function(s,r,n){return n&&typeof n!="number"&&fts(s,r,n)&&(r=n=void 0),s=gme(s),r===void 0?(r=s,s=0):r=gme(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),Em(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()}),Em(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Em(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Em(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Em(n,"handleSlideDragStart",function(a){var o=fIe(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 Ats(s,t),Sts(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,h=i.data,f=h.length-1,g=Math.min(a,o),v=Math.max(a,o),_=s.getIndexInRange(l,g),j=s.getIndexInRange(l,v);return{startIndex:_-_%d,endIndex:j===f?f:j-j%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,d=Ou(o[n],i,n);return hi(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,h=d.x,f=d.width,g=d.travellerWidth,v=d.startIndex,_=d.endIndex,j=d.onChange,w=n.pageX-o;w>0?w=Math.min(w,h+f-g-i,h+f-g-l):w<0&&(w=Math.max(w,h-l,h-i));var k=this.getIndex({startX:l+w,endX:i+w});(k.startIndex!==v||k.endIndex!==_)&&j&&j(k),this.setState({startX:l+w,endX:i+w,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=fIe(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,h=this.state[l],f=this.props,g=f.x,v=f.width,_=f.travellerWidth,j=f.onChange,w=f.gap,k=f.data,M={startX:this.state.startX,endX:this.state.endX},S=n.pageX-o;S>0?S=Math.min(S,g+v-_-h):S<0&&(S=Math.max(S,g-h)),M[l]=h+S;var E=this.getIndex(M),D=E.startIndex,L=E.endIndex,B=function(){var V=k.length-1;return l==="startX"&&(i>d?D%w===0:L%w===0)||id?L%w===0:D%w===0)||i>d&&L===V};this.setState(Em(Em({},l,h+S),"brushMoveStartX",n.pageX),function(){j&&B()&&j(E)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,d=l.startX,h=l.endX,f=this.state[a],g=i.indexOf(f);if(g!==-1){var v=g+n;if(!(v===-1||v>=i.length)){var _=i[v];a==="startX"&&_>=h||a==="endX"&&_<=d||this.setState(Em({},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,h=n.stroke;return lt.createElement("rect",{stroke:h,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,h=n.children,f=n.padding,g=T.Children.only(h);return g?lt.cloneElement(g,{x:a,y:o,width:l,height:i,margin:f,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,d=this.props,h=d.y,f=d.travellerWidth,g=d.height,v=d.traveller,_=d.ariaLabel,j=d.data,w=d.startIndex,k=d.endIndex,M=Math.max(n,this.props.x),S=xme(xme({},ni(this.props,!1)),{},{x:M,y:h,width:f,height:g}),E=_||"Min value: ".concat((o=j[w])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=j[k])===null||l===void 0?void 0:l.name);return lt.createElement(Vo,{tabIndex:0,role:"slider","aria-label":E,"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,S))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,d=o.stroke,h=o.travellerWidth,f=Math.min(n,a)+h,g=Math.max(Math.abs(a-n)-h,0);return lt.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:f,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,h=n.stroke,f=this.state,g=f.startX,v=f.endX,_=5,j={pointerEvents:"none",fill:h};return lt.createElement(Vo,{className:"recharts-brush-texts"},lt.createElement(pN,Tae({textAnchor:"end",verticalAnchor:"middle",x:Math.min(g,v)-_,y:l+i/2},j),this.getTextOfTick(a)),lt.createElement(pN,Tae({textAnchor:"start",verticalAnchor:"middle",x:Math.max(g,v)+d+_,y:l+i/2},j),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,h=n.width,f=n.height,g=n.alwaysShowText,v=this.state,_=v.startX,j=v.endX,w=v.isTextActive,k=v.isSlideMoving,M=v.isTravellerMoving,S=v.isTravellerFocused;if(!a||!a.length||!Zr(i)||!Zr(d)||!Zr(h)||!Zr(f)||h<=0||f<=0)return null;var E=Ai("recharts-brush",o),D=lt.Children.count(l)===1,L=kts("userSelect","none");return lt.createElement(Vo,{className:E,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:L},this.renderBackground(),D&&this.renderPanorama(),this.renderSlide(_,j),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(j,"endX"),(w||k||M||S||g)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,d=n.stroke,h=Math.floor(o+i/2)-1;return lt.createElement(lt.Fragment,null,lt.createElement("rect",{x:a,y:o,width:l,height:i,fill:d,stroke:"none"}),lt.createElement("line",{x1:a+1,y1:h,x2:a+l-1,y2:h,fill:"none",stroke:"#fff"}),lt.createElement("line",{x1:a+1,y1:h+2,x2:a+l-1,y2:h+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var o;return lt.isValidElement(n)?o=lt.cloneElement(n,a):hi(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,h=n.updateId,f=n.startIndex,g=n.endIndex;if(o!==a.prevData||h!==a.prevUpdateId)return xme({prevData:o,prevTravellerWidth:d,prevUpdateId:h,prevX:i,prevWidth:l},o&&o.length?Its({data:o,width:l,x:i,travellerWidth:d,startIndex:f,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:h,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}}])}(T.PureComponent);Em(h3,"displayName","Brush");Em(h3,"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 Pts=xbe;function Lts(t,s){var r;return Pts(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Dts=Lts,Ots=jWe,Rts=Xx,Fts=Dts,zts=xm,Bts=lle;function $ts(t,s,r){var n=zts(t)?Ots:Fts;return r&&Bts(t,s,r)&&(s=void 0),n(t,Rts(s))}var Uts=$ts;const qts=fo(Uts);var Dx=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},gIe=HWe;function Vts(t,s,r){s=="__proto__"&&gIe?gIe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Hts=Vts,Wts=Hts,Gts=qWe,Kts=Xx;function Zts(t,s){var r={};return s=Kts(s),Gts(t,function(n,a,o){Wts(r,a,s(n,a,o))}),r}var Yts=Zts;const Xts=fo(Yts);function Qts(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 fss(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 gss(t,s){var r=t.x,n=t.y,a=pss(t,dss),o="".concat(r),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),h="".concat(s.height||a.height),f=parseInt(h,10),g="".concat(s.width||a.width),v=parseInt(g,10);return $A($A($A($A($A({},s),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:f,width:v,name:s.name,radius:s.radius})}function yIe(t){return lt.createElement(TKe,rye({shapeType:"rectangle",propTransformer:gss,activeClassName:"recharts-active-bar"},t))}var xss=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=Zr(n)||q8t(n);return o?s(n,a):(o||gN(),r)}},yss=["value","background"],RKe;function m3(t){"@babel/helpers - typeof";return m3=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},m3(t)}function vss(t,s){if(t==null)return{};var r=_ss(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 _ss(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 Eae(){return Eae=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(de)0&&Math.abs(ee)0&&(ie=Math.min((Ke||0)-(ee[Ae-1]||0),ie))}),Number.isFinite(ie)){var de=ie/ne,oe=w.layout==="vertical"?n.height:n.width;if(w.padding==="gap"&&($=de*oe/2),w.padding==="no-gap"){var ue=vh(s.barCategoryGap,de*oe),ce=de*oe/2;$=ce-ue-(ce-ue)/oe*ue}}}a==="xAxis"?V=[n.left+(E.left||0)+($||0),n.left+n.width-(E.right||0)-($||0)]:a==="yAxis"?V=d==="horizontal"?[n.top+n.height-(E.bottom||0),n.top+(E.top||0)]:[n.top+(E.top||0)+($||0),n.top+n.height-(E.bottom||0)-($||0)]:V=w.range,L&&(V=[V[1],V[0]]);var ge=rKe(w,o,v),Te=ge.scale,ve=ge.realScaleType;Te.domain(M).range(V),nKe(Te);var ye=aKe(Te,Qf(Qf({},w),{},{realScaleType:ve}));a==="xAxis"?(J=k==="top"&&!D||k==="bottom"&&D,W=n.left,G=g[B]-J*w.height):a==="yAxis"&&(J=k==="left"&&!D||k==="right"&&D,W=g[B]-J*w.width,G=n.top);var Se=Qf(Qf(Qf({},w),ye),{},{realScaleType:ve,x:W,y:G,scale:Te,width:a==="xAxis"?n.width:w.width,height:a==="yAxis"?n.height:w.height});return Se.bandSize=gae(Se,ye),!w.hide&&a==="xAxis"?g[B]+=(J?-1:1)*Se.height:w.hide||(g[B]+=(J?-1:1)*Se.width),Qf(Qf({},_),{},Tle({},j,Se))},{})},$Ke=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)}},Iss=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return $Ke({x:r,y:n},{x:a,y:o})},UKe=function(){function t(s){Mss(this,t),this.scale=s}return Tss(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)}}])}();Tle(UKe,"EPS",1e-4);var Gbe=function(s){var r=Object.keys(s).reduce(function(n,a){return Qf(Qf({},n),{},Tle({},a,UKe.create(s[a])))},{});return Qf(Qf({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Xts(a,function(d,h){return r[h].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return OKe(a,function(o,l){return r[l].isInRange(o)})}})};function Pss(t){return(t%180+180)%180}var Lss=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Pss(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var zss=Fss,Bss=IKe;function $ss(t){var s=Bss(t),r=s%1;return s===s?r?s-r:s:0}var Uss=$ss,qss=RWe,Vss=Xx,Hss=Uss,Wss=Math.max;function Gss(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Hss(r);return a<0&&(a=Wss(n+a,0)),qss(t,Vss(s),a)}var Kss=Gss,Zss=zss,Yss=Kss,Xss=Zss(Yss),Qss=Xss;const Jss=fo(Qss);var ers=ZOt(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("")}),Kbe=T.createContext(void 0),Zbe=T.createContext(void 0),qKe=T.createContext(void 0),VKe=T.createContext({}),HKe=T.createContext(void 0),WKe=T.createContext(0),GKe=T.createContext(0),jIe=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,o=r.offset,l=s.clipPathId,i=s.children,d=s.width,h=s.height,f=ers(o);return lt.createElement(Kbe.Provider,{value:n},lt.createElement(Zbe.Provider,{value:a},lt.createElement(VKe.Provider,{value:o},lt.createElement(qKe.Provider,{value:f},lt.createElement(HKe.Provider,{value:l},lt.createElement(WKe.Provider,{value:h},lt.createElement(GKe.Provider,{value:d},i)))))))},trs=function(){return T.useContext(HKe)},KKe=function(s){var r=T.useContext(Kbe);r==null&&gN();var n=r[s];return n==null&&gN(),n},srs=function(){var s=T.useContext(Kbe);return Kv(s)},rrs=function(){var s=T.useContext(Zbe),r=Jss(s,function(n){return OKe(n.domain,Number.isFinite)});return r||Kv(s)},ZKe=function(s){var r=T.useContext(Zbe);r==null&&gN();var n=r[s];return n==null&&gN(),n},nrs=function(){var s=T.useContext(qKe);return s},ars=function(){return T.useContext(VKe)},Ybe=function(){return T.useContext(GKe)},Xbe=function(){return T.useContext(WKe)};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 irs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function ors(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 Urs(t,s){return sZe(t,s+1)}function qrs(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,d=0,h=1,f=l,g=function(){var j=n==null?void 0:n[d];if(j===void 0)return{v:sZe(n,h)};var w=d,k,M=function(){return k===void 0&&(k=r(j,w)),k},S=j.coordinate,E=d===0||Oae(t,S,M,f,i);E||(d=0,f=l,h+=1),E&&(f=S+t*(M()/2+a),d+=h)},v;h<=o.length;)if(v=g(),v)return v.v;return[]}function a6(t){"@babel/helpers - typeof";return a6=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},a6(t)}function EIe(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 Iu(t){for(var s=1;s0?_.coordinate-k*t:_.coordinate})}else o[v]=_=Iu(Iu({},_),{},{tickCoord:_.coordinate});var M=Oae(t,_.tickCoord,w,i,d);M&&(d=_.tickCoord-t*(w()/2+a),o[v]=Iu(Iu({},_),{},{isShow:!0}))},f=l-1;f>=0;f--)h(f);return o}function Krs(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,d=s.start,h=s.end;if(o){var f=n[i-1],g=r(f,i-1),v=t*(f.coordinate+t*g/2-h);l[i-1]=f=Iu(Iu({},f),{},{tickCoord:v>0?f.coordinate-v*t:f.coordinate});var _=Oae(t,f.tickCoord,function(){return g},d,h);_&&(h=f.tickCoord-t*(g/2+a),l[i-1]=Iu(Iu({},f),{},{isShow:!0}))}for(var j=o?i-1:i,w=function(S){var E=l[S],D,L=function(){return D===void 0&&(D=r(E,S)),D};if(S===0){var B=t*(E.coordinate-t*L()/2-d);l[S]=E=Iu(Iu({},E),{},{tickCoord:B<0?E.coordinate-B*t:E.coordinate})}else l[S]=E=Iu(Iu({},E),{},{tickCoord:E.coordinate});var $=Oae(t,E.tickCoord,L,d,h);$&&(d=E.tickCoord+t*(L()/2+a),l[S]=Iu(Iu({},E),{},{isShow:!0}))},k=0;k=2?yh(a[1].coordinate-a[0].coordinate):1,M=$rs(o,k,_);return d==="equidistantPreserveStart"?qrs(k,M,w,a,l):(d==="preserveStart"||d==="preserveStartEnd"?v=Krs(k,M,w,a,l,d==="preserveStartEnd"):v=Grs(k,M,w,a,l),v.filter(function(S){return S.isShow}))}var Zrs=["viewBox"],Yrs=["viewBox"],Xrs=["ticks"];function x3(t){"@babel/helpers - typeof";return x3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},x3(t)}function l4(){return l4=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 Qrs(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 Jrs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function PIe(t,s){for(var r=0;r0?d(this.props):d(_)),l<=0||i<=0||!j||!j.length?null:lt.createElement(Vo,{className:Ai("recharts-cartesian-axis",h),ref:function(k){n.layerReference=k}},o&&this.renderAxisLine(),this.renderTicks(j,this.state.fontSize,this.state.letterSpacing),Zd.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Ai(a.className,"recharts-cartesian-axis-tick-value");return lt.isValidElement(n)?l=lt.cloneElement(n,yd(yd({},a),{},{className:i})):hi(n)?l=n(yd(yd({},a),{},{className:i})):l=lt.createElement(pN,l4({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(T.Component);twe(uM,"displayName","CartesianAxis");twe(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 ins=["x1","y1","x2","y2","key"],ons=["offset"];function xN(t){"@babel/helpers - typeof";return xN=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},xN(t)}function LIe(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 Du(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function uns(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 hns=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 lt.createElement("rect",{x:a,y:o,ry:d,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function aZe(t,s){var r;if(lt.isValidElement(t))r=lt.cloneElement(t,s);else if(hi(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,d=DIe(s,ins),h=ni(d,!1);h.offset;var f=DIe(h,ons);r=lt.createElement("line",sk({},f,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function mns(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 h=Du(Du({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(d),index:d});return aZe(a,h)});return lt.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function pns(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 h=Du(Du({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(d),index:d});return aZe(a,h)});return lt.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function fns(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,h=d===void 0?!0:d;if(!h||!s||!s.length)return null;var f=i.map(function(v){return Math.round(v+a-a)}).sort(function(v,_){return v-_});a!==f[0]&&f.unshift(0);var g=f.map(function(v,_){var j=!f[_+1],w=j?a+l-v:f[_+1]-v;if(w<=0)return null;var k=_%s.length;return lt.createElement("rect",{key:"react-".concat(_),y:v,x:n,height:w,width:o,stroke:"none",fill:s[k],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return lt.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},g)}function gns(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,h=t.verticalPoints;if(!r||!n||!n.length)return null;var f=h.map(function(v){return Math.round(v+o-o)}).sort(function(v,_){return v-_});o!==f[0]&&f.unshift(0);var g=f.map(function(v,_){var j=!f[_+1],w=j?o+i-v:f[_+1]-v;if(w<=0)return null;var k=_%n.length;return lt.createElement("rect",{key:"react-".concat(_),x:v,y:l,width:w,height:d,stroke:"none",fill:n[k],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return lt.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},g)}var xns=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return sKe(ewe(Du(Du(Du({},uM.defaultProps),n),{},{ticks:Gy(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},yns=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return sKe(ewe(Du(Du(Du({},uM.defaultProps),n),{},{ticks:Gy(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},DC={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function iZe(t){var s,r,n,a,o,l,i=Ybe(),d=Xbe(),h=ars(),f=Du(Du({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:DC.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:DC.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:DC.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:DC.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:DC.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:DC.verticalFill,x:Zr(t.x)?t.x:h.left,y:Zr(t.y)?t.y:h.top,width:Zr(t.width)?t.width:h.width,height:Zr(t.height)?t.height:h.height}),g=f.x,v=f.y,_=f.width,j=f.height,w=f.syncWithTicks,k=f.horizontalValues,M=f.verticalValues,S=srs(),E=rrs();if(!Zr(_)||_<=0||!Zr(j)||j<=0||!Zr(g)||g!==+g||!Zr(v)||v!==+v)return null;var D=f.verticalCoordinatesGenerator||xns,L=f.horizontalCoordinatesGenerator||yns,B=f.horizontalPoints,$=f.verticalPoints;if((!B||!B.length)&&hi(L)){var V=k&&k.length,W=L({yAxis:E?Du(Du({},E),{},{ticks:V?k:E.ticks}):void 0,width:i,height:d,offset:h},V?!0:w);gg(Array.isArray(W),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(xN(W),"]")),Array.isArray(W)&&(B=W)}if((!$||!$.length)&&hi(D)){var G=M&&M.length,J=D({xAxis:S?Du(Du({},S),{},{ticks:G?M:S.ticks}):void 0,width:i,height:d,offset:h},G?!0:w);gg(Array.isArray(J),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(xN(J),"]")),Array.isArray(J)&&($=J)}return lt.createElement("g",{className:"recharts-cartesian-grid"},lt.createElement(hns,{fill:f.fill,fillOpacity:f.fillOpacity,x:f.x,y:f.y,width:f.width,height:f.height,ry:f.ry}),lt.createElement(mns,sk({},f,{offset:h,horizontalPoints:B,xAxis:S,yAxis:E})),lt.createElement(pns,sk({},f,{offset:h,verticalPoints:$,xAxis:S,yAxis:E})),lt.createElement(fns,sk({},f,{horizontalPoints:B})),lt.createElement(gns,sk({},f,{verticalPoints:$})))}iZe.displayName="CartesianGrid";function y3(t){"@babel/helpers - typeof";return y3=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},y3(t)}function vns(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function _ns(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 ias(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 oas(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function las(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&Zr(a)&&Zr(o)?s.slice(a,o+1):[]};function _Ze(t){return t==="number"?[0,"auto"]:void 0}var _ye=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=Ole(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,h){var f,g=(f=h.props.data)!==null&&f!==void 0?f: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=Gge(_,l.dataKey,a)}else v=g&&g[n]||i[n];return v?[].concat(b3(d),[oKe(h,v)]):d},[])},$Ie=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=_as(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,h=s.tooltipTicks,f=tYt(l,i,h,d);if(f>=0&&h){var g=h[f]&&h[f].value,v=_ye(s,r,f,g),_=bas(n,i,f,o);return{activeTooltipIndex:f,activeLabel:g,activePayload:v,activeCoordinate:_}}return null},was=function(s,r){var n=r.axes,a=r.graphicalItems,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,h=r.dataEndIndex,f=s.layout,g=s.children,v=s.stackOffset,_=tKe(f,o);return n.reduce(function(j,w){var k,M=w.type.defaultProps!==void 0?pr(pr({},w.type.defaultProps),w.props):w.props,S=M.type,E=M.dataKey,D=M.allowDataOverflow,L=M.allowDuplicatedCategory,B=M.scale,$=M.ticks,V=M.includeHidden,W=M[l];if(j[W])return j;var G=Ole(s.data,{graphicalItems:a.filter(function(ye){var Se,Ke=l in ye.props?ye.props[l]:(Se=ye.type.defaultProps)===null||Se===void 0?void 0:Se[l];return Ke===W}),dataStartIndex:d,dataEndIndex:h}),J=G.length,ne,ie,ee;Kns(M.domain,D,S)&&(ne=Dxe(M.domain,null,D),_&&(S==="number"||B!=="auto")&&(ee=jI(G,E,"category")));var de=_Ze(S);if(!ne||ne.length===0){var oe,ue=(oe=M.domain)!==null&&oe!==void 0?oe:de;if(E){if(ne=jI(G,E,S),S==="category"&&_){var ce=H8t(ne);L&&ce?(ie=ne,ne=Mae(0,J)):L||(ne=hEe(ue,ne,w).reduce(function(ye,Se){return ye.indexOf(Se)>=0?ye:[].concat(b3(ye),[Se])},[]))}else if(S==="category")L?ne=ne.filter(function(ye){return ye!==""&&!Wi(ye)}):ne=hEe(ue,ne,w).reduce(function(ye,Se){return ye.indexOf(Se)>=0||Se===""||Wi(Se)?ye:[].concat(b3(ye),[Se])},[]);else if(S==="number"){var ge=iYt(G,a.filter(function(ye){var Se,Ke,Ae=l in ye.props?ye.props[l]:(Se=ye.type.defaultProps)===null||Se===void 0?void 0:Se[l],Ee="hide"in ye.props?ye.props.hide:(Ke=ye.type.defaultProps)===null||Ke===void 0?void 0:Ke.hide;return Ae===W&&(V||!Ee)}),E,o,f);ge&&(ne=ge)}_&&(S==="number"||B!=="auto")&&(ee=jI(G,E,"category"))}else _?ne=Mae(0,J):i&&i[W]&&i[W].hasStack&&S==="number"?ne=v==="expand"?[0,1]:iKe(i[W].stackGroups,d,h):ne=eKe(G,a.filter(function(ye){var Se=l in ye.props?ye.props[l]:ye.type.defaultProps[l],Ke="hide"in ye.props?ye.props.hide:ye.type.defaultProps.hide;return Se===W&&(V||!Ke)}),S,f,!0);if(S==="number")ne=xye(g,ne,W,o,$),ue&&(ne=Dxe(ue,ne,D));else if(S==="category"&&ue){var Te=ue,ve=ne.every(function(ye){return Te.indexOf(ye)>=0});ve&&(ne=Te)}}return pr(pr({},j),{},qa({},W,pr(pr({},M),{},{axisType:o,domain:ne,categoricalDomain:ee,duplicateDomain:ie,originalDomain:(k=M.domain)!==null&&k!==void 0?k:de,isCategorical:_,layout:f})))},{})},jas=function(s,r){var n=r.graphicalItems,a=r.Axis,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,h=r.dataEndIndex,f=s.layout,g=s.children,v=Ole(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:h}),_=v.length,j=tKe(f,o),w=-1;return n.reduce(function(k,M){var S=M.type.defaultProps!==void 0?pr(pr({},M.type.defaultProps),M.props):M.props,E=S[l],D=_Ze("number");if(!k[E]){w++;var L;return j?L=Mae(0,_):i&&i[E]&&i[E].hasStack?(L=iKe(i[E].stackGroups,d,h),L=xye(g,L,E,o)):(L=Dxe(D,eKe(v,n.filter(function(B){var $,V,W=l in B.props?B.props[l]:($=B.type.defaultProps)===null||$===void 0?void 0:$[l],G="hide"in B.props?B.props.hide:(V=B.type.defaultProps)===null||V===void 0?void 0:V.hide;return W===E&&!G}),"number",f),a.defaultProps.allowDataOverflow),L=xye(g,L,E,o)),pr(pr({},k),{},qa({},E,pr(pr({axisType:o},a.defaultProps),{},{hide:!0,orientation:rp(yas,"".concat(o,".").concat(w%2),null),domain:L,originalDomain:D,isCategorical:j,layout:f})))}return k},{})},kas=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,h=r.dataEndIndex,f=s.children,g="".concat(a,"Id"),v=Jp(f,o),_={};return v&&v.length?_=was(s,{axes:v,graphicalItems:l,axisType:a,axisIdKey:g,stackGroups:i,dataStartIndex:d,dataEndIndex:h}):l&&l.length&&(_=jas(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:g,stackGroups:i,dataStartIndex:d,dataEndIndex:h})),_},Nas=function(s){var r=Kv(s),n=Gy(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:ybe(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:gae(r,n)}},UIe=function(s){var r=s.children,n=s.defaultShowTooltip,a=Lm(r,h3),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}},Sas=function(s){return!s||!s.length?!1:s.some(function(r){var n=l0(r&&r.type);return n&&n.indexOf("Bar")>=0})},qIe=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"}},Cas=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,h=n.width,f=n.height,g=n.children,v=n.margin||{},_=Lm(g,h3),j=Lm(g,o5),w=Object.keys(d).reduce(function(L,B){var $=d[B],V=$.orientation;return!$.mirror&&!$.hide?pr(pr({},L),{},qa({},V,L[V]+$.width)):L},{left:v.left||0,right:v.right||0}),k=Object.keys(l).reduce(function(L,B){var $=l[B],V=$.orientation;return!$.mirror&&!$.hide?pr(pr({},L),{},qa({},V,rp(L,"".concat(V))+$.height)):L},{top:v.top||0,bottom:v.bottom||0}),M=pr(pr({},k),w),S=M.bottom;_&&(M.bottom+=_.props.height||h3.defaultProps.height),j&&r&&(M=nYt(M,a,n,r));var E=h-M.left-M.right,D=f-M.top-M.bottom;return pr(pr({brushBottom:S},M),{},{width:Math.max(E,0),height:Math.max(D,0)})},Mas=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},bZe=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,h=s.legendContent,f=s.formatAxisMap,g=s.defaultProps,v=function(M,S){var E=S.graphicalItems,D=S.stackGroups,L=S.offset,B=S.updateId,$=S.dataStartIndex,V=S.dataEndIndex,W=M.barSize,G=M.layout,J=M.barGap,ne=M.barCategoryGap,ie=M.maxBarSize,ee=qIe(G),de=ee.numericAxisName,oe=ee.cateAxisName,ue=Sas(E),ce=[];return E.forEach(function(ge,Te){var ve=Ole(M.data,{graphicalItems:[ge],dataStartIndex:$,dataEndIndex:V}),ye=ge.type.defaultProps!==void 0?pr(pr({},ge.type.defaultProps),ge.props):ge.props,Se=ye.dataKey,Ke=ye.maxBarSize,Ae=ye["".concat(de,"Id")],Ee=ye["".concat(oe,"Id")],He={},Ue=d.reduce(function(it,dt){var tt=S["".concat(dt.axisType,"Map")],ut=ye["".concat(dt.axisType,"Id")];tt&&tt[ut]||dt.axisType==="zAxis"||gN();var xt=tt[ut];return pr(pr({},it),{},qa(qa({},dt.axisType,xt),"".concat(dt.axisType,"Ticks"),Gy(xt)))},He),De=Ue[oe],Ge=Ue["".concat(oe,"Ticks")],wt=D&&D[Ae]&&D[Ae].hasStack&&fYt(ge,D[Ae].stackGroups),Ie=l0(ge.type).indexOf("Bar")>=0,st=gae(De,Ge),he=[],We=ue&&sYt({barSize:W,stackGroups:D,totalSize:Mas(Ue,oe)});if(Ie){var et,Ye,ke=Wi(Ke)?ie:Ke,at=(et=(Ye=gae(De,Ge,!0))!==null&&Ye!==void 0?Ye:ke)!==null&&et!==void 0?et:0;he=rYt({barGap:J,barCategoryGap:ne,bandSize:at!==st?at:st,sizeList:We[Ee],maxBarSize:ke}),at!==st&&(he=he.map(function(it){return pr(pr({},it),{},{position:pr(pr({},it.position),{},{offset:it.position.offset-at/2})})}))}var Fe=ge&&ge.type&&ge.type.getComposedData;Fe&&ce.push({props:pr(pr({},Fe(pr(pr({},Ue),{},{displayedData:ve,props:M,dataKey:Se,item:ge,bandSize:st,barPosition:he,offset:L,stackedData:wt,layout:G,dataStartIndex:$,dataEndIndex:V}))),{},qa(qa(qa({key:ge.key||"item-".concat(Te)},de,Ue[de]),oe,Ue[oe]),"animationId",B)),childIndex:rRt(ge,M.children),item:ge})}),ce},_=function(M,S){var E=M.props,D=M.dataStartIndex,L=M.dataEndIndex,B=M.updateId;if(!iTe({props:E}))return null;var $=E.children,V=E.layout,W=E.stackOffset,G=E.data,J=E.reverseStackOrder,ne=qIe(V),ie=ne.numericAxisName,ee=ne.cateAxisName,de=Jp($,n),oe=mYt(G,de,"".concat(ie,"Id"),"".concat(ee,"Id"),W,J),ue=d.reduce(function(ye,Se){var Ke="".concat(Se.axisType,"Map");return pr(pr({},ye),{},qa({},Ke,kas(E,pr(pr({},Se),{},{graphicalItems:de,stackGroups:Se.axisType===ie&&oe,dataStartIndex:D,dataEndIndex:L}))))},{}),ce=Cas(pr(pr({},ue),{},{props:E,graphicalItems:de}),S==null?void 0:S.legendBBox);Object.keys(ue).forEach(function(ye){ue[ye]=f(E,ue[ye],ce,ye.replace("Map",""),r)});var ge=ue["".concat(ee,"Map")],Te=Nas(ge),ve=v(E,pr(pr({},ue),{},{dataStartIndex:D,dataEndIndex:L,updateId:B,graphicalItems:de,stackGroups:oe,offset:ce}));return pr(pr({formattedGraphicalItems:ve,graphicalItems:de,offset:ce,stackGroups:oe},Te),ue)},j=function(k){function M(S){var E,D,L;return oas(this,M),L=das(this,M,[S]),qa(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),qa(L,"accessibilityManager",new Gns),qa(L,"handleLegendBBoxUpdate",function(B){if(B){var $=L.state,V=$.dataStartIndex,W=$.dataEndIndex,G=$.updateId;L.setState(pr({legendBBox:B},_({props:L.props,dataStartIndex:V,dataEndIndex:W,updateId:G},pr(pr({},L.state),{},{legendBBox:B}))))}}),qa(L,"handleReceiveSyncEvent",function(B,$,V){if(L.props.syncId===B){if(V===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent($)}}),qa(L,"handleBrushChange",function(B){var $=B.startIndex,V=B.endIndex;if($!==L.state.dataStartIndex||V!==L.state.dataEndIndex){var W=L.state.updateId;L.setState(function(){return pr({dataStartIndex:$,dataEndIndex:V},_({props:L.props,dataStartIndex:$,dataEndIndex:V,updateId:W},L.state))}),L.triggerSyncEvent({dataStartIndex:$,dataEndIndex:V})}}),qa(L,"handleMouseEnter",function(B){var $=L.getMouseInfo(B);if($){var V=pr(pr({},$),{},{isTooltipActive:!0});L.setState(V),L.triggerSyncEvent(V);var W=L.props.onMouseEnter;hi(W)&&W(V,B)}}),qa(L,"triggeredAfterMouseMove",function(B){var $=L.getMouseInfo(B),V=$?pr(pr({},$),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(V),L.triggerSyncEvent(V);var W=L.props.onMouseMove;hi(W)&&W(V,B)}),qa(L,"handleItemMouseEnter",function(B){L.setState(function(){return{isTooltipActive:!0,activeItem:B,activePayload:B.tooltipPayload,activeCoordinate:B.tooltipPosition||{x:B.cx,y:B.cy}}})}),qa(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),qa(L,"handleMouseMove",function(B){B.persist(),L.throttleTriggeredAfterMouseMove(B)}),qa(L,"handleMouseLeave",function(B){L.throttleTriggeredAfterMouseMove.cancel();var $={isTooltipActive:!1};L.setState($),L.triggerSyncEvent($);var V=L.props.onMouseLeave;hi(V)&&V($,B)}),qa(L,"handleOuterEvent",function(B){var $=sRt(B),V=rp(L.props,"".concat($));if($&&hi(V)){var W,G;/.*touch.*/i.test($)?G=L.getMouseInfo(B.changedTouches[0]):G=L.getMouseInfo(B),V((W=G)!==null&&W!==void 0?W:{},B)}}),qa(L,"handleClick",function(B){var $=L.getMouseInfo(B);if($){var V=pr(pr({},$),{},{isTooltipActive:!0});L.setState(V),L.triggerSyncEvent(V);var W=L.props.onClick;hi(W)&&W(V,B)}}),qa(L,"handleMouseDown",function(B){var $=L.props.onMouseDown;if(hi($)){var V=L.getMouseInfo(B);$(V,B)}}),qa(L,"handleMouseUp",function(B){var $=L.props.onMouseUp;if(hi($)){var V=L.getMouseInfo(B);$(V,B)}}),qa(L,"handleTouchMove",function(B){B.changedTouches!=null&&B.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(B.changedTouches[0])}),qa(L,"handleTouchStart",function(B){B.changedTouches!=null&&B.changedTouches.length>0&&L.handleMouseDown(B.changedTouches[0])}),qa(L,"handleTouchEnd",function(B){B.changedTouches!=null&&B.changedTouches.length>0&&L.handleMouseUp(B.changedTouches[0])}),qa(L,"handleDoubleClick",function(B){var $=L.props.onDoubleClick;if(hi($)){var V=L.getMouseInfo(B);$(V,B)}}),qa(L,"handleContextMenu",function(B){var $=L.props.onContextMenu;if(hi($)){var V=L.getMouseInfo(B);$(V,B)}}),qa(L,"triggerSyncEvent",function(B){L.props.syncId!==void 0&&vme.emit(_me,L.props.syncId,B,L.eventEmitterSymbol)}),qa(L,"applySyncEvent",function(B){var $=L.props,V=$.layout,W=$.syncMethod,G=L.state.updateId,J=B.dataStartIndex,ne=B.dataEndIndex;if(B.dataStartIndex!==void 0||B.dataEndIndex!==void 0)L.setState(pr({dataStartIndex:J,dataEndIndex:ne},_({props:L.props,dataStartIndex:J,dataEndIndex:ne,updateId:G},L.state)));else if(B.activeTooltipIndex!==void 0){var ie=B.chartX,ee=B.chartY,de=B.activeTooltipIndex,oe=L.state,ue=oe.offset,ce=oe.tooltipTicks;if(!ue)return;if(typeof W=="function")de=W(ce,B);else if(W==="value"){de=-1;for(var ge=0;ge=0){var wt,Ie;if(ie.dataKey&&!ie.allowDuplicatedCategory){var st=typeof ie.dataKey=="function"?Ge:"payload.".concat(ie.dataKey.toString());wt=Gge(ge,st,de),Ie=Te&&ve&&Gge(ve,st,de)}else wt=ge==null?void 0:ge[ee],Ie=Te&&ve&&ve[ee];if(Ee||Ae){var he=B.props.activeIndex!==void 0?B.props.activeIndex:ee;return[T.cloneElement(B,pr(pr(pr({},W.props),Ue),{},{activeIndex:he})),null,null]}if(!Wi(wt))return[De].concat(b3(L.renderActivePoints({item:W,activePoint:wt,basePoint:Ie,childIndex:ee,isRange:Te})))}else{var We,et=(We=L.getItemByXY(L.state.activeCoordinate))!==null&&We!==void 0?We:{graphicalItem:De},Ye=et.graphicalItem,ke=Ye.item,at=ke===void 0?B:ke,Fe=Ye.childIndex,it=pr(pr(pr({},W.props),Ue),{},{activeIndex:Fe});return[T.cloneElement(at,it),null,null]}return Te?[De,null,null]:[De,null]}),qa(L,"renderCustomized",function(B,$,V){return T.cloneElement(B,pr(pr({key:"recharts-customized-".concat(V)},L.props),L.state))}),qa(L,"renderMap",{CartesianGrid:{handler:A8,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:A8},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:A8},YAxis:{handler:A8},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((E=S.id)!==null&&E!==void 0?E:iL("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=XWe(L.triggeredAfterMouseMove,(D=S.throttleDelay)!==null&&D!==void 0?D:1e3/60),L.state={},L}return mas(M,k),cas(M,[{key:"componentDidMount",value:function(){var E,D;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(E=this.props.margin.left)!==null&&E!==void 0?E:0,top:(D=this.props.margin.top)!==null&&D!==void 0?D:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var E=this.props,D=E.children,L=E.data,B=E.height,$=E.layout,V=Lm(D,Xf);if(V){var W=V.props.defaultIndex;if(!(typeof W!="number"||W<0||W>this.state.tooltipTicks.length-1)){var G=this.state.tooltipTicks[W]&&this.state.tooltipTicks[W].value,J=_ye(this.state,L,W,G),ne=this.state.tooltipTicks[W].coordinate,ie=(this.state.offset.top+B)/2,ee=$==="horizontal",de=ee?{x:ne,y:ie}:{y:ne,x:ie},oe=this.state.formattedGraphicalItems.find(function(ce){var ge=ce.item;return ge.type.name==="Scatter"});oe&&(de=pr(pr({},de),oe.props.points[W].tooltipPosition),J=oe.props.points[W].tooltipPayload);var ue={activeTooltipIndex:W,isTooltipActive:!0,activeLabel:G,activePayload:J,activeCoordinate:de};this.setState(ue),this.renderCursor(V),this.accessibilityManager.setIndex(W)}}}},{key:"getSnapshotBeforeUpdate",value:function(E,D){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==D.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==E.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==E.margin){var L,B;this.accessibilityManager.setDetails({offset:{left:(L=this.props.margin.left)!==null&&L!==void 0?L:0,top:(B=this.props.margin.top)!==null&&B!==void 0?B:0}})}return null}},{key:"componentDidUpdate",value:function(E){Zge([Lm(E.children,Xf)],[Lm(this.props.children,Xf)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var E=Lm(this.props.children,Xf);if(E&&typeof E.props.shared=="boolean"){var D=E.props.shared?"axis":"item";return i.indexOf(D)>=0?D:o}return o}},{key:"getMouseInfo",value:function(E){if(!this.container)return null;var D=this.container,L=D.getBoundingClientRect(),B=THt(L),$={chartX:Math.round(E.pageX-B.left),chartY:Math.round(E.pageY-B.top)},V=L.width/D.offsetWidth||1,W=this.inRange($.chartX,$.chartY,V);if(!W)return null;var G=this.state,J=G.xAxisMap,ne=G.yAxisMap,ie=this.getTooltipEventType(),ee=$Ie(this.state,this.props.data,this.props.layout,W);if(ie!=="axis"&&J&&ne){var de=Kv(J).scale,oe=Kv(ne).scale,ue=de&&de.invert?de.invert($.chartX):null,ce=oe&&oe.invert?oe.invert($.chartY):null;return pr(pr({},$),{},{xValue:ue,yValue:ce},ee)}return ee?pr(pr({},$),ee):null}},{key:"inRange",value:function(E,D){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,B=this.props.layout,$=E/L,V=D/L;if(B==="horizontal"||B==="vertical"){var W=this.state.offset,G=$>=W.left&&$<=W.left+W.width&&V>=W.top&&V<=W.top+W.height;return G?{x:$,y:V}:null}var J=this.state,ne=J.angleAxisMap,ie=J.radiusAxisMap;if(ne&&ie){var ee=Kv(ne);return fEe({x:$,y:V},ee)}return null}},{key:"parseEventsOfWrapper",value:function(){var E=this.props.children,D=this.getTooltipEventType(),L=Lm(E,Xf),B={};L&&D==="axis"&&(L.props.trigger==="click"?B={onClick:this.handleClick}:B={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 $=qne(this.props,this.handleOuterEvent);return pr(pr({},$),B)}},{key:"addListener",value:function(){vme.on(_me,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){vme.removeListener(_me,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(E,D,L){for(var B=this.state.formattedGraphicalItems,$=0,V=B.length;$");return t}const kZe=T.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=T.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(wZe.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:$t("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(Ias,{id:i,config:n}),e.jsx(yxe,{children:r})]})})});kZe.displayName="Chart";const Ias=({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(Eas).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},NZe=T.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:d,formatter:h,color:f,nameKey:g,labelKey:v},_)=>{const{config:j}=jZe(),w=T.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[M]=s,S=`${v||M.dataKey||M.name||"value"}`,E=bye(j,M,S),D=!v&&typeof l=="string"?((L=j[l])==null?void 0:L.label)||l:E==null?void 0:E.label;return i?e.jsx("div",{className:$t("font-medium",d),children:i(D,s)}):D?e.jsx("div",{className:$t("font-medium",d),children:D}):null},[l,i,s,a,d,j,v]);if(!t||!(s!=null&&s.length))return null;const k=s.length===1&&n!=="dot";return e.jsxs("div",{ref:_,className:$t("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:[k?null:w,e.jsx("div",{className:"grid gap-1.5",children:s.map((M,S)=>{const E=`${g||M.name||M.dataKey||"value"}`,D=bye(j,M,E),L=f||M.payload.fill||M.color;return e.jsx("div",{className:$t("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:h&&(M==null?void 0:M.value)!==void 0&&M.name?h(M.value,M.name,M,S,M.payload):e.jsxs(e.Fragment,{children:[D!=null&&D.icon?e.jsx(D.icon,{}):!o&&e.jsx("div",{className:$t("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":k&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:$t("flex flex-1 justify-between leading-none",k?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[k?w:null,e.jsx("span",{className:"text-muted-foreground",children:(D==null?void 0:D.label)||M.name})]}),M.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:M.value.toLocaleString()})]})]})},M.dataKey)})})]})});NZe.displayName="ChartTooltip";const Pas=T.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=jZe();return r!=null&&r.length?e.jsx("div",{ref:o,className:$t("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const d=`${a||i.dataKey||"value"}`,h=bye(l,i,d);return e.jsxs("div",{className:$t("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[h!=null&&h.icon&&!s?e.jsx(h.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),h==null?void 0:h.label]},i.value)})}):null});Pas.displayName="ChartLegend";function bye(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 E8=["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 SZe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Oe,{children:e.jsx($e,{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(Oe,{className:"overflow-hidden",children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Transactions by Month"})}),e.jsx($e,{className:"overflow-hidden",children:e.jsx(kZe,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(yxe,{width:"100%",height:"100%",children:e.jsxs(Tas,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(iZe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Lle,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(Dle,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(Xf,{content:e.jsx(NZe,{})}),e.jsx(LN,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Lead Sources"})}),e.jsxs($e,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(yxe,{width:"100%",height:"100%",children:e.jsxs(Aas,{children:[e.jsx(T0,{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(cle,{fill:E8[o%E8.length]},`cell-${o}`))}),e.jsx(Xf,{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:E8[o%E8.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function Las(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=r1e(s,n,new Date);if(Rfe(a))return Bs(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(Rfe(n))return Bs(n,"yyyy-MM-dd")}catch{}return null}const Das=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function Oas({open:t,onOpenChange:s}){const[r,n]=T.useState([]),[a,o]=T.useState(!1),[l,i]=T.useState(0),{data:d}=loe(),{data:h}=Ag(),f=coe(),g=()=>{const M=Das.join(","),S=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),E=`${M} ${S}`,D=new Blob([E],{type:"text/csv"}),L=URL.createObjectURL(D),B=document.createElement("a");B.href=L,B.download="transaction-import-template.csv",B.click(),URL.revokeObjectURL(L)},v=M=>{const S=M.split(` `).filter(D=>D.trim());if(S.length<2)return[];const E=S[0].split(",").map(D=>D.trim().toLowerCase().replace(/['"]/g,""));return S.slice(1).map((D,L)=>{var ue,ce,ge,Te;const B=[];let $="",V=!1;for(const ve of D)ve==='"'?V=!V:ve===","&&!V?(B.push($.trim()),$=""):$+=ve;B.push($.trim());const W=ve=>{var Se;const ye=E.indexOf(ve);return ye>=0?(Se=B[ye])==null?void 0:Se.replace(/^["']|["']$/g,"").trim():""},G=(ue=W("transaction_type"))==null?void 0:ue.toLowerCase(),J=(ce=W("sale_price"))==null?void 0:ce.replace(/[$,]/g,""),ne=(ge=W("commission_amount"))==null?void 0:ge.replace(/[$,]/g,""),ie=(Te=W("is_win"))==null?void 0:Te.toLowerCase(),ee=W("close_date"),de=Las(ee);let oe;return W("property_address")?["buyer","seller"].includes(G)?de?(!J||isNaN(Number(J)))&&(oe="Invalid sale price"):oe=`Invalid date format: "${ee}" - use MM/DD/YYYY or YYYY-MM-DD`:oe='Transaction type must be "buyer" or "seller"':oe="Missing property address",{property_address:W("property_address"),city:W("city"),state:W("state"),zip:W("zip"),transaction_type:G==="seller"?"seller":"buyer",close_date:de||"",sale_price:Number(J)||0,commission_amount:ne?Number(ne):null,lead_source_name:W("lead_source"),client_type_name:W("client_type"),is_win:["yes","true","1"].includes(ie),notes:W("notes"),error:oe}})},_=M=>{var D;const S=(D=M.target.files)==null?void 0:D[0];if(!S)return;const E=new FileReader;E.onload=L=>{var V;const B=(V=L.target)==null?void 0:V.result,$=v(B);n($)},E.readAsText(S)},j=async()=>{const M=r.filter(D=>!D.error);if(M.length===0){be.error("No valid transactions to import");return}o(!0),i(0);let S=0,E=0;for(let D=0;DV.name.toLowerCase()===L.lead_source_name.toLowerCase()),$=h==null?void 0:h.find(V=>V.name.toLowerCase()===L.client_type_name.toLowerCase());await f.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:(B==null?void 0:B.id)||null,client_type_id:($==null?void 0:$.id)||null,contact_id:null,notes:L.notes||null,is_win:L.is_win}),S++}catch(B){E++,console.error("Failed to import transaction:",B)}i(Math.round((D+1)/M.length*100))}o(!1),S>0&&be.success(`Imported ${S} transaction${S>1?"s":""}`),E>0&&be.error(`Failed to import ${E} transaction${E>1?"s":""}`),n([]),s(!1)},w=r.filter(M=>!M.error).length,k=r.filter(M=>M.error).length;return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Import Transactions"}),e.jsx(en,{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(Y,{variant:"outline",onClick:g,children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(Be,{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(ct,{variant:"outline",children:[r.length," rows found"]}),w>0&&e.jsxs(ct,{className:"bg-green-500 text-white",children:[e.jsx(ma,{className:"h-3 w-3 mr-1"}),w," valid"]}),k>0&&e.jsxs(ct,{variant:"destructive",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),k," errors"]})]}),e.jsx(po,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((M,S)=>e.jsxs("div",{className:`p-2 rounded text-sm ${M.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:M.property_address||"(no address)"}),e.jsx(ct,{variant:M.transaction_type==="buyer"?"default":"secondary",children:M.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[M.close_date," • $",M.sale_price.toLocaleString()]}),M.error&&e.jsx(E_e,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(I_e,{className:"text-xs",children:M.error})})]},S)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{onClick:j,disabled:w===0||a,children:[e.jsx(ji,{className:"h-4 w-4 mr-2"}),"Import ",w," Transaction",w!==1?"s":""]})]})]})]})})}const Ras=u_({transactions_goal:nI().min(0).optional(),volume_goal:nI().min(0).optional(),gci_goal:nI().min(0).optional()});function Fas({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=e2t(),{data:o}=doe(),l=(o==null?void 0:o.show_commission)??!0,i=Jie({resolver:eoe(Ras),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});T.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 h=>{await a.mutateAsync({year:r,transactions_goal:h.transactions_goal??null,volume_goal:h.volume_goal??null,gci_goal:l?h.gci_goal??null:null}),s(!1)};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{children:[r," Goals"]}),e.jsx(en,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(toe,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[e.jsx(Jl,{control:i.control,name:"transactions_goal",render:({field:h})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Transactions Goal"}),e.jsx($l,{children:e.jsx(Be,{type:"number",placeholder:"e.g., 24",...h,value:h.value??"",onChange:f=>h.onChange(f.target.value?Number(f.target.value):void 0)})}),e.jsx(Nse,{children:"Total number of deals you want to close"}),e.jsx(gh,{})]})}),e.jsx(Jl,{control:i.control,name:"volume_goal",render:({field:h})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"Volume Goal ($)"}),e.jsx($l,{children:e.jsx(Be,{type:"number",placeholder:"e.g., 5000000",...h,value:h.value??"",onChange:f=>h.onChange(f.target.value?Number(f.target.value):void 0)})}),e.jsx(Nse,{children:"Total sales volume you want to achieve"}),e.jsx(gh,{})]})}),l&&e.jsx(Jl,{control:i.control,name:"gci_goal",render:({field:h})=>e.jsxs(zl,{children:[e.jsx(Bl,{children:"GCI Goal ($)"}),e.jsx($l,{children:e.jsx(Be,{type:"number",placeholder:"e.g., 150000",...h,value:h.value??"",onChange:f=>h.onChange(f.target.value?Number(f.target.value):void 0)})}),e.jsx(Nse,{children:"Gross commission income target"}),e.jsx(gh,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function CZe({transactions:t,isLoading:s}){const r=T.useRef(null),n=T.useRef(null),a=T.useRef([]),o=T.useRef(null),{isAdmin:l}=Ys(),[i,d]=T.useState(""),[h,f]=T.useState(!0),[g,v]=T.useState(0),[_,j]=T.useState(!1),w=t.filter(M=>M.latitude!=null&&M.longitude!=null),k=t.filter(M=>M.latitude==null||M.longitude==null);return T.useEffect(()=>{(async()=>{f(!0);try{const{data:S}=await Z.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&d(S.value)}catch(S){console.error("Error fetching mapbox token:",S)}f(!1)})()},[]),T.useEffect(()=>{if(!i||k.length===0||_)return;(async()=>{var E;j(!0);let S=0;for(const D of k){const L=[D.property_address,D.city,D.state,D.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((E=$.features)!=null&&E[0]){const[V,W]=$.features[0].center;await Z.from("scorecard_transactions").update({latitude:W,longitude:V}).eq("id",D.id),D.latitude=W,D.longitude=V,S++}}catch(B){console.error("Geocode error:",B)}}v(S),j(!1)})()},[i,t]),T.useEffect(()=>{if(!r.current||!i||n.current)return;Mc.accessToken=i;const M=t.filter(D=>D.latitude!=null&&D.longitude!=null);let S=[-98.5795,39.8283],E=4;if(M.length>0){const D=M.reduce((B,$)=>B+$.longitude,0)/M.length,L=M.reduce((B,$)=>B+$.latitude,0)/M.length;S=[D,L],E=M.length===1?12:10}return n.current=new Mc.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:E,center:S}),n.current.addControl(new Mc.NavigationControl,"top-right"),()=>{var D;(D=n.current)==null||D.remove(),n.current=null}},[i]),T.useEffect(()=>{var S;if(!n.current||!i)return;a.current.forEach(E=>E.remove()),a.current=[],(S=o.current)==null||S.remove();const M=t.filter(E=>E.latitude!=null&&E.longitude!=null);if(M.forEach(E=>{var W;const D=E.transaction_type==="buyer",L=D?"#3B82F6":"#10B981",B=document.createElement("div");B.className="cursor-pointer",B.innerHTML=`
${D?'':''}
`;const $=new Mc.Popup({offset:25,closeButton:!0}).setHTML(`
${E.property_address}
${E.city?`
${E.city}${E.state?", "+E.state:""} ${E.zip||""}
`:""}
${D?"Buyer":"Seller"} $${Number(E.sale_price).toLocaleString()}
Closed: ${new Date(E.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(W=E.lead_source)!=null&&W.name?" · "+E.lead_source.name:""}
${E.contact?`
Client: ${E.contact.first_name} ${E.contact.last_name||""}
`:""}
`),V=new Mc.Marker(B).setLngLat([E.longitude,E.latitude]).setPopup($).addTo(n.current);a.current.push(V)}),M.length>1){const E=new Mc.LngLatBounds;M.forEach(D=>E.extend([D.longitude,D.latitude])),n.current.fitBounds(E,{padding:60,maxZoom:13})}else M.length===1&&n.current.flyTo({center:[M[0].longitude,M[0].latitude],zoom:12})},[t,i,_]),h||s?e.jsx(Oe,{children:e.jsx($e,{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(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Gi,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[w.length," of ",t.length," mapped",_&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Oe,{children:e.jsxs($e,{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 MZe=new Date().getFullYear(),zas=Array.from({length:10},(t,s)=>MZe-s);function Bas(){var L;const[t,s]=T.useState(MZe),[r,n]=T.useState(!1),[a,o]=T.useState(!1),[l,i]=T.useState(!1),[d,h]=T.useState(!1),{data:f,isLoading:g}=I1e(t),{yearStats:v,lifetimeStats:_,showCommission:j}=J9e(t),{data:w,isLoading:k}=Q9e(t),{data:M}=doe(),S=t2t(),E=()=>{if(!f||f.length===0)return;const B=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...j?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],$=f.map(ne=>{var ie,ee;return[ne.property_address,ne.city||"",ne.state||"",ne.zip||"",ne.transaction_type,ne.close_date,ne.sale_price,...j?[ne.commission_amount||""]:[],((ie=ne.lead_source)==null?void 0:ie.name)||"",((ee=ne.client_type)==null?void 0:ee.name)||"",ne.contact?`${ne.contact.first_name} ${ne.contact.last_name||""}`.trim():"",ne.is_win?"Yes":"No",ne.notes||""]}),V=[B,...$].map(ne=>ne.map(ie=>`"${String(ie).replace(/"/g,'""')}"`).join(",")).join(` `),W=new Blob([V],{type:"text/csv"}),G=URL.createObjectURL(W),J=document.createElement("a");J.href=G,J.download=`transactions-${t}.csv`,J.click(),URL.revokeObjectURL(G)},D=!f||f.length===0;return e.jsxs(Vs,{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 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),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(er,{value:String(t),onValueChange:B=>s(Number(B)),children:[e.jsx(Qs,{className:"w-[120px]",children:e.jsx(tr,{})}),e.jsx(Js,{children:zas.map(B=>e.jsx(Et,{value:String(B),children:B},B))})]}),e.jsx(Y,{variant:"outline",size:"icon",onClick:()=>h(!d),children:e.jsx(Ic,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsx(Gt,{className:"text-lg",children:"Settings"})}),e.jsx($e,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(je,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(ln,{checked:(M==null?void 0:M.show_commission)??!0,onCheckedChange:B=>S.mutate({show_commission:B})})]})})]}),D&&!g?e.jsx(Oe,{className:"py-12",children:e.jsxs($e,{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(Sc,{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(Y,{onClick:()=>n(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(Y,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ji,{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(Y,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(Vi,{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(Y,{onClick:()=>n(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(Y,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(hm,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(Y,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ji,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(Y,{variant:"outline",onClick:E,disabled:D,children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(Y,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"CSV Template"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:[e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Zn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:v.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.totalTransactions," lifetime"]})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(br,{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:[v.buyerCount,"/",v.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ad,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:fu(v.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[fu(_.totalVolume,!0)," lifetime"]})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jd,{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:fu(v.averagePrice,!0)})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{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:((L=v.topLeadSource)==null?void 0:L.name)||"-"}),v.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[v.topLeadSource.count," deals"]})]})}),j&&e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ad,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Commission"})]}),e.jsx("p",{className:"text-2xl font-bold",children:fu(v.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[fu(_.totalCommission,!0)," lifetime"]})]})})]}),w&&e.jsx(OHe,{goals:w,stats:v,year:t,showCommission:j}),e.jsxs(Qa,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"transactions",children:"Transactions"}),e.jsx(Fs,{value:"charts",children:"Charts"}),e.jsxs(Fs,{value:"map",children:[e.jsx(Gi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(Zs,{value:"transactions",children:e.jsx(DHe,{transactions:f||[],showCommission:j,isLoading:g})}),e.jsx(Zs,{value:"charts",children:e.jsx(SZe,{stats:v,year:t})}),e.jsx(Zs,{value:"map",children:e.jsx(CZe,{transactions:f||[],isLoading:g})})]})]})]}),e.jsx(LHe,{open:r,onOpenChange:n}),e.jsx(Oas,{open:a,onOpenChange:o}),e.jsx(Fas,{open:l,onOpenChange:i,year:t,existingGoals:w})]})}function TZe({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Ys(),[l,i]=T.useState(null),[d,h]=T.useState(!1),[f,g]=T.useState(!1);T.useEffect(()=>{(async()=>{if(!(!t||!o)){h(!0);try{const{data:k,error:M}=await Z.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(M)throw M;if(k&&k.share_token)i(k);else if(k&&!k.share_token){const{data:S,error:E}=await Z.from("listing_shares").update({share_type:"referral_link"}).eq("id",k.id).select("id, share_token, click_count, lead_count").single();if(E)throw E;i(S)}else{const{data:S,error:E}=await Z.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(E)throw E;i(S)}}catch(k){console.error("Error creating share link:",k),be.error("Failed to generate share link")}finally{h(!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),be.success("Link copied to clipboard!"),setTimeout(()=>g(!1),2e3)}catch{be.error("Failed to copy link")}},j=w=>{const k=encodeURIComponent(v),M=encodeURIComponent(`Check out this listing: ${a}`);switch(w){case"email":window.open(`mailto:?subject=${M}&body=${k}`);break;case"text":window.open(`sms:?body=${M}%20${k}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${k}`,"_blank");break}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(en,{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(je,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:d?"Generating...":v,readOnly:!0,className:"font-mono text-sm"}),e.jsx(Y,{onClick:_,disabled:d||!v,variant:f?"default":"outline",children:f?e.jsx(ma,{className:"h-4 w-4"}):e.jsx(Di,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Y,{variant:"outline",className:"flex-1",onClick:()=>j("email"),disabled:d,children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(Y,{variant:"outline",className:"flex-1",onClick:()=>j("text"),disabled:d,children:[e.jsx(Eo,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Y,{variant:"outline",className:"flex-1",onClick:()=>j("facebook"),disabled:d,children:[e.jsx(Qd,{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(je,{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(wi,{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(br,{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 $as={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Uas={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},qas={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function I8({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var w,k;const{user:o}=Ys(),{data:l}=W9e(t.id),i=H9e(),[d,h]=T.useState(!1),f=M=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(M),g=((w=t.photos)==null?void 0:w.find(M=>M.is_primary))||((k=t.photos)==null?void 0:k[0]),v=(o==null?void 0:o.id)===t.agent_id,_=async M=>{M.stopPropagation();try{const S=await i.mutateAsync(t.id);be.success(S.saved?"Listing saved!":"Listing removed from saved")}catch{be.error("Failed to save listing")}},j=M=>{if(M.stopPropagation(),o)h(!0);else{const S=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(S),be.success("Link copied to clipboard!")}};return e.jsxs(Oe,{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(Tx,{className:"h-12 w-12"})}),e.jsx(ct,{className:`absolute top-2 left-2 ${$as[t.status]} text-white border-0`,children:Uas[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(qn,{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(Y,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,children:e.jsx(Ti,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(Y,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:j,title:v?"Copy link":"Share & earn leads",children:v?e.jsx(Kc,{className:"h-4 w-4"}):e.jsx(Sn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(TZe,{open:d,onOpenChange:h,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs($e,{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:f(t.price)}),t.open_to_referrals&&e.jsxs(ct,{variant:"outline",className:"text-xs",children:[e.jsx(br,{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(Gi,{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(k1,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(j1,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tx,{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(ct,{variant:"secondary",className:"text-xs",children:qas[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(wi,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kc,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ti,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(Y,{variant:"outline",size:"sm",className:"flex-1",onClick:M=>{M.stopPropagation(),r()},children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(Y,{variant:"destructive",size:"sm",onClick:M=>{M.stopPropagation(),n()},children:e.jsx(Ir,{className:"h-4 w-4"})})]})]})]})}const Vas=[{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"}],Has=[{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 Was({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Gt,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Xr,{className:"h-4 w-4"})})]})]}),e.jsxs($e,{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(je,{children:"Status"}),e.jsxs(er,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"All statuses"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Statuses"}),Vas.map(a=>e.jsx(Et,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Property Type"}),e.jsxs(er,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"All types"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Types"}),Has.map(a=>e.jsx(Et,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Min Price"}),e.jsx(Be,{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(je,{children:"Max Price"}),e.jsx(Be,{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(je,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(ln,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function Gas({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(vo,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(s0,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(nc,{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(ct,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx($e,{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(Kc,{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(Zn,{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(s0,{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(vo,{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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Community Leaderboard"})}),e.jsx($e,{children:e.jsxs(Qa,{defaultValue:"sharers",children:[e.jsxs(Ga,{className:"w-full",children:[e.jsxs(Fs,{value:"sharers",className:"flex-1",children:[e.jsx(Kc,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(Fs,{value:"listers",className:"flex-1",children:[e.jsx(Zn,{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 VIe={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},HIe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Kas(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Zas({listings:t,isLoading:s}){const r=Yr(),n=T.useRef(null),a=T.useRef(null),o=T.useRef([]),{isAdmin:l}=Ys(),[i,d]=T.useState(""),[h,f]=T.useState(!0),[g,v]=T.useState(!1),_=t.filter(w=>w.latitude!=null&&w.longitude!=null),j=t.filter(w=>(w.latitude==null||w.longitude==null)&&(w.property_address||w.city));return T.useEffect(()=>{(async()=>{f(!0);try{const{data:k}=await Z.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();k!=null&&k.value&&d(k.value)}catch(k){console.error("Error fetching mapbox token:",k)}f(!1)})()},[]),T.useEffect(()=>{if(!i||j.length===0||g)return;(async()=>{var k;v(!0);for(const M of j){const S=[M.property_address,M.city,M.state].filter(Boolean).join(", ");if(S)try{const D=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(S)}.json?access_token=${i}&limit=1`)).json();if((k=D.features)!=null&&k[0]){const[L,B]=D.features[0].center;await Z.from("listings").update({latitude:B,longitude:L}).eq("id",M.id),M.latitude=B,M.longitude=L}}catch(E){console.error("Geocode error:",E)}}v(!1)})()},[i,t]),T.useEffect(()=>{if(!n.current||!i||a.current)return;Mc.accessToken=i;const w=t.filter(S=>S.latitude!=null&&S.longitude!=null);let k=[-98.5795,39.8283],M=4;if(w.length>0){const S=w.reduce((D,L)=>D+L.longitude,0)/w.length,E=w.reduce((D,L)=>D+L.latitude,0)/w.length;k=[S,E],M=w.length===1?12:10}return a.current=new Mc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:M,center:k}),a.current.addControl(new Mc.NavigationControl,"top-right"),()=>{var S;(S=a.current)==null||S.remove(),a.current=null}},[i]),T.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(k=>k.remove()),o.current=[];const w=t.filter(k=>k.latitude!=null&&k.longitude!=null);if(w.forEach(k=>{var B,$,V;const M=VIe[k.status]||"#10B981",S=((B=k.photos)==null?void 0:B.find(W=>W.is_primary))||(($=k.photos)==null?void 0:$[0]),E=document.createElement("div");E.className="cursor-pointer",E.innerHTML=`
`;const D=new Mc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${S!=null&&S.photo_url?``:""}
${Kas(k.price)}
${k.property_address||""}
${k.city}, ${k.state}
${HIe[k.status]||k.status} ${k.bedrooms?`${k.bedrooms} bed`:""} ${k.bathrooms?`${k.bathrooms} bath`:""}
${(V=k.agent)!=null&&V.name?`
Listed by ${k.agent.name}
`:""}
Click to view details →
`),L=new Mc.Marker(E).setLngLat([k.longitude,k.latitude]).setPopup(D).addTo(a.current);o.current.push(L)}),w.length>1){const k=new Mc.LngLatBounds;w.forEach(M=>k.extend([M.longitude,M.latitude])),a.current.fitBounds(k,{padding:60,maxZoom:13})}else w.length===1&&a.current.flyTo({center:[w[0].longitude,w[0].latitude],zoom:12})},[t,i,g]),T.useEffect(()=>(window.__navigateToListing__=w=>{r(`/mission-control/listings/${w}`)},()=>{delete window.__navigateToListing__}),[r]),h||s?e.jsx(Oe,{children:e.jsx($e,{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(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Gi,{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(VIe).map(([w,k])=>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:k}}),e.jsx("span",{className:"text-xs",children:HIe[w]})]},w)),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(Oe,{children:e.jsxs($e,{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 Yas(){var W,G,J,ne,ie,ee,de,oe;const t=Yr(),{brokerageId:s}=Ys(),{data:r,isLoading:n}=B9e(),[a,o]=T.useState("feed"),[l,i]=T.useState(!1),[d,h]=T.useState(""),[f,g]=T.useState({sortBy:"newest"}),{data:v,isLoading:_}=$9e({...f,city:d||f.city}),{data:j,isLoading:w}=Fwt(),{data:k,isLoading:M}=U9e(),{data:S,isLoading:E}=Uwt(),{data:D,isLoading:L}=Hwt(),{data:B}=Vwt(),$=V9e(),V=async ue=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await $.mutateAsync(ue),be.success("Listing deleted successfully")}catch{be.error("Failed to delete listing")}};return n?e.jsx(Vs,{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(Vs,{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(Y,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(ar,{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(Oe,{children:e.jsxs($e,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Zn,{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(Oe,{children:e.jsxs($e,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Ti,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(j==null?void 0:j.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),e.jsx(Oe,{children:e.jsxs($e,{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:(k==null?void 0:k.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(br,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((W=S==null?void 0:S.sent)==null?void 0:W.length)||0)+(((G=S==null?void 0:S.received)==null?void 0:G.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(Qa,{value:a,onValueChange:o,children:[e.jsxs(Ga,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(Fs,{value:"feed",children:"Community Feed"}),s&&e.jsx(Fs,{value:"brokerage",children:"Brokerage"}),e.jsx(Fs,{value:"my-listings",children:"My Listings"}),e.jsx(Fs,{value:"saved",children:"Saved"}),e.jsx(Fs,{value:"referrals",children:"Referrals"}),e.jsx(Fs,{value:"map",children:"Map"}),e.jsx(Fs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by city or neighborhood...",value:d,onChange:ue=>h(ue.target.value),className:"pl-9"})]}),e.jsxs(er,{value:f.sortBy,onValueChange:ue=>g({...f,sortBy:ue}),children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{placeholder:"Sort by"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"newest",children:"Newest First"}),e.jsx(Et,{value:"updated",children:"Recently Updated"}),e.jsx(Et,{value:"price_asc",children:"Price: Low to High"}),e.jsx(Et,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(Y,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(Jy,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(Was,{filters:f,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((ue,ce)=>e.jsxs(Oe,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs($e,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"}),e.jsx(ys,{className:"h-4 w-1/4"})]})]},ce))}):(v==null?void 0:v.length)===0?e.jsx(Oe,{children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx(Zn,{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(Y,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(ar,{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(ue=>e.jsx(I8,{listing:ue,onClick:()=>t(`/mission-control/listings/${ue.id}`)},ue.id))})]}),e.jsx(Zs,{value:"my-listings",className:"space-y-4",children:M?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ue,ce)=>e.jsxs(Oe,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs($e,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(k==null?void 0:k.length)===0?e.jsx(Oe,{children:e.jsxs($e,{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(Y,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(ar,{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:k==null?void 0:k.map(ue=>e.jsx(I8,{listing:ue,showActions:!0,onClick:()=>t(`/mission-control/listings/${ue.id}`),onEdit:()=>t(`/mission-control/listings/${ue.id}/edit`),onDelete:()=>V(ue.id)},ue.id))})}),e.jsx(Zs,{value:"saved",className:"space-y-4",children:w?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ue,ce)=>e.jsxs(Oe,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs($e,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(j==null?void 0:j.length)===0?e.jsx(Oe,{children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx(Ti,{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:j==null?void 0:j.map(ue=>e.jsx(I8,{listing:ue.listing,onClick:()=>t(`/mission-control/listings/${ue.listing.id}`)},ue.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(Kc,{className:"h-4 w-4"}),"Referrals Sent (",((J=S==null?void 0:S.sent)==null?void 0:J.length)||0,")"]}),((ne=S==null?void 0:S.sent)==null?void 0:ne.length)===0?e.jsx(Oe,{children:e.jsx($e,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(ie=S==null?void 0:S.sent)==null?void 0:ie.map(ue=>{var ce,ge;return e.jsx(Oe,{children:e.jsx($e,{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:ue.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((ce=ue.listing)==null?void 0:ce.property_address)||((ge=ue.listing)==null?void 0:ge.city)})]}),e.jsx(ct,{variant:ue.status==="closed"?"default":"secondary",children:ue.status.replace("_"," ")})]})})},ue.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4"}),"Referrals Received (",((ee=S==null?void 0:S.received)==null?void 0:ee.length)||0,")"]}),((de=S==null?void 0:S.received)==null?void 0:de.length)===0?e.jsx(Oe,{children:e.jsx($e,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(oe=S==null?void 0:S.received)==null?void 0:oe.map(ue=>{var ce;return e.jsx(Oe,{children:e.jsxs($e,{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:ue.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(ce=ue.sender)==null?void 0:ce.name]})]}),e.jsx(ct,{variant:ue.status==="closed"?"default":"secondary",children:ue.status.replace("_"," ")})]}),e.jsx(Y,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${ue.listing_id}`),children:"View Listing"})]})},ue.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((ue,ce)=>e.jsxs(Oe,{children:[e.jsx(ys,{className:"h-48 w-full"}),e.jsxs($e,{className:"p-4 space-y-2",children:[e.jsx(ys,{className:"h-5 w-3/4"}),e.jsx(ys,{className:"h-4 w-1/2"})]})]},ce))}):(D==null?void 0:D.length)===0?e.jsx(Oe,{children:e.jsxs($e,{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(Y,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(ar,{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:D==null?void 0:D.map(ue=>e.jsx(I8,{listing:ue,onClick:()=>t(`/mission-control/listings/${ue.id}`)},ue.id))})}),e.jsx(Zs,{value:"map",children:e.jsx(Zas,{listings:v||[],isLoading:_})}),e.jsx(Zs,{value:"leaderboard",children:e.jsx(Gas,{leaderboard:B})})]})]})}):e.jsx(Vs,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Oe,{children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx(Zn,{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 Rle(){const t=lo();return zt({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function AZe(){const t=lo(),s=vs();return Wt({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await Z.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function Fle(){const t=lo();return zt({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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 EZe(){const t=lo(),s=vs();return Wt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await Z.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 Z.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 IZe(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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 Xas(){const t=vs();return Wt({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await Z.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await Z.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 Qas(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.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 Jas(t){return zt({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await Z.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function eis(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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 tis(t){return zt({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await Z.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function sis(){const t=vs();return Wt({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await Z.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 ris(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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 nis(){const t=lo();return zt({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await Z.from("deal_pipeline").select("expected_price, expected_commission, 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),wonValue:a.reduce((o,l)=>o+(l.expected_price||0),0)}},enabled:!!t})}function ais(t){const s=lo();return zt({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await Z.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 iis(){const t=vs();return Wt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await Z.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await Z.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 ois(){const t=vs();return Wt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await Z.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 lis({listing:t}){const s=Yr(),[r,n]=T.useState(""),[a,o]=T.useState(!1),{data:l,isLoading:i}=ais(t.id),{data:d,isLoading:h}=Rle(),{data:f,isLoading:g}=Fle(),v=AZe(),_=iis(),j=ois(),w=EZe(),k=(f==null?void 0:f.filter(L=>!L.listing_id))||[],M=L=>{if(!(d!=null&&d.length))return null;switch(L){case"coming_soon":case"active":case"price_improvement":return d.find(B=>B.name==="Active");case"under_contract":return d.find(B=>B.name==="Under Contract");case"sold":return d.find(B=>B.is_won_stage);default:return d.find(B=>B.name==="Active")}},S=async()=>{o(!0);try{d!=null&&d.length||await v.mutateAsync();const L=M(t.status);await w.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(L==null?void 0:L.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),be.success("Deal created and linked to listing!")}catch(L){console.error("Failed to create deal:",L),be.error("Failed to create deal")}finally{o(!1)}},E=async()=>{if(!r){be.error("Please select a deal");return}try{await _.mutateAsync({dealId:r,listingId:t.id}),be.success("Listing linked to deal!"),n("")}catch{be.error("Failed to link listing")}},D=async()=>{if(l)try{await j.mutateAsync({dealId:l.id,listingId:t.id}),be.success("Listing unlinked from deal")}catch{be.error("Failed to unlink listing")}};return i||h?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Sx,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx($e,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Us,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Oe,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Jm,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs($e,{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(ct,{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(Y,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(qi,{className:"h-3 w-3 ml-1"})]}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:D,disabled:j.isPending,children:j.isPending?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(YE,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs(Gt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Sx,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs($e,{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(Y,{onClick:S,disabled:a||w.isPending,className:"w-full",size:"sm",children:[a||w.isPending?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),k.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(er,{value:r,onValueChange:n,children:[e.jsx(Qs,{className:"flex-1 text-sm",children:e.jsx(tr,{placeholder:"Link to existing deal..."})}),e.jsx(Js,{children:k.map(L=>e.jsx(Et,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(Y,{variant:"secondary",size:"icon",onClick:E,disabled:!r||_.isPending,children:_.isPending?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(Jm,{className:"h-4 w-4"})})]})]})]})]})}const cis={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},dis={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},WIe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function uis(){var ie,ee,de,oe,ue,ce,ge,Te,ve;const{listingId:t}=wl(),s=Yr(),{user:r}=Ys(),{data:n,isLoading:a}=q9e(t||""),{data:o}=W9e(t||""),{data:l}=Bwt(t||""),i=H9e(),d=zwt(),h=$wt(),f=V9e(),g=qwt(),[v,_]=T.useState(!1),[j,w]=T.useState(!1),[k,M]=T.useState(!1),[S,E]=T.useState(null),[D,L]=T.useState({buyerName:"",buyerType:"",notes:""}),B=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=ye=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ye),V=async ye=>{const Se=`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)}`;h.mutate({listingId:n.id,shareType:ye});try{switch(ye){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Se)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(Se),be.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Ke} ${Se}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ke)}&body=${encodeURIComponent(`Check out this listing: ${Se}`)}`);break}}catch(Ae){console.error("Share error:",Ae),be.error("Failed to share")}},W=async()=>{try{await f.mutateAsync(n.id),be.success("Listing deleted"),s("/mission-control/listings")}catch{be.error("Failed to delete listing")}},G=async()=>{if(!D.buyerName.trim()){be.error("Please enter buyer name");return}try{await g.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:D.buyerName,buyerType:D.buyerType||void 0,notes:D.notes||void 0}),be.success("Referral sent successfully!"),w(!1),L({buyerName:"",buyerType:"",notes:""})}catch{be.error("Failed to send referral")}},J=ye=>{var De,Ge;const Se=(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),Ae=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Ee=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",He=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Ue=[Ae,Ee,He].filter(Boolean).join(" | ");switch(ye){case"just_listed":return`🏡 JUST LISTED! ${Se} ${Ke} ${Ue} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(De=n==null?void 0:n.city)==null?void 0:De.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${Se} Now ${Ke}! ${Ue} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${WIe[(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! ${Ue} DM me for details! 📩 #ComingSoon #RealEstate #${(Ge=n==null?void 0:n.city)==null?void 0:Ge.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Vs,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-10 w-32"}),e.jsx(ys,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(ys,{className:"h-48"}),e.jsx(ys,{className:"h-48"}),e.jsx(ys,{className:"h-48"})]})]})});if(!n)return e.jsx(Vs,{title:"Listing Not Found",description:"",children:e.jsx(Oe,{children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(Y,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const ne=((ie=n.photos)==null?void 0:ie.find(ye=>ye.is_primary))||((ee=n.photos)==null?void 0:ee[0]);return e.jsxs(Vs,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Y,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(bi,{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:()=>ne&&E(ne.photo_url),children:ne?e.jsx("img",{src:ne.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((ye,Se)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>E(ye.photo_url),children:e.jsx("img",{src:ye.photo_url,alt:`Photo ${Se+2}`,className:"w-full h-full object-cover"})},ye.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(Oe,{children:e.jsxs($e,{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(ct,{className:`${cis[n.status]} text-white border-0`,children:dis[n.status]}),n.is_featured&&e.jsxs(ct,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(qn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(ct,{variant:"outline",children:[e.jsx(br,{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(Gi,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(Ti,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(Y,{variant:"outline",size:"icon",onClick:()=>d.mutate(n.id),children:l?e.jsx(xk,{className:"h-4 w-4"}):e.jsx(dg,{className:"h-4 w-4"})}),!B&&e.jsxs(Y,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>M(!0),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsxs(Y,{variant:"outline",children:[e.jsx(Kc,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(ju,{children:[e.jsxs(Va,{onClick:()=>V("copy"),children:[e.jsx(Di,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Va,{onClick:()=>V("facebook"),children:[e.jsx(Qd,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Va,{onClick:()=>V("text"),children:[e.jsx(Eo,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Va,{onClick:()=>V("email"),children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),B&&e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(Y,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:e.jsx(Ir,{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(k1,{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(j1,{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(Tx,{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(xn,{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(ct,{variant:"secondary",children:[e.jsx(Ya,{className:"h-3 w-3 mr-1"}),WIe[n.property_type]]}),n.lot_size&&e.jsxs(ct,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(ct,{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(Y,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(bn,{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(wi,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kc,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ti,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Share Content"})}),e.jsx($e,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(ye=>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:[ye.replace("_"," ")," Caption"]}),e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(J(ye)),be.success("Caption copied!")},children:e.jsx(Di,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:J(ye)})]},ye))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Listing Agent"})}),e.jsxs($e,{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:((ue=(oe=n.agent)==null?void 0:oe.name)==null?void 0:ue.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ce=n.agent)==null?void 0:ce.name)||"Unknown"}),((Te=(ge=n.agent)==null?void 0:ge.brokerage)==null?void 0:Te.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!B&&e.jsx("div",{className:"space-y-2",children:((ve=n.agent)==null?void 0:ve.email)&&e.jsx(Y,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),B&&e.jsx(lis,{listing:n}),!B&&n.open_to_referrals&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs($e,{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(Y,{className:"w-full",onClick:()=>w(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(js,{open:!!S,onOpenChange:()=>E(null),children:e.jsx(_s,{className:"max-w-4xl",children:e.jsx("img",{src:S||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(js,{open:v,onOpenChange:_,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Delete Listing"}),e.jsx(en,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(Y,{variant:"destructive",onClick:W,disabled:f.isPending,children:f.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(js,{open:j,onOpenChange:w,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Send Buyer Referral"}),e.jsx(en,{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(je,{children:"Buyer Name *"}),e.jsx(Be,{value:D.buyerName,onChange:ye=>L({...D,buyerName:ye.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Buyer Type"}),e.jsxs(er,{value:D.buyerType,onValueChange:ye=>L({...D,buyerType:ye}),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select type"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"first_time",children:"First-Time Buyer"}),e.jsx(Et,{value:"investor",children:"Investor"}),e.jsx(Et,{value:"relocating",children:"Relocating"}),e.jsx(Et,{value:"upgrade",children:"Upgrading"}),e.jsx(Et,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Notes"}),e.jsx(Rr,{value:D.notes,onChange:ye=>L({...D,notes:ye.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(Y,{onClick:G,disabled:g.isPending,children:g.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(TZe,{open:k,onOpenChange:M,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 his({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=Yr(),{user:a}=Ys(),[o,l]=T.useState(!1),[i,d]=T.useState([]),[h,f]=T.useState(!1),[g,v]=T.useState(null),[_,j]=T.useState({});T.useEffect(()=>{t&&a?w():v(null)},[t,a]);const w=async()=>{if(!t)return;const{data:W,error:G}=await Z.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();!G&&W&&(v(W),k(W))},k=async W=>{try{const{data:G,error:J}=await Z.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:W.bunny_video_id,isAgentVideo:!0}});!J&&(G!=null&&G.thumbnailUrl)&&j(ne=>({...ne,[W.id]:{thumbnailUrl:G.thumbnailUrl}}))}catch(G){console.warn("Failed to get signed URL",G)}},M=async()=>{if(a){f(!0);try{const{data:W,error:G}=await Z.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(G)throw G;d(W||[]),W!=null&&W.length&&S(W)}catch(W){console.error("Error fetching videos:",W),be.error("Failed to load videos")}finally{f(!1)}}},S=async W=>{var G;try{const J=W.map(oe=>oe.bunny_video_id),{data:ne,error:ie}=await Z.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:J,isAgentVideo:!0}});if(ie)throw ie;const ee=(ne==null?void 0:ne.assets)||{},de={};for(const oe of W)(G=ee[oe.bunny_video_id])!=null&&G.thumbnailUrl&&(de[oe.id]={thumbnailUrl:ee[oe.bunny_video_id].thumbnailUrl});j(oe=>({...oe,...de}))}catch(J){console.warn("Failed to bulk-fetch signed URLs",J)}},E=()=>{l(!0),M()},D=W=>{s(W.id),v(W),l(!1),be.success("Video selected")},L=()=>{s(null),v(null)},B=()=>{const W=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(W)}`)},$=W=>{if(!W)return"0:00";const G=Math.floor(W/60),J=W%60;return`${G}:${J.toString().padStart(2,"0")}`},V=W=>{var G;return((G=_[W.id])==null?void 0:G.thumbnailUrl)||W.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[g?e.jsx(Oe,{className:"overflow-hidden",children:e.jsx($e,{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:[V(g)?e.jsx("img",{src:V(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(Wn,{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(Kl,{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(Y,{type:"button",variant:"outline",size:"sm",onClick:E,children:"Change"}),e.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:L,className:"text-destructive hover:text-destructive",children:e.jsx(Xr,{className:"h-4 w-4"})})]})]})})}):e.jsx(Oe,{className:"border-dashed",children:e.jsx($e,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Wn,{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(Y,{type:"button",variant:"outline",onClick:E,className:"gap-2",children:[e.jsx(L4,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(Y,{type:"button",variant:"outline",onClick:B,className:"gap-2",children:[e.jsx(hg,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(js,{open:o,onOpenChange:l,children:e.jsxs(_s,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Ls,{children:e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(L4,{className:"h-5 w-5"}),"Select a Video"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:h?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Wn,{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(Y,{onClick:B,className:"gap-2",children:[e.jsx(hg,{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(W=>e.jsxs("button",{type:"button",onClick:()=>D(W),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===W.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:[V(W)?e.jsx("img",{src:V(W),alt:W.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(Wn,{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(Kl,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),W.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:$(W.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:W.title||"Untitled Video"})})]},W.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(Y,{type:"button",variant:"ghost",onClick:B,className:"gap-2",children:[e.jsx(hg,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(Y,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const mis=[{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"}],pis=[{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 GIe(){var de;const{listingId:t}=wl(),[s]=Oc(),r=s.get("brokerage"),n=Yr(),{user:a}=Ys(),o=!!t&&t!=="new",l=!!r&&!o,{data:i,isLoading:d}=q9e(o?t:""),h=Pwt(),f=Lwt(),g=Dwt(),v=Owt(),_=Rwt(),{data:j=[]}=zt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:oe,error:ue}=await Z.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(ue)throw ue;return oe||[]},enabled:l}),[w,k]=T.useState(""),[M,S]=T.useState(!1),[E,D]=T.useState([]),[L,B]=T.useState([]),[$,V]=T.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});T.useEffect(()=>{var oe,ue,ce,ge,Te;i&&o&&V({property_address:i.property_address||"",city:i.city||"",state:i.state||"",neighborhood:i.neighborhood||"",price:((oe=i.price)==null?void 0:oe.toString())||"",property_type:i.property_type,status:i.status,bedrooms:((ue=i.bedrooms)==null?void 0:ue.toString())||"",bathrooms:((ce=i.bathrooms)==null?void 0:ce.toString())||"",square_footage:((ge=i.square_footage)==null?void 0:ge.toString())||"",lot_size:i.lot_size||"",year_built:((Te=i.year_built)==null?void 0:Te.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 W=oe=>{if(!oe)return;const ue=Array.from(oe);D(ge=>[...ge,...ue]);const ce=ue.map(ge=>URL.createObjectURL(ge));B(ge=>[...ge,...ce])},G=oe=>{URL.revokeObjectURL(L[oe]),D(ue=>ue.filter((ce,ge)=>ge!==oe)),B(ue=>ue.filter((ce,ge)=>ge!==oe))},J=async oe=>{var ue;if(!(!oe||!i)){S(!0);try{for(const ce of Array.from(oe)){const ge=ce.name.split(".").pop(),Te=`${a==null?void 0:a.id}/${i.id}/${Date.now()}.${ge}`,{error:ve}=await Z.storage.from("listing-photos").upload(Te,ce);if(ve)throw ve;const{data:{publicUrl:ye}}=Z.storage.from("listing-photos").getPublicUrl(Te);await v.mutateAsync({listingId:i.id,photoUrl:ye,isPrimary:!((ue=i.photos)!=null&&ue.length)})}be.success("Photos uploaded!")}catch(ce){console.error("Upload error:",ce),be.error("Failed to upload photos")}finally{S(!1)}}},ne=async oe=>{for(let ue=0;ue{if(i)try{await _.mutateAsync({photoId:oe,listingId:i.id}),be.success("Photo removed")}catch{be.error("Failed to remove photo")}},ee=async oe=>{if(oe.preventDefault(),!$.city.trim()||!$.state.trim()||!$.price){be.error("Please fill in required fields (City, State, Price)");return}if(l&&!w){be.error("Please select an agent to assign this listing to");return}try{const ue={property_address:$.property_address||null,city:$.city,state:$.state,neighborhood:$.neighborhood||null,price:Number($.price),property_type:$.property_type,status:$.status,bedrooms:$.bedrooms?Number($.bedrooms):null,bathrooms:$.bathrooms?Number($.bathrooms):null,square_footage:$.square_footage?Number($.square_footage):null,lot_size:$.lot_size||null,year_built:$.year_built?Number($.year_built):null,has_hoa:$.has_hoa,description:$.description||null,agent_notes:$.agent_notes||null,agent_notes_public:$.agent_notes_public,mls_link:$.mls_link||null,video_link:$.video_link||null,video_id:$.video_id||null,allow_sharing:$.allow_sharing,open_to_referrals:$.open_to_referrals,open_to_social_promotion:$.open_to_social_promotion,share_with_brokerage:$.share_with_brokerage,is_public:$.is_public};if(o)await g.mutateAsync({id:t,...ue}),be.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{S(!0);let ce;if(l&&w?ce=await f.mutateAsync({agentId:w,...ue}):ce=await h.mutateAsync(ue),E.length>0)try{await ne(ce.id),L.forEach(ge=>URL.revokeObjectURL(ge)),D([]),B([])}catch(ge){console.error("Photo upload error:",ge),be.error("Listing created but some photos failed to upload")}S(!1),be.success("Listing created!"),n(l?"/my-brokerage":`/mission-control/listings/${ce.id}`)}}catch(ue){console.error("Save error:",ue),be.error("Failed to save listing"),S(!1)}};return o&&d?e.jsx(Vs,{title:"Loading...",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-10 w-32"}),e.jsx(ys,{className:"h-[600px] w-full"})]})}):e.jsx(Vs,{title:o?"Edit Listing":l?"Add Listing for Agent":"Add Listing",description:"",children:e.jsxs("form",{onSubmit:ee,className:"space-y-6",children:[e.jsxs(Y,{type:"button",variant:"ghost",onClick:()=>n(l?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(bi,{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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Assign to Agent *"})}),e.jsxs($e,{children:[e.jsxs(er,{value:w,onValueChange:k,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select an agent..."})}),e.jsx(Js,{children:j.map(oe=>e.jsx(Et,{value:oe.id,children:oe.name||oe.email},oe.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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Property Details"})}),e.jsx($e,{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(je,{children:"Property Address"}),e.jsx(Be,{value:$.property_address,onChange:oe=>V({...$,property_address:oe.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"City *"}),e.jsx(Be,{value:$.city,onChange:oe=>V({...$,city:oe.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"State *"}),e.jsx(Be,{value:$.state,onChange:oe=>V({...$,state:oe.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Neighborhood"}),e.jsx(Be,{value:$.neighborhood,onChange:oe=>V({...$,neighborhood:oe.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Price *"}),e.jsx(Be,{type:"number",value:$.price,onChange:oe=>V({...$,price:oe.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Property Type"}),e.jsxs(er,{value:$.property_type,onValueChange:oe=>V({...$,property_type:oe}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:pis.map(oe=>e.jsx(Et,{value:oe.value,children:oe.label},oe.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Status"}),e.jsxs(er,{value:$.status,onValueChange:oe=>V({...$,status:oe}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:mis.map(oe=>e.jsx(Et,{value:oe.value,children:oe.label},oe.value))})]})]})]})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Property Specs (Optional)"})}),e.jsx($e,{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(je,{children:"Bedrooms"}),e.jsx(Be,{type:"number",value:$.bedrooms,onChange:oe=>V({...$,bedrooms:oe.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Bathrooms"}),e.jsx(Be,{type:"number",step:"0.5",value:$.bathrooms,onChange:oe=>V({...$,bathrooms:oe.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Sq Ft"}),e.jsx(Be,{type:"number",value:$.square_footage,onChange:oe=>V({...$,square_footage:oe.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Lot Size"}),e.jsx(Be,{value:$.lot_size,onChange:oe=>V({...$,lot_size:oe.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Year Built"}),e.jsx(Be,{type:"number",value:$.year_built,onChange:oe=>V({...$,year_built:oe.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(ln,{checked:$.has_hoa,onCheckedChange:oe=>V({...$,has_hoa:oe})}),e.jsx(je,{children:"Has HOA"})]})]})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Description & Links"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Description"}),e.jsx(Rr,{value:$.description,onChange:oe=>V({...$,description:oe.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Agent Notes"}),e.jsx(Rr,{value:$.agent_notes,onChange:oe=>V({...$,agent_notes:oe.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{checked:$.agent_notes_public,onCheckedChange:oe=>V({...$,agent_notes_public:oe})}),e.jsx(je,{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(je,{children:"MLS Link"}),e.jsx(Be,{value:$.mls_link,onChange:oe=>V({...$,mls_link:oe.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Video Link"}),e.jsx(Be,{value:$.video_link,onChange:oe=>V({...$,video_link:oe.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Wn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx($e,{children:e.jsx(his,{selectedVideoId:$.video_id,onVideoSelect:oe=>V({...$,video_id:oe}),listingId:o?t:void 0})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Photos"})}),e.jsxs($e,{children:[e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[o&&((de=i==null?void 0:i.photos)==null?void 0:de.map(oe=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:oe.photo_url,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>ie(oe.id),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:e.jsx(Xr,{className:"h-3 w-3"})}),oe.is_primary&&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"})]},oe.id))),!o&&L.map((oe,ue)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:oe,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>G(ue),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:e.jsx(Xr,{className:"h-3 w-3"})}),ue===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"})]},ue)),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:[M?e.jsx(Us,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ji,{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:oe=>o?J(oe.target.files):W(oe.target.files),disabled:M})]})]}),!o&&E.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[E.length," photo",E.length!==1?"s":""," will be uploaded when you save."]})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Sharing & Collaboration"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(ln,{checked:$.allow_sharing,onCheckedChange:oe=>V({...$,allow_sharing:oe})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(ln,{checked:$.open_to_referrals,onCheckedChange:oe=>V({...$,open_to_referrals:oe})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(ln,{checked:$.open_to_social_promotion,onCheckedChange:oe=>V({...$,open_to_social_promotion:oe})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(ln,{checked:$.share_with_brokerage,onCheckedChange:oe=>V({...$,share_with_brokerage:oe})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(ln,{checked:$.is_public,onCheckedChange:oe=>V({...$,is_public:oe})})]})]})]}),e.jsx(Y,{type:"submit",className:"w-full",size:"lg",disabled:h.isPending||g.isPending,children:h.isPending||g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):o?"Update Listing":"Create Listing"})]})]})]})})}function zle({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=T.useRef(null),i=T.useRef(null),d=T.useRef(null),h=T.useRef([]),f=T.useRef(null),g=T.useRef(null),v=T.useRef(null),_=T.useRef(null),j=Q3(),[w,k]=T.useState(!0),[M,S]=T.useState(!0),[E,D]=T.useState(null),[L,B]=T.useState(!1),[$,V]=T.useState(!1),[W,G]=T.useState(null),[J,ne]=T.useState(null),[ie,ee]=T.useState(0),[de,oe]=T.useState("user"),[ue,ce]=T.useState(0),[ge,Te]=T.useState(!1),[ve,ye]=T.useState(!0),[Se,Ke]=T.useState(null),[Ae,Ee]=T.useState(!1),[He,Ue]=T.useState(null),De=T.useRef(null),Ge=T.useRef(r);Ge.current=r;const wt=T.useCallback(_t=>{k(_t)},[]),Ie=T.useRef(w),st=T.useCallback(async()=>{var qe,Lt;S(!0),Ke(null);const _t=j&&w;console.log("[VideoRecorder] initCamera start",{isMobile:j,usePortraitMode:w,shouldBePortrait:_t,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 Rt=j&&_t?{facingMode:{ideal:de},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:de},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",Rt);const Kt=await navigator.mediaDevices.getUserMedia({video:Rt,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),Kt.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=Kt,D(!0);const ss=Kt.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",ss.width,"x",ss.height),l.current){const fs=l.current;fs.srcObject=Kt,fs.muted=!0,fs.playsInline=!0,fs.autoplay=!0,fs.setAttribute("muted",""),fs.setAttribute("playsinline",""),fs.setAttribute("autoplay","");try{(qe=fs.load)==null||qe.call(fs)}catch(yt){console.warn("[VideoRecorder] videoEl.load failed",yt)}const fr=async()=>{try{return await fs.play(),console.log("[VideoRecorder] preview play ok"),Ee(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:fs.readyState,videoWidth:fs.videoWidth,videoHeight:fs.videoHeight})},300),!0}catch(yt){return console.warn("[VideoRecorder] preview play blocked",yt),Ee(!0),!1}};await new Promise(yt=>{let bs=!1;const gr=()=>{bs||(bs=!0,yt())},Br=()=>{fr().finally(gr)};fs.onloadedmetadata=Br,fs.onloadeddata=Br,setTimeout(gr,1500)})}try{g.current=new AudioContext;const fs=g.current.createMediaStreamSource(Kt);v.current=g.current.createAnalyser(),v.current.fftSize=256,fs.connect(v.current);const fr=()=>{if(v.current){const yt=new Uint8Array(v.current.frequencyBinCount);v.current.getByteFrequencyData(yt);const bs=yt.reduce((gr,Br)=>gr+Br)/yt.length;ce(Math.min(100,bs/128*100))}_.current=requestAnimationFrame(fr)};fr()}catch(fs){console.warn("Audio context not available:",fs)}}catch(Rt){console.error("Camera initialization error:",Rt),D(!1);let Kt="Failed to access camera or microphone.";Rt.name==="NotAllowedError"?Kt="Camera permission denied. Please allow camera access in your browser settings.":Rt.name==="NotFoundError"?Kt="No camera found. Please connect a camera and try again.":Rt.name==="NotReadableError"?Kt="Camera is in use by another application. Please close other apps using the camera.":Rt.message&&(Kt=Rt.message),Ke(Kt),(Lt=Ge.current)==null||Lt.call(Ge,Kt)}finally{S(!1)}},[de,j,w]);T.useEffect(()=>{Ie.current!==w&&E&&!L&&!J&&(Ie.current=w,st())},[w,E,L,J,st]),T.useEffect(()=>(st(),()=>{d.current&&d.current.getTracks().forEach(_t=>_t.stop()),f.current&&clearInterval(f.current),_.current&&cancelAnimationFrame(_.current),g.current&&g.current.close(),De.current&&clearInterval(De.current),J&&URL.revokeObjectURL(J)}),[st,J]),T.useEffect(()=>{if(M||E!==!0||J)return;const _t=d.current,qe=l.current;!_t||!qe||(qe.srcObject!==_t&&(qe.srcObject=_t,qe.muted=!0,qe.playsInline=!0,qe.autoplay=!0,qe.setAttribute("muted",""),qe.setAttribute("playsinline",""),qe.setAttribute("autoplay","")),qe.play().then(()=>Ee(!1)).catch(Lt=>{Ee(!0),console.warn("Live preview play blocked on mount:",Lt)}))},[E,M,J]),T.useEffect(()=>{n==null||n(L)},[L,n]);const he=T.useCallback(async()=>{if(J)return;const _t=l.current;if(_t)try{await _t.play(),Ee(!1)}catch(qe){Ee(!0),console.warn("Live preview still blocked (needs user gesture):",qe)}},[J]),We=T.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),f.current&&(clearInterval(f.current),f.current=null),B(!1),V(!1)},[]),et=T.useCallback(()=>{if(!d.current)return;he(),h.current=[],ee(0);const qe=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Rt=>MediaRecorder.isTypeSupported(Rt)),Lt=new MediaRecorder(d.current,qe?{mimeType:qe,videoBitsPerSecond:25e5}:{videoBitsPerSecond:25e5});Lt.ondataavailable=Rt=>{Rt.data.size>0&&h.current.push(Rt.data)},Lt.onstop=()=>{var ss;const Rt=Lt.mimeType||qe||((ss=h.current[0])==null?void 0:ss.type)||"video/webm",Kt=new Blob(h.current,{type:Rt});G(Kt);const Xt=URL.createObjectURL(Kt);ne(Xt)},i.current=Lt,Lt.start(100),B(!0),f.current=setInterval(()=>{ee(Rt=>Rt>=t-1?(We(),t):Rt+1)},1e3)},[he,t,We]),Ye=T.useCallback(()=>{if(He!==null)return;Ue(3);let _t=3;De.current=setInterval(()=>{_t-=1,_t<=0?(De.current&&clearInterval(De.current),De.current=null,Ue(null),et()):Ue(_t)},1e3)},[He,et]),ke=T.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),V(!0),f.current&&clearInterval(f.current))},[]),at=T.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),V(!1),f.current=setInterval(()=>{ee(_t=>_t>=t-1?(We(),t):_t+1)},1e3))},[t,We]),Fe=T.useCallback(()=>{J&&URL.revokeObjectURL(J),G(null),ne(null),ee(0),Te(!1),ye(!0),l.current&&d.current&&(l.current.srcObject=d.current,l.current.muted=!0,he())},[he,J]),it=T.useCallback(()=>{oe(_t=>_t==="user"?"environment":"user")},[]),dt=T.useCallback(()=>{W&&s(W,ie)},[W,ie,s]),tt=T.useCallback(()=>{l.current&&J&&(ge?l.current.pause():(ye(!1),l.current.muted=!1,l.current.play()),Te(!ge))},[J,ge]);T.useEffect(()=>{if(!J)return;const _t=l.current;if(!_t)return;ye(!1),_t.pause(),_t.removeAttribute("src"),_t.srcObject=null,_t.load(),_t.src=J,_t.currentTime=0,_t.playsInline=!0,_t.muted=!1,_t.onended=()=>Te(!1);const qe=()=>{var Kt;const Lt=_t.error,Rt=Lt?`Recorded video failed to play (code ${Lt.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Lt),(Kt=Ge.current)==null||Kt.call(Ge,Rt)};return _t.addEventListener("error",qe),_t.load(),()=>{_t.removeEventListener("error",qe)}},[J]);const ut=_t=>{const qe=Math.floor(_t/60),Lt=_t%60;return`${qe}:${Lt.toString().padStart(2,"0")}`},xt=j&&w?"aspect-[9/16]":"aspect-video";return M?e.jsx("div",{className:$t("flex items-center justify-center bg-black rounded-lg",xt,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(Us,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):E===!1?e.jsx("div",{className:$t("flex items-center justify-center bg-black rounded-lg",xt,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:Se||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Y,{onClick:()=>st(),variant:"secondary",className:"w-full",children:[e.jsx(el,{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:$t("flex flex-col gap-2",a),children:[j&&!L&&!J&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(Ck,{className:$t("h-4 w-4",w?"text-muted-foreground":"text-primary")}),e.jsx(je,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(ln,{id:"orientation-toggle",checked:w,onCheckedChange:wt}),e.jsx(je,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(n0,{className:$t("h-4 w-4",w?"text-primary":"text-muted-foreground")})]}),e.jsxs("div",{className:$t("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{he()},children:[e.jsx("video",{ref:l,src:J??void 0,className:$t("w-full bg-black",w&&!J?"object-contain":"object-cover",xt,de==="user"&&!J&&"scale-x-[-1]"),playsInline:!0,controls:!!J,muted:J?ve:!0,autoPlay:!J},J??"live"),!J&&Ae&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(Y,{type:"button",variant:"secondary",onClick:()=>void he(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!J&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),He!==null&&!J&&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:He},He),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:$t("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:[ut(ie)," / ",ut(t)]})]}),L&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(rl,{value:ie/t*100,className:"h-1 rounded-none"})}),!J&&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(DE,{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:`${ue}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:J?e.jsxs(e.Fragment,{children:[e.jsxs(Y,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:Fe,children:[e.jsx(el,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(Y,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:tt,children:ge?e.jsx(ep,{className:"h-5 w-5"}):e.jsx(Kl,{className:"h-5 w-5"})}),e.jsxs(Y,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:dt,children:[e.jsx(ma,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:it,disabled:L||He!==null,children:e.jsx(Ik,{className:"h-5 w-5"})}),!L&&He===null?e.jsx(Y,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Ye,children:e.jsx(Wn,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:$?at:ke,children:$?e.jsx(Kl,{className:"h-5 w-5"}):e.jsx(ep,{className:"h-5 w-5"})}),e.jsx(Y,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:We,children:e.jsx(Tx,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const PZe="teleprompter_settings",wme={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function fis(){try{const t=localStorage.getItem(PZe);return t?{...wme,...JSON.parse(t)}:wme}catch{return wme}}function gis(t){try{localStorage.setItem(PZe,JSON.stringify(t))}catch{}}function LZe({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=T.useRef(null),d=T.useRef(null),h=T.useRef(0),f=T.useRef(0),[g,v]=T.useState(fis),{scrollSpeed:_,fontSize:j,lineHeight:w,opacity:k,position:M,isMirrored:S}=g,E=T.useCallback((ne,ie)=>{v(ee=>{const de={...ee,[ne]:ie};return gis(de),de})},[]),[D,L]=T.useState(!1),[B,$]=T.useState(null),V=T.useCallback(ne=>{if(!i.current)return;h.current===0&&(h.current=ne);const ie=ne-h.current;h.current=ne,f.current+=_*ie/1e3;const ee=Math.floor(f.current);ee>0&&(i.current.scrollTop+=ee,f.current-=ee);const{scrollTop:de,scrollHeight:oe,clientHeight:ue}=i.current;if(de+ue>=oe){L(!1);return}d.current=requestAnimationFrame(V)},[_]);T.useEffect(()=>(D?(h.current=0,f.current=0,d.current=requestAnimationFrame(V)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[D,V]),T.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){$(3);let ne=3;const ie=setInterval(()=>{ne-=1,ne<=0?(clearInterval(ie),$(null),o==null||o(),L(!0)):$(ne)},1e3);return()=>clearInterval(ie)}else setTimeout(()=>L(!0),100);else n||(L(!1),$(null))},[n,s,a,o]);const W=T.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),G=T.useCallback(()=>{L(ne=>!ne)},[]);if(!s)return e.jsx("div",{className:$t("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(Y,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const J={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:$t("absolute inset-0 pointer-events-none",l),children:[B!==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:B},B),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:$t("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",J[M],B!==null&&"opacity-30"),style:{opacity:B!==null?.3:k},children:e.jsxs("div",{ref:i,className:$t("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",S&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${j}px`,lineHeight:w,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:t}),e.jsx("div",{className:"h-full"})]})}),e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsx(Y,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(Ic,{className:"h-4 w-4"})})}),e.jsx(nl,{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(je,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),e.jsx(og,{value:[_],onValueChange:([ne])=>E("scrollSpeed",ne),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(je,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[j,"px"]})]}),e.jsx(og,{value:[j],onValueChange:([ne])=>E("fontSize",ne),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(je,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w.toFixed(1)})]}),e.jsx(og,{value:[w*10],onValueChange:([ne])=>E("lineHeight",ne/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(je,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(k*100),"%"]})]}),e.jsx(og,{value:[k*100],onValueChange:([ne])=>E("opacity",ne/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:M==="top"?"default":"outline",size:"sm",onClick:()=>E("position","top"),children:e.jsx(kx,{className:"h-4 w-4"})}),e.jsx(Y,{variant:M==="center"?"default":"outline",size:"sm",onClick:()=>E("position","center"),children:e.jsx(T1,{className:"h-4 w-4"})}),e.jsx(Y,{variant:M==="bottom"?"default":"outline",size:"sm",onClick:()=>E("position","bottom"),children:e.jsx(Gc,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{className:"text-xs",children:"Mirror Mode"}),e.jsx(ln,{checked:S,onCheckedChange:ne=>E("isMirrored",ne)})]})]})})]}),e.jsx(Y,{variant:"secondary",size:"icon",onClick:G,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:D?e.jsx(ep,{className:"h-4 w-4"}):e.jsx(Kl,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"secondary",size:"icon",onClick:W,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(Ik,{className:"h-4 w-4"})}),e.jsxs(Y,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Wp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function xis({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Sa(),[o,l]=T.useState(""),[i,d]=T.useState(null),[h,f]=T.useState("levelup"),{data:g,isLoading:v}=W6t(),{data:_,isLoading:j}=G6t(),{data:w,isLoading:k}=K6t(),M=Z6t(),S=T.useMemo(()=>_?_.filter($=>{const V=!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())||$.tags.some(G=>G.toLowerCase().includes(o.toLowerCase())),W=!i||$.category_id===i;return V&&W}):[],[_,o,i]),E=T.useMemo(()=>w?w.filter($=>!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())):[],[w,o]),D=$=>{t({title:$.title,text:$.script_text})},L=async $=>{try{await M.mutateAsync($),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},B=v||j||k;return e.jsxs("div",{className:$t("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search scripts...",value:o,onChange:$=>l($.target.value),className:"pl-9"})]})}),e.jsxs(Qa,{value:h,onValueChange:$=>f($),className:"flex-1 flex flex-col",children:[e.jsxs(Ga,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(Fs,{value:"levelup",children:[e.jsx(Yn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(Fs,{value:"my-scripts",children:[e.jsx(ug,{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(ct,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),g==null?void 0:g.map($=>e.jsx(ct,{variant:i===$.id?"default":"outline",className:"cursor-pointer",onClick:()=>d($.id),children:$.name},$.id))]}),e.jsx(po,{className:"flex-1 max-h-[50vh]",children:B?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Yn,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:S.map($=>e.jsxs(Oe,{className:$t("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>D($),children:[e.jsx(Ht,{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(Gt,{className:"text-sm font-medium truncate",children:$.title}),$.category&&e.jsx(ct,{variant:"secondary",className:"mt-1 text-xs",children:$.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:V=>{V.stopPropagation(),L($)},children:e.jsx(ug,{className:"h-4 w-4"})}),e.jsx(Ri,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx($e,{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(Y,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(po,{className:"flex-1 max-h-[50vh]",children:k?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):E.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ug,{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:E.map($=>e.jsxs(Oe,{className:$t("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>D($),children:[e.jsx(Ht,{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(Gt,{className:"text-sm font-medium truncate",children:$.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:$.is_custom?e.jsx(ct,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(ct,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(Ri,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx($e,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]})]})]})}function yis({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=T.useState(()=>{const i=e5(t);return new Set([i.category])}),l=i=>{o(d=>{const h=new Set(d);return h.has(i)?h.delete(i):h.add(i),h})};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(Us,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:Ybt.map(i=>{const d=Xbt(i.id),h=a.has(i.id),f=d.some(g=>g.id===t);return e.jsxs(Dk,{open:h,onOpenChange:()=>l(i.id),children:[e.jsxs(Ok,{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,")"]}),f&&!h&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(Gc,{className:$t("h-4 w-4 text-muted-foreground transition-transform",h&&"rotate-180")})]}),e.jsx(Rk,{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:$t("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(ma,{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: "',e5(t).headerText(r),'"']})]})}function DZe({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=T.useState(r.page_template||"default"),[i,d]=T.useState(!1),[h,f]=T.useState(!1),[g,v]=T.useState(r.page_template||"default"),[_,j]=T.useState([]),[w,k]=T.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[M,S]=T.useState(!1),[E,D]=T.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";T.useEffect(()=>{t&&_.length===0&&B()},[t]);const B=async()=>{D(!0);try{const{data:de,error:oe}=await Z.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(oe)throw oe;const ue=(de||[]).map(ce=>({id:ce.id,name:[ce.first_name,ce.last_name].filter(Boolean).join(" ")||"Unnamed",email:ce.email||null}));j(ue)}catch(de){console.error("Failed to fetch contacts:",de)}finally{D(!1)}},$=async de=>{k(de),S(!1),d(!0);try{const{error:oe}=await Z.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(oe)throw oe;be.success(de?`Assigned to ${de.name}`:"Contact removed"),a==null||a()}catch(oe){console.error("Failed to update contact:",oe),be.error("Failed to update contact")}finally{d(!1)}},V=async de=>{l(de),d(!0);try{const{error:oe}=await Z.from("agent_videos").update({page_template:de}).eq("id",r.id);if(oe)throw oe;v(de),be.success("Template saved!"),a==null||a()}catch(oe){console.error("Failed to save template:",oe),be.error("Failed to save template"),l(g)}finally{d(!1)}},W=(w==null?void 0:w.name)||null,G=()=>{const de=r.title||"Video Message",oe=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},J=async()=>{if(!r.thumbnail_url){be.error("Video thumbnail not available yet");return}const de=G(),oe=`Watch: ${r.title||"Video Message"} ${L}`;try{const ue=new Blob([de],{type:"text/html"}),ce=new Blob([oe],{type:"text/plain"}),ge=new ClipboardItem({"text/html":ue,"text/plain":ce});await navigator.clipboard.write([ge]),be.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(oe+` `+de),be.success("Copied! Paste into your email.")}},ne=async()=>{await navigator.clipboard.writeText(L),f(!0),be.success("Share link copied!"),setTimeout(()=>f(!1),2e3)},ie=()=>{const oe=e5(o).headerText(W),ue=o==="default"?`Check out this video: ${L}`:`${oe} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(ue)}`,"_self")},ee=()=>{const de=e5(o),oe=de.headerText(W),ue=o==="default"?r.title||"Video Message":oe,ce=`${de.subText} Watch the video: ${L}`,ge=w!=null&&w.email?encodeURIComponent(w.email):"";window.open(`mailto:${ge}?subject=${encodeURIComponent(ue)}&body=${encodeURIComponent(ce)}`,"_self")};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(Ro,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(en,{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(je,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(_l,{open:M,onOpenChange:S,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":M,className:"flex-1 justify-between",disabled:i,children:[w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Wo,{className:"h-4 w-4 text-muted-foreground"}),w.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(mg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(nl,{className:"w-[300px] p-0",align:"start",children:e.jsxs(wg,{children:[e.jsx(jg,{placeholder:"Search contacts..."}),e.jsxs(kg,{children:[e.jsx(Ng,{children:E?"Loading...":"No contacts found."}),e.jsx(Sg,{children:_.map(de=>e.jsxs(Vm,{value:de.name,onSelect:()=>$(de),children:[e.jsx(ma,{className:$t("mr-2 h-4 w-4",(w==null?void 0:w.id)===de.id?"opacity-100":"opacity-0")}),de.name]},de.id))})]})]})})]}),w&&e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>$(null),disabled:i,className:"shrink-0",children:e.jsx(Xr,{className:"h-4 w-4"})})]}),w&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',e5(o).headerText(w.name),'"']})]}),e.jsx(yis,{selectedTemplate:o,onSelect:V,contactName:W,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:L,readOnly:!0,className:"font-mono text-sm"}),e.jsx(Y,{onClick:ne,variant:h?"default":"outline",className:"shrink-0 gap-2",children:h?e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Di,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Share for Email"}),e.jsxs(Y,{variant:"outline",className:"w-full gap-2",onClick:J,children:[e.jsx(fl,{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(je,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Y,{variant:"outline",className:"flex-1 gap-2",onClick:ie,children:[e.jsx(Eo,{className:"h-4 w-4"}),"Text"]}),e.jsxs(Y,{variant:"outline",className:"flex-1 gap-2",onClick:ee,children:[e.jsx(zr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(Hn,{children:e.jsx(Y,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function vis(){var Ye;const t=Yr(),[s]=Oc(),{toast:r}=Sa(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d}=PHe(),{data:h}=of(),f=TN(),g=eLt(),[v,_]=T.useState("record"),[j,w]=T.useState(""),[k,M]=T.useState(!1),[S,E]=T.useState(!1),[D,L]=T.useState(!1),[B,$]=T.useState(null),[V,W]=T.useState(0),[G,J]=T.useState(0),[ne,ie]=T.useState(null),[ee,de]=T.useState(null),[oe,ue]=T.useState(n||""),[ce,ge]=T.useState(""),[Te,ve]=T.useState(""),[ye,Se]=T.useState(null),[Ke,Ae]=T.useState(null),[Ee,He]=T.useState(null),[Ue,De]=T.useState(!1),Ge=T.useCallback(async(ke,at)=>{$(ke),_("uploading");try{const{videoId:Fe,uploadUrl:it}=await sL(ce||"Quick Video Touch");ie(Fe);const{apiKey:dt}=await rL(Fe),tt=new XMLHttpRequest;tt.upload.onprogress=qe=>{qe.lengthComputable&&W(qe.loaded/qe.total*100)},await new Promise((qe,Lt)=>{tt.onload=()=>{tt.status>=200&&tt.status<300?qe():Lt(new Error(`Upload failed: ${tt.status}`))},tt.onerror=()=>Lt(new Error("Upload failed")),tt.open("PUT",it),tt.setRequestHeader("AccessKey",dt),tt.send(ke)}),_("processing");let ut=0;const xt=Date.now(),_t=90*1e3;for(;ut<4;){if(await new Promise(Lt=>setTimeout(Lt,3e3)),Date.now()-xt>_t){const Lt=ke.size/1048576,Rt=`https://iframe.mediadelivery.net/play/${Fe}/${Fe}`;await f.mutateAsync({bunny_video_id:Fe,playback_url:Rt,file_size_mb:Lt,title:ce||"Quick Video Touch",notes:Te||void 0,contact_id:oe&&oe!=="none"?oe: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 qe=await X5(Fe);if(ut=qe.status,J(qe.encodeProgress||0),ut===4)de({playbackUrl:qe.directPlayUrl,thumbnailUrl:qe.thumbnailUrl,previewUrl:qe.previewUrl||null,duration:qe.length||at,fileSizeMb:(qe.storageSize||ke.size)/(1024*1024)});else if(ut===5||ut===6)throw new Error("Video processing failed")}_("details")}catch(Fe){console.error("Upload error:",Fe),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),_("record")}},[ce,r]),wt=async()=>{if(!(!ne||!ee))try{const ke=oe&&oe!=="none"?oe:null,at=await f.mutateAsync({bunny_video_id:ne,contact_id:ke,playback_url:ee.playbackUrl,thumbnail_url:ee.thumbnailUrl,preview_url:ee.previewUrl,duration_seconds:ee.duration,file_size_mb:ee.fileSizeMb,title:ce||"Quick Video Touch",notes:Te,task_id:a||null,status:"ready"});Se(at.id),Ae(at.share_token||null),ke&&await g.mutateAsync({contactId:ke,videoId:at.id,notes:Te}),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"})}},Ie=(ke,at)=>{navigator.clipboard.writeText(at),He(ke),setTimeout(()=>He(null),2e3),r({title:"Copied to clipboard!"})},st=()=>Ke?`https://video.relevelup.com/${Ke}`:(ee==null?void 0:ee.playbackUrl)||"",he=()=>{const ke=h==null?void 0:h.find(tt=>tt.id===oe),at=ke?`${ke.first_name}`:"",Fe=(ke==null?void 0:ke.phone)||"",it=(ke==null?void 0:ke.email)||"",dt=st();return{text:`Hey${at?` ${at}`:""}! I recorded a quick video for you: ${dt}`,link:dt,contactPhone:Fe,contactEmail:it}},We=()=>{const{text:ke,contactPhone:at}=he(),Fe=at?`sms:${at}?body=${encodeURIComponent(ke)}`:`sms:?body=${encodeURIComponent(ke)}`;window.open(Fe,"_self")},et=()=>{const{link:ke,contactEmail:at}=he(),Fe="Check out this video",it=`I recorded a quick video for you: ${ke}`,dt=at?`mailto:${at}?subject=${encodeURIComponent(Fe)}&body=${encodeURIComponent(it)}`:`mailto:?subject=${encodeURIComponent(Fe)}&body=${encodeURIComponent(it)}`;window.open(dt,"_self")};return o?e.jsx(Vs,{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(Y,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(bi,{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(zle,{maxDurationSeconds:60,onRecordingComplete:Ge,onRecordingStateChange:L,className:"w-full",teleprompterContent:k&&j&&e.jsx(LZe,{text:j,isVisible:k,onToggleVisibility:()=>M(!1),isRecording:D,startCountdown:!0})}),!k&&j&&e.jsxs(Y,{variant:"outline",className:"mt-4",onClick:()=>M(!0),children:[e.jsx(Yn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Oe,{className:"lg:col-span-1",children:[e.jsx(Ht,{className:"pb-2",children:e.jsx(Gt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsx(Rr,{placeholder:"Type or paste your script here...",value:j,onChange:ke=>w(ke.target.value),rows:6}),e.jsxs(z6,{open:S,onOpenChange:E,children:[e.jsx(a1e,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:"w-full",children:[e.jsx(Yn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(q3,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(B6,{className:"p-4 border-b",children:e.jsx($6,{children:"Select a Script"})}),e.jsx(xis,{onSelectScript:ke=>{w(ke.text),E(!1),M(!0)},className:"h-[calc(100vh-80px)]"})]})]}),j&&e.jsx(Y,{className:"w-full",onClick:()=>M(!0),children:"Use Script"})]})]})]}),v==="uploading"&&e.jsx(Oe,{className:"max-w-md mx-auto",children:e.jsxs($e,{className:"pt-6 text-center",children:[e.jsx(ji,{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(rl,{value:V,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[V.toFixed(0),"%"]})]})}),v==="processing"&&e.jsx(Oe,{className:"max-w-md mx-auto",children:e.jsxs($e,{className:"pt-6 text-center space-y-4",children:[e.jsx(Us,{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(rl,{value:G,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[G.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(Oe,{className:"max-w-lg mx-auto",children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Video Details"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Title"}),e.jsx(Be,{value:ce,onChange:ke=>ge(ke.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Attach to Contact (Optional)"}),e.jsxs(er,{value:oe,onValueChange:ue,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"No contact - use anywhere"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ro,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),h==null?void 0:h.map(ke=>e.jsx(Et,{value:ke.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wo,{className:"h-4 w-4"}),ke.first_name," ",ke.last_name]})},ke.id))]})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Notes"}),e.jsx(Rr,{value:Te,onChange:ke=>ve(ke.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(Y,{className:"w-full",onClick:wt,disabled:f.isPending,children:[f.isPending&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),v==="share"&&e.jsxs(Oe,{className:"max-w-lg mx-auto",children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(ma,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs($e,{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(Y,{variant:"outline",className:"justify-start",onClick:We,children:[e.jsx(Eo,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(Y,{variant:"outline",className:"justify-start",onClick:et,children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(Y,{variant:"outline",className:"justify-start",onClick:()=>Ie("link",he().link),children:[e.jsx(Ro,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Ee==="link"&&e.jsx(ma,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(Y,{variant:"outline",className:"justify-start",onClick:()=>De(!0),children:[e.jsx(hd,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(Y,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(Y,{onClick:()=>{_("record"),$(null),ie(null),de(null)},children:"Record Another"})]})]})]}),ye&&Ke&&e.jsx(DZe,{open:Ue,onOpenChange:De,video:{id:ye,share_token:Ke,title:ce||null,contact_id:oe||null,thumbnail_url:(ee==null?void 0:ee.thumbnailUrl)||null},contactName:((Ye=h==null?void 0:h.find(ke=>ke.id===oe))==null?void 0:Ye.first_name)||null})]})}):e.jsx(Vs,{title:"Quick Video Touch",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(Lu,{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(Y,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function _is({open:t,onOpenChange:s}){const{data:r}=of(),{data:n}=Boe(),a=TN(),o=T.useRef(null),[l,i]=T.useState(null),[d,h]=T.useState(""),[f,g]=T.useState(""),[v,_]=T.useState(""),[j,w]=T.useState(!1),[k,M]=T.useState(0),[S,E]=T.useState("idle"),D=(n==null?void 0:n.total_storage_mb)||0,B=((n==null?void 0:n.max_storage_mb)||1024)-D,$=J=>{var ee;const ne=(ee=J.target.files)==null?void 0:ee[0];if(!ne)return;if(!ne.type.startsWith("video/")){be.error("Please select a video file");return}const ie=ne.size/(1024*1024);if(ie>500){be.error("Video file must be less than 500MB");return}if(ie>B){be.error(`Not enough storage. You have ${B.toFixed(1)} MB remaining.`);return}i(ne),d||h(ne.name.replace(/\.[^/.]+$/,""))},V=async()=>{if(!l){be.error("Please select a video file");return}w(!0),M(0),E("creating");try{const{data:J,error:ne}=await Z.functions.invoke("bunny-upload",{body:{action:"create",title:d||l.name,isAgentVideo:!0}});if(ne)throw new Error(ne.message);const{videoId:ie,libraryId:ee}=J;E("uploading");const{data:de,error:oe}=await Z.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ie,isAgentVideo:!0}});if(oe)throw new Error(oe.message);await new Promise((ge,Te)=>{const ve=new XMLHttpRequest;ve.upload.addEventListener("progress",ye=>{if(ye.lengthComputable){const Se=Math.round(ye.loaded/ye.total*100);M(Se)}}),ve.addEventListener("load",()=>{ve.status>=200&&ve.status<300?ge():Te(new Error(`Upload failed with status ${ve.status}`))}),ve.addEventListener("error",()=>Te(new Error("Upload failed"))),ve.open("PUT",de.uploadUrl),ve.setRequestHeader("AccessKey",de.apiKey),ve.send(l)}),E("processing");const ue=l.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${ee}/${ie}`;await a.mutateAsync({bunny_video_id:ie,playback_url:ce,file_size_mb:ue,title:d||l.name,notes:f||void 0,contact_id:v||void 0,status:"processing",touch_type:"video_upload"}),be.success("Video uploaded successfully! Processing may take a few minutes."),W()}catch(J){console.error("Upload error:",J),be.error(J instanceof Error?J.message:"Failed to upload video")}finally{w(!1),E("idle")}},W=()=>{j||(i(null),h(""),g(""),_(""),M(0),E("idle"),s(!1))},G=()=>{switch(S){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${k}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(js,{open:t,onOpenChange:W,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Upload Video"}),e.jsx(en,{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(je,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Wn,{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"]})]}),!j&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:J=>{J.stopPropagation(),i(null)},children:e.jsx(Xr,{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 J;return(J=o.current)==null?void 0:J.click()},children:[e.jsx(ji,{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:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"title",children:"Title"}),e.jsx(Be,{id:"title",value:d,onChange:J=>h(J.target.value),placeholder:"Enter video title",disabled:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Associate with Contact (optional)"}),e.jsxs(er,{value:v||"__none__",onValueChange:J=>_(J==="__none__"?"":J),disabled:j,children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select a contact"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(J=>e.jsxs(Et,{value:J.id,children:[J.first_name," ",J.last_name||""]},J.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Rr,{id:"notes",value:f,onChange:J=>g(J.target.value),placeholder:"Add any notes about this video",rows:2,disabled:j})]}),j&&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(Us,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:G()})]}),e.jsx(rl,{value:S==="uploading"?k:S==="processing"?100:10})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:W,disabled:j,children:"Cancel"}),e.jsx(Y,{onClick:V,disabled:!l||j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ji,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function bis({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=T.useState([]),[d,h]=T.useState(null),[f,g]=T.useState(!1),[v,_]=T.useState(!1),[j,w]=T.useState(""),[k,M]=T.useState(""),[S,E]=T.useState(""),[D,L]=T.useState(!1),B=r.share_token?`https://video.relevelup.com/${r.share_token}`:"",$=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",V=r.title||"Video Message";T.useEffect(()=>{t&&l.length===0&&W()},[t]),T.useEffect(()=>{if(t&&(M(`I recorded a video for you — ${V}`),E("Hey! I recorded a quick video just for you. Click below to watch it:"),h(null),w(""),r.contact_id)){const de=l.find(oe=>oe.id===r.contact_id);de&&(h(de),w(de.email||""))}},[t,r.contact_id,l]);const W=async()=>{_(!0);try{const{data:de,error:oe}=await Z.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(oe)throw oe;i(de||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},G=de=>{h(de),g(!1),w(de.email||""),E(`Hey ${de.first_name}! I recorded a quick video just for you. Click below to watch it:`),M(`I recorded a video for you — ${V}`)},J=()=>{h(null),w(""),E("Hey! I recorded a quick video just for you. Click below to watch it:")},ne=de=>`${de.first_name} ${de.last_name||""}`.trim(),ie=()=>`
${S.split(/\n\n+/).map(oe=>`

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

`).join("")}

▶ Watch Video

`,ee=async()=>{if(!j){be.error("Please enter a recipient email");return}if(!B){be.error("Video does not have a share link");return}L(!0);try{const de=ie(),{data:oe,error:ue}=await Z.functions.invoke("gmail-send",{body:{to:j,subject:k,body:de,contactId:(d==null?void 0:d.id)||null}});if(ue)throw ue;if(!(oe!=null&&oe.success))throw new Error((oe==null?void 0:oe.error)||"Failed to send");be.success("Video email sent!"),s(!1),o==null||o()}catch(de){console.error("Gmail send error:",de),be.error("Failed to send: "+(de instanceof Error?de.message:"Unknown error"))}finally{L(!1)}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(zr,{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(je,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(_l,{open:f,onOpenChange:g,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Wo,{className:"h-4 w-4 text-muted-foreground"}),ne(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(mg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(nl,{className:"w-[350px] p-0",align:"start",children:e.jsxs(wg,{children:[e.jsx(jg,{placeholder:"Search contacts..."}),e.jsxs(kg,{children:[e.jsx(Ng,{children:v?"Loading...":"No contacts found."}),e.jsx(Sg,{children:l.filter(de=>de.email).map(de=>e.jsxs(Vm,{value:`${de.first_name} ${de.last_name||""} ${de.email||""}`,onSelect:()=>G(de),children:[e.jsx(ma,{className:$t("mr-2 h-4 w-4",(d==null?void 0:d.id)===de.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ne(de)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:de.email})]})]},de.id))})]})]})})]}),d&&e.jsx(Y,{variant:"ghost",size:"icon",onClick:J,className:"shrink-0",children:e.jsx(Xr,{className:"h-4 w-4"})})]})]}),!d&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(Be,{id:"video-to",value:j,onChange:de=>w(de.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(ud,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Be,{id:"video-subject",value:k,onChange:de=>M(de.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Rr,{id:"video-message",value:S,onChange:de=>E(de.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(je,{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:[$?e.jsx("img",{src:$,alt:V,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(Kl,{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(Kl,{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(Y,{variant:"outline",onClick:()=>s(!1),disabled:D,children:"Cancel"}),e.jsxs(Y,{onClick:ee,disabled:D||!j||!k,className:"gap-2",children:[D?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(Wa,{className:"h-4 w-4"}),D?"Sending...":"Send Video Email"]})]})]})]})})}const wis=()=>{const{user:t}=Ys();return zt({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function jis({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=T.useState(!1),[l,i]=T.useState(!1),d=n&&t&&!a,h=s&&!l;return!h&&!d?e.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:e.jsx(Wn,{className:"h-12 w-12 text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[h&&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 kis({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:h,onShareWithTemplate:f,onSendViaGmail:g,isGmailConnected:v,getContactName:_,getShareUrl:j,copyToClipboard:w,formatDuration:k}){const[M,S]=T.useState(!1);return e.jsxs(Oe,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(jis,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:M}),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(Kl,{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:k(t.duration_seconds)}),t.status!=="ready"&&e.jsx(ct,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx($e,{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(Wo,{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(ca,{className:"h-3 w-3"}),e.jsx("span",{children:Bs(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(wi,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),v&&t.share_token&&e.jsxs(Y,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:E=>{E.stopPropagation(),g==null||g()},children:[e.jsx(zr,{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(Wo,{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(ca,{className:"h-3 w-3"}),e.jsx("span",{children:Bs(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(wi,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:E=>E.stopPropagation(),children:e.jsx(hx,{className:"h-4 w-4"})})}),e.jsxs(ju,{align:"end",className:"bg-popover",children:[e.jsxs(Va,{onClick:E=>{E.stopPropagation(),n()},children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(eN,{}),e.jsxs(Va,{onClick:E=>{E.stopPropagation(),f()},children:[e.jsx(hd,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Va,{onClick:E=>{E.stopPropagation(),w(j(t),"Share link")},children:[e.jsx(Ro,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Va,{onClick:E=>{E.stopPropagation(),i()},children:[e.jsx(vk,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Va,{onClick:E=>{E.stopPropagation(),d()},children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Va,{onClick:E=>{E.stopPropagation(),h()},children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),v&&t.share_token&&e.jsxs(Va,{onClick:E=>{E.stopPropagation(),g==null||g()},children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Va,{onClick:E=>{E.stopPropagation(),o()},children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(eN,{}),t.contact_id&&e.jsxs(Va,{onClick:E=>{E.stopPropagation(),l()},children:[e.jsx(Wo,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Va,{onClick:E=>{E.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(Ir,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function Nis(){var qe,Lt;const t=Yr(),{data:s,isLoading:r,refetch:n}=Y6t(),{data:a}=Boe(),{data:o}=of(),l=J6t(),i=Q6t(),{isGmailConnected:d,gmailEmail:h}=MN(),{data:f}=h_(),{data:g=[],isLoading:v}=wis(),[_,j]=T.useState("my"),[w,k]=T.useState(""),[M,S]=T.useState(null),[E,D]=T.useState(!1),[L,B]=T.useState(!1),[$,V]=T.useState(!1),[W,G]=T.useState(!1),[J,ne]=T.useState(!1),[ie,ee]=T.useState(""),[de,oe]=T.useState(!1),[ue,ce]=T.useState(!1),[ge,Te]=T.useState(!1),[ve,ye]=T.useState(!1),[Se,Ke]=T.useState(""),[Ae,Ee]=T.useState({}),He=Rt=>{if(!Rt)return"Unassigned";const Kt=o==null?void 0:o.find(Xt=>Xt.id===Rt);return Kt?`${Kt.first_name} ${Kt.last_name||""}`.trim():"Unknown"},Ue=Rt=>{if(!Rt)return"0:00";const Kt=Math.floor(Rt/60),Xt=Rt%60;return`${Kt}:${Xt.toString().padStart(2,"0")}`},De=s==null?void 0:s.filter(Rt=>{if(!w)return!0;const Kt=He(Rt.contact_id).toLowerCase(),Xt=(Rt.title||"").toLowerCase(),ss=(Rt.notes||"").toLowerCase();return Kt.includes(w.toLowerCase())||Xt.includes(w.toLowerCase())||ss.includes(w.toLowerCase())}),[Ge,wt]=T.useState(!1);T.useEffect(()=>{if(Ge)return;(async()=>{if(!(s!=null&&s.length))return;const Kt=s.filter(ss=>ss.status==="processing"&&ss.bunny_video_id);if(!Kt.length)return;let Xt=!1;for(const ss of Kt)try{const{data:fs,error:fr}=await Z.functions.invoke("bunny-upload",{body:{action:"status",videoId:ss.bunny_video_id,isAgentVideo:!0}});if(fr||!fs)continue;fs.status===4&&(await Z.from("agent_videos").update({status:"ready",playback_url:fs.directPlayUrl,thumbnail_url:fs.thumbnailUrl,preview_url:fs.previewUrl,duration_seconds:fs.length||ss.duration_seconds,updated_at:new Date().toISOString()}).eq("id",ss.id),Xt=!0)}catch(fs){console.warn("Reconcile check failed for video",ss.id,fs)}wt(!0),Xt&&n()})()},[s,Ge,n]),T.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const Kt=s.filter(yt=>(yt==null?void 0:yt.bunny_video_id)&&!Ae[yt.id]);if(!Kt.length)return;const Xt=Kt.map(yt=>yt.bunny_video_id),{data:ss,error:fs}=await Z.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Xt,isAgentVideo:!0}});if(fs)throw fs;const fr=(ss==null?void 0:ss.assets)||{};Ee(yt=>{const bs={...yt};for(const gr of Kt)fr[gr.bunny_video_id]&&(bs[gr.id]={previewUrl:fr[gr.bunny_video_id].previewUrl,thumbnailUrl:fr[gr.bunny_video_id].thumbnailUrl});return bs})})().catch(Kt=>console.warn("Failed to load signed Bunny asset URLs",Kt))},[s,Ae]);const Ie=(a==null?void 0:a.total_storage_mb)||0,st=(a==null?void 0:a.max_storage_mb)||1024,he=Ie/st*100,We=he>=80,et=he>=100,Ye=async(Rt,Kt)=>{await navigator.clipboard.writeText(Rt),be.success(`${Kt} copied to clipboard`)},ke=Rt=>Rt.share_token?`https://video.relevelup.com/${Rt.share_token}`:Rt.playback_url||"",at=Rt=>{const Kt=ke(Rt),Xt=o==null?void 0:o.find(gr=>gr.id===Rt.contact_id),ss=He(Rt.contact_id),fs=ss!=="Unassigned"?ss.split(" ")[0]:"",fr=(Xt==null?void 0:Xt.phone)||"",yt=`Hey${fs?` ${fs}`:""}! I recorded a quick video message for you. Check it out: ${Kt}`,bs=fr?`sms:${fr}?body=${encodeURIComponent(yt)}`:`sms:?body=${encodeURIComponent(yt)}`;window.open(bs,"_self")},Fe=Rt=>{const Kt=o==null?void 0:o.find(bs=>bs.id===Rt.contact_id),Xt=(Kt==null?void 0:Kt.email)||"",ss=ke(Rt),fs="Check out this video",fr=`I recorded a quick video for you: ${ss}`,yt=Xt?`mailto:${Xt}?subject=${encodeURIComponent(fs)}&body=${encodeURIComponent(fr)}`:`mailto:?subject=${encodeURIComponent(fs)}&body=${encodeURIComponent(fr)}`;window.open(yt,"_self")},it=Rt=>{var fs;const Kt=ke(Rt),Xt=Rt.title||"Video Message",ss=Rt.share_token?`https://video.relevelup.com/thumb/${Rt.share_token}`:((fs=Ae[Rt.id])==null?void 0:fs.thumbnailUrl)||Rt.thumbnail_url||"";return``},dt=async Rt=>{if(!Rt.thumbnail_url&&!Rt.share_token){be.error("Video thumbnail not available yet");return}const Kt=it(Rt),Xt=ke(Rt),ss=`Watch: ${Rt.title||"Video Message"} ${Xt}`;try{const fs=new Blob([Kt],{type:"text/html"}),fr=new Blob([ss],{type:"text/plain"}),yt=new ClipboardItem({"text/html":fs,"text/plain":fr});await navigator.clipboard.write([yt]),be.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ss+` `+Kt),be.success("Copied! Paste into your email.")}},tt=async Rt=>{try{be.loading("Preparing download...",{id:"download"});const{data:Kt,error:Xt}=await Z.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Rt.bunny_video_id,isAgentVideo:!0}});if(Xt||!(Kt!=null&&Kt.downloadUrl))throw new Error((Xt==null?void 0:Xt.message)||"Failed to get download URL");const fs=`${((Rt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,fr=await fetch(Kt.downloadUrl);if(!fr.ok)throw new Error("Failed to fetch video file");const yt=await fr.blob(),bs=URL.createObjectURL(yt),gr=document.createElement("a");gr.href=bs,gr.download=fs,gr.rel="noreferrer",document.body.appendChild(gr),gr.click(),gr.remove(),URL.revokeObjectURL(bs),be.success("Download started",{id:"download"})}catch(Kt){console.error("Download error:",Kt),be.error("Could not force download (your browser may block it).",{id:"download"})}},ut=async Rt=>{S(Rt),oe(!0),ee(""),ne(!0);try{const{data:Kt,error:Xt}=await Z.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Rt.bunny_video_id,title:Rt.title,isAgentVideo:!0,shareToken:Rt.share_token}});if(Xt||!(Kt!=null&&Kt.html))throw new Error("Failed to generate CRM embed code");ee(Kt.html)}catch(Kt){console.error("CRM embed error:",Kt),be.error("Failed to generate CRM embed code"),ne(!1)}finally{oe(!1)}},xt=Rt=>{S(Rt),D(!0)},_t=async()=>{if(M)try{await l.mutateAsync({id:M.id,bunnyVideoId:M.bunny_video_id,hardDelete:!0}),B(!1),S(null),be.success("Video deleted successfully")}catch{be.error("Failed to delete video")}};return e.jsx(Vs,{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"})]}),f&&((qe=f.team)==null?void 0:qe.shared_videos_enabled)&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>j("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"}),e.jsxs("button",{onClick:()=>j("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(br,{className:"h-3.5 w-3.5"}),"Team"]})]})]}),_==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Y,{variant:"outline",onClick:()=>V(!0),children:[e.jsx(ji,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(Y,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?e.jsx(Sis,{videos:g,isLoading:v,searchTerm:w,setSearchTerm:k}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:We?"border-amber-500":et?"border-destructive":"",children:e.jsxs($e,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(SE,{className:`h-5 w-5 ${et?"text-destructive":We?"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:[Ie.toFixed(1)," MB / ",st>=1024?`${(st/1024).toFixed(0)} GB`:`${st} MB`]})]}),e.jsx(rl,{value:Math.min(he,100),className:`h-2 ${et?"[&>div]:bg-destructive":We?"[&>div]:bg-amber-500":""}`})]}),We&&!et&&e.jsxs(ct,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),et&&e.jsxs(ct,{variant:"destructive",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),et&&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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search videos by contact, title, or notes...",value:w,onChange:Rt=>k(Rt.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"})}):(De==null?void 0:De.length)===0?e.jsx(Oe,{children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx(Wn,{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(Y,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(ar,{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:De==null?void 0:De.map(Rt=>{var Kt,Xt;return e.jsx(kis,{video:Rt,previewSrc:(Kt=Ae[Rt.id])==null?void 0:Kt.previewUrl,thumbnailSrc:(Xt=Ae[Rt.id])==null?void 0:Xt.thumbnailUrl,onOpen:()=>xt(Rt),onDelete:()=>{S(Rt),B(!0)},onRename:()=>{S(Rt),Ke(Rt.title||""),ye(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Rt.contact_id}`),onGetEmbedCode:()=>{S(Rt),G(!0)},onCopyEmailHtml:()=>dt(Rt),onEmbedToCrm:()=>ut(Rt),onShareWithTemplate:()=>{S(Rt),ce(!0)},onSendViaGmail:()=>{S(Rt),Te(!0)},isGmailConnected:d,getContactName:He,getShareUrl:ke,copyToClipboard:Ye,formatDuration:Ue},Rt.id)})}),e.jsx(js,{open:E,onOpenChange:D,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:(M==null?void 0:M.title)||"Video Preview"}),e.jsx(en,{children:(M==null?void 0:M.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wo,{className:"h-3 w-3"}),He(M.contact_id)]})})]}),M&&e.jsxs("div",{className:"space-y-4",children:[M.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(Us,{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(Y,{variant:"outline",size:"sm",onClick:()=>{D(!1),n()},children:[e.jsx(el,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:M.playback_url?(()=>{let Rt=M.playback_url;return Rt.includes("iframe.mediadelivery.net/play/")&&(Rt=Rt.replace("/play/","/embed/"),Rt+=(Rt.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Rt.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Rt,title:M.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:M.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:M.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>be.error("Video preview failed to load")},M.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(Wn,{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(Y,{variant:"outline",onClick:()=>at(M),children:[e.jsx(Eo,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(Y,{variant:"outline",onClick:()=>Fe(M),children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(Y,{variant:"outline",onClick:()=>Ye(ke(M),"Share link"),children:[e.jsx(Di,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Y,{variant:"outline",onClick:()=>dt(M),children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Y,{variant:"outline",onClick:()=>tt(M),children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(Y,{variant:"outline",onClick:()=>{D(!1),ut(M)},children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(Y,{variant:"outline",onClick:()=>{D(!1),ce(!0)},children:[e.jsx(hd,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(M==null?void 0:M.share_token)&&e.jsxs(Y,{variant:"outline",onClick:()=>{D(!1),Te(!0)},children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(Y,{variant:"destructive",onClick:()=>{D(!1),B(!0)},children:[e.jsx(Ir,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(js,{open:L,onOpenChange:B,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Delete Video"}),e.jsx(en,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>B(!1),children:"Cancel"}),e.jsx(Y,{variant:"destructive",onClick:_t,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(_is,{open:$,onOpenChange:V}),e.jsx(js,{open:W,onOpenChange:G,children:e.jsxs(_s,{className:"sm:max-w-lg",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Embed Video"}),e.jsx(en,{children:"Copy this code to embed the video on your website."})]}),M&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Embed Code"}),e.jsx(Rr,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(Y,{className:"flex-1",onClick:()=>{const Rt=``;Ye(Rt,"Embed code")},children:[e.jsx(Di,{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."})]})]})}),M&&e.jsx(DZe,{open:ue,onOpenChange:ce,video:M,contactName:He(M.contact_id)}),M&&e.jsx(bis,{open:ge,onOpenChange:Te,video:M,gmailEmail:h,signedThumbnailUrl:(Lt=Ae[M.id])==null?void 0:Lt.thumbnailUrl}),e.jsx(js,{open:ve,onOpenChange:ye,children:e.jsxs(_s,{className:"max-w-sm",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Rename Video"}),e.jsx(en,{children:"Enter a new title for this video."})]}),e.jsx(Be,{value:Se,onChange:Rt=>Ke(Rt.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Rt=>{Rt.key==="Enter"&&Se.trim()&&i.mutate({id:M.id,title:Se.trim()},{onSuccess:()=>{be.success("Video renamed"),ye(!1)}})}}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>ye(!1),children:"Cancel"}),e.jsx(Y,{disabled:!Se.trim()||i.isPending,onClick:()=>{i.mutate({id:M.id,title:Se.trim()},{onSuccess:()=>{be.success("Video renamed"),ye(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(js,{open:J,onOpenChange:ne,children:e.jsxs(_s,{className:"sm:max-w-lg",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(bn,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(en,{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(Us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):ie?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"CRM Email HTML"}),e.jsx(Rr,{readOnly:!0,rows:12,value:ie,className:"font-mono text-xs"})]}),e.jsxs(Y,{className:"w-full",onClick:()=>{Ye(ie,"CRM embed code")},children:[e.jsx(Di,{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 Sis({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=T.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=T.useMemo(()=>{const i=new Map;return a.forEach(d=>{const h=i.get(d.owner_user_id);h?h.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),h=i%60;return`${d}:${h.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{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(Oe,{children:e.jsxs($e,{className:"py-12 text-center",children:[e.jsx(br,{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(_a,{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(ct,{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(h=>e.jsxs(Oe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center",children:[h.thumbnail_url?e.jsx("img",{src:h.thumbnail_url,alt:h.title||"Video",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:f=>{f.target.style.display="none"}}):e.jsx(Wn,{className:"h-10 w-10 text-muted-foreground"}),h.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(h.duration_seconds)})]}),e.jsxs($e,{className:"p-3",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:h.title||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[h.recipient_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wo,{className:"h-3 w-3"}),h.recipient_name]}),h.view_count!=null&&h.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wi,{className:"h-3 w-3"}),h.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ca,{className:"h-3 w-3"}),Bs(new Date(h.created_at),"MMM d")]})]})]})]},h.id))})]},i))})]})}const Cis=()=>{const{user:t}=Ys();return zt({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function Mis({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Cis(),[a,o]=T.useState(""),[l,i]=T.useState("all"),d=T.useMemo(()=>{if(!r)return[];const v=new Map;return r.forEach(_=>{v.has(_.owner_user_id)||v.set(_.owner_user_id,{id:_.owner_user_id,name:_.owner_name||"Unknown",avatar:_.owner_avatar_url})}),Array.from(v.values())},[r]),h=T.useMemo(()=>{if(!r)return[];let v=r;if(l!=="all"&&(v=v.filter(_=>_.owner_user_id===l)),a.trim()){const _=a.toLowerCase();v=v.filter(j=>{var w,k,M,S;return j.deal_name.toLowerCase().includes(_)||((w=j.contact_name)==null?void 0:w.toLowerCase().includes(_))||((k=j.property_address)==null?void 0:k.toLowerCase().includes(_))||((M=j.city)==null?void 0:M.toLowerCase().includes(_))||((S=j.owner_name)==null?void 0:S.toLowerCase().includes(_))})}return v},[r,a,l]),f=T.useMemo(()=>{const v=new Map;return h.forEach(_=>{v.has(_.owner_user_id)||v.set(_.owner_user_id,{name:_.owner_name||"Unknown",avatar:_.owner_avatar_url,deals:[]}),v.get(_.owner_user_id).deals.push(_)}),Array.from(v.entries())},[h]),g=v=>v?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(v):null;return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-2xl max-h-[80vh] flex flex-col",children:[e.jsx(Ls,{children:e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Team Pipeline"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search deals...",value:a,onChange:v=>o(v.target.value),className:"pl-9"})]}),e.jsxs(er,{value:l,onValueChange:i,children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{placeholder:"All Members"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Members"}),d.map(v=>e.jsx(Et,{value:v.id,children:v.name},v.id))]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-4 mt-2",children:n?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(v=>e.jsx(ys,{className:"h-20 w-full"},v))}):h.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(br,{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 based on your team's visibility settings."})]}):f.map(([v,_])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 sticky top-0 bg-background py-1 z-10",children:[e.jsxs(fn,{className:"h-6 w-6",children:[e.jsx(_a,{src:_.avatar||""}),e.jsx(gn,{className:"text-xs",children:_.name.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"font-medium text-sm",children:_.name}),e.jsxs(ct,{variant:"secondary",className:"text-xs",children:[_.deals.length," deals"]})]}),e.jsx("div",{className:"space-y-2 pl-8",children:_.deals.map(j=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:j.deal_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[j.contact_name&&e.jsx("span",{className:"text-xs text-muted-foreground",children:j.contact_name}),j.property_address&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",j.property_address]}),j.deal_type&&e.jsx(ct,{variant:"outline",className:"text-[10px] capitalize",children:j.deal_type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2 shrink-0",children:[j.sale_price&&e.jsxs("span",{className:"text-xs font-medium flex items-center gap-0.5 text-muted-foreground",children:[e.jsx(Ad,{className:"h-3 w-3"}),g(j.sale_price)]}),j.stage_name&&e.jsxs(ct,{variant:"outline",className:"text-[10px] whitespace-nowrap",style:{borderColor:j.stage_color||void 0,color:j.stage_color||void 0,backgroundColor:j.stage_color?`${j.stage_color}10`:void 0},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block mr-1",style:{backgroundColor:j.stage_color||void 0}}),j.stage_name]})]})]},j.id))})]},v))}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t",children:[h.length," deal",h.length!==1?"s":""," from ",f.length," team member",f.length!==1?"s":""]})]})})}function Tis({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:$t("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(Y,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(br,{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(hc,{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(po,{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:$t("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(_a,{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:$t("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(ln,{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:$t("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(_a,{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 KIe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Ais(){const{user:t}=Ys(),{data:s}=h_(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=zt({queryKey:["team-pipeline-members",n],queryFn:async()=>{const{data:o,error:l}=await Z.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t.id);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(f=>f.user_id),{data:d,error:h}=await Z.from("profiles").select("id, name, avatar_url").in("id",i);if(h)throw h;return(d||[]).map((f,g)=>({id:f.id,name:f.name||"Unknown",avatar_url:f.avatar_url,color:KIe[g%KIe.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function Eis(t){return zt({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await Z.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 OZe({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=T.useState(!1),l=t.find(d=>d.id===s),i=d=>{d.id!==s&&r(d.id,d.name),o(!1)};return e.jsxs(Hu,{open:a,onOpenChange:o,children:[e.jsx(Wu,{asChild:!0,children:e.jsxs(Y,{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(Ri,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(ju,{align:"end",className:"w-48 z-50 bg-popover",onClick:d=>d.stopPropagation(),children:t.map(d=>{const h=d.icon&&TOe[d.icon]||Td,f=d.id===s;return e.jsxs(Va,{onClick:()=>i(d),className:$t("flex items-center gap-2 cursor-pointer",f&&"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(h,{className:"h-3 w-3",style:{color:d.color}})}),e.jsx("span",{className:"flex-1",children:d.name}),f&&e.jsx(ma,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const Iis={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"}},Pis={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 RZe({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var S,E;const d=Q3(),h=Iis[t.deal_type],f=Pis[t.priority],g=T.useMemo(()=>t.target_close_date?bg(new Date(t.target_close_date),new Date):null,[t.target_close_date]),v=g!==null&&g<0,_=g!==null&&g<=7&&g>=0,j=T.useMemo(()=>{var B;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const D=((B=t.listing)==null?void 0:B.created_at)||t.listing_date;if(!D)return null;const L=t.contract_date?new Date(t.contract_date):new Date;return bg(L,new Date(D))},[t]),w=l&&!t.scorecard_transaction_id,k=!!t.scorecard_transaction_id,M=D=>D?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(D):null;return e.jsx(Oe,{className:$t("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",w&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs($e,{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(_a,{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(ct,{variant:"outline",className:$t("text-[10px] px-1.5 py-0 shrink-0",h.color),children:h.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:[(S=t.contact.first_name)==null?void 0:S[0],(E=t.contact.last_name)==null?void 0:E[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(Jm,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),w&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(vo,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),k&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(oi,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),j!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(wE,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:$t("font-medium",j>90?"text-red-600":j>60?"text-amber-600":"text-muted-foreground"),children:[j," 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(Zn,{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(Ad,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:M(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",M(t.expected_commission)," GCI"]})]}),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:$t("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",f.color),children:[e.jsx("div",{className:$t("w-1.5 h-1.5 rounded-full",f.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(OZe,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(D,L)=>a(t.id,D,L)}):t.target_close_date?e.jsxs("div",{className:$t("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(xn,{className:"h-3 w-3"}),e.jsx("span",{children:v?`${Math.abs(g)}d overdue`:_?`${g}d left`:Bs(new Date(t.target_close_date),"MMM d")})]}):null]})]})})}function Lis({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:h}){const f=T.useRef(null),g=s.reduce((w,k)=>w+(k.expected_price||0),0),v=s.reduce((w,k)=>w+(k.expected_commission||0),0),_=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,j=t.icon&&TOe[t.icon]||Td;return e.jsxs("div",{ref:f,className:$t("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(ct,{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",children:[e.jsx("span",{className:"font-medium text-foreground",children:_(g)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[_(v)," GCI"]})]})]}),e.jsx(po,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:k=>{k.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(RZe,{deal:w,onClick:()=>r(w),isWonStage:d,ownerInfo:(h==null?void 0:h(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(Y,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function Dis({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:hm,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Pipeline Value",value:r((t==null?void 0:t.pipelineValue)||0),icon:Sc,color:"text-purple-500",bgColor:"bg-purple-500/10"},{label:"Expected GCI",value:r((t==null?void 0:t.expectedCommission)||0),icon:Ad,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},{label:"Won Deals",value:(t==null?void 0:t.wonDeals)||0,icon:vo,color:"text-amber-500",bgColor:"bg-amber-500/10"}];return s?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[1,2,3,4].map(a=>e.jsx(Oe,{className:"animate-pulse",children:e.jsx($e,{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-4 gap-3",children:n.map(a=>e.jsx(Oe,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx($e,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:$t("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:$t("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 Ois(t){return zt({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await Z.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function swe(){const t=lo(),s=vs();return Wt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await Z.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 Ble(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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 Ris(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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 Fis(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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 zis(){const t=vs();return Wt({mutationFn:async({id:s,dealId:r})=>{await Z.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await Z.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 Bis(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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 $is(){const t=lo();return zt({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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 Uis(){const t=lo(),s=vs();return Wt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await Z.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 qis(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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 Vis(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function d5(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function His({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Ys(),[a,o]=T.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(Sn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(ct,{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(Dk,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(Ok,{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(Sn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(ct,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Gc,{className:$t("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(Rk,{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(je,{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(ln,{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(je,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(k1e,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:$t("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(Hre,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(zu,{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:$t("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(Hre,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pg,{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(Do,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(je,{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(Do,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(je,{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(je,{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(je,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(Be,{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(je,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(Be,{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(je,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(Be,{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(je,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(er,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"email",children:"Email"}),e.jsxs(Et,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const Wis=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],Gis=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function Kis({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Rle(),{data:o}=of(),{data:l}=U9e(),i=EZe(),d=IZe(),h=swe(),[f,g]=T.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[v,_]=T.useState(""),[j,w]=T.useState(!1),k=(l==null?void 0:l.filter($=>((r==null?void 0:r.listing_id)===$.id,!0)))||[],[M,S]=T.useState({deal_name:"",deal_type:"buyer",stage_id:"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});T.useEffect(()=>{var $,V,W;t&&(r?(S({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:(($=r.expected_price)==null?void 0:$.toString())||"",commission_percentage:((V=r.commission_percentage)==null?void 0:V.toString())||"3",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&&_(`${r.contact.first_name} ${r.contact.last_name}`)):(S({deal_name:"",deal_type:"buyer",stage_id:n||((W=a==null?void 0:a[0])==null?void 0:W.id)||"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),_(""),g({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 E=o==null?void 0:o.filter($=>{var W,G,J;const V=v.toLowerCase();return((W=$.first_name)==null?void 0:W.toLowerCase().includes(V))||((G=$.last_name)==null?void 0:G.toLowerCase().includes(V))||((J=$.email)==null?void 0:J.toLowerCase().includes(V))}).slice(0,5),D=()=>{const $=parseFloat(M.expected_price)||0,V=parseFloat(M.commission_percentage)||0;return $*(V/100)},L=async $=>{var V,W,G;if($.preventDefault(),!M.deal_name.trim()){be.error("Please enter a deal name");return}try{const J={deal_name:M.deal_name,deal_type:M.deal_type,stage_id:M.stage_id||null,contact_id:M.contact_id||null,listing_id:M.listing_id||null,property_address:M.property_address||null,city:M.city||null,state:M.state||null,zip_code:M.zip_code||null,expected_price:M.expected_price?parseFloat(M.expected_price):null,expected_commission:D()||null,commission_percentage:M.commission_percentage?parseFloat(M.commission_percentage):3,target_close_date:((V=M.target_close_date)==null?void 0:V.toISOString().split("T")[0])||null,contract_date:((W=M.contract_date)==null?void 0:W.toISOString().split("T")[0])||null,listing_date:((G=M.listing_date)==null?void 0:G.toISOString().split("T")[0])||null,priority:M.priority,probability:parseInt(M.probability)||50,notes:M.notes||null};if(r)await d.mutateAsync({id:r.id,...J}),be.success("Deal updated successfully");else{const ne=await i.mutateAsync(J);if(be.success("Deal created successfully"),f.portal_enabled&&(ne!=null&&ne.id))try{await h.mutateAsync({deal_id:ne.id,visibility:f.visibility,require_onboarding:f.require_onboarding,allow_spouse:f.allow_spouse,client_name:f.client_name||null,client_email:f.client_email||null,client_phone:f.client_phone||null,invite_method:f.invite_method}),be.success("Client portal created!")}catch{be.error("Deal created, but portal setup failed")}}s(!1)}catch{be.error("Failed to save deal")}},B=i.isPending||d.isPending;return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(en,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:L,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(je,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(Be,{id:"deal_name",value:M.deal_name,onChange:$=>S(V=>({...V,deal_name:$.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Deal Type"}),e.jsxs(er,{value:M.deal_type,onValueChange:$=>S(V=>({...V,deal_type:$})),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:Wis.map($=>e.jsx(Et,{value:$.value,children:$.label},$.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Stage"}),e.jsxs(er,{value:M.stage_id||"none",onValueChange:$=>S(V=>({...V,stage_id:$==="none"?"":$})),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select stage"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No Stage"}),a==null?void 0:a.map($=>e.jsx(Et,{value:$.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:$.color}}),$.name]})},$.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{value:v,onChange:$=>{_($.target.value),w(!0),$.target.value||S(V=>({...V,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),j&&v&&E&&E.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg max-h-48 overflow-y-auto",children:E.map($=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{S(V=>({...V,contact_id:$.id})),_(`${$.first_name} ${$.last_name}`),w(!1)},children:[e.jsx(Wo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[$.first_name," ",$.last_name]}),$.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:$.email})]},$.id))})]})]}),k.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{className:"flex items-center gap-2",children:[e.jsx(Jm,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(er,{value:M.listing_id||"none",onValueChange:$=>{const V=$==="none"?"":$,W=k.find(G=>G.id===V);S(W?G=>{var J;return{...G,listing_id:V,deal_type:"seller",property_address:W.property_address||G.property_address,city:W.city||G.city,state:W.state||G.state,expected_price:((J=W.price)==null?void 0:J.toString())||G.expected_price}}:G=>({...G,listing_id:V}))},children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"None"}),k.map($=>e.jsx(Et,{value:$.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:$.property_address||`${$.city}, ${$.state}`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",($.price/1e3).toFixed(0),"K"]})]})},$.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(je,{htmlFor:"property_address",children:"Address"}),e.jsx(Be,{id:"property_address",value:M.property_address,onChange:$=>S(V=>({...V,property_address:$.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"city",children:"City"}),e.jsx(Be,{id:"city",value:M.city,onChange:$=>S(V=>({...V,city:$.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"state",children:"State"}),e.jsx(Be,{id:"state",value:M.state,onChange:$=>S(V=>({...V,state:$.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(Be,{id:"zip_code",value:M.zip_code,onChange:$=>S(V=>({...V,zip_code:$.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(je,{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(Be,{id:"expected_price",type:"number",value:M.expected_price,onChange:$=>S(V=>({...V,expected_price:$.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(Be,{id:"commission_percentage",type:"number",step:"0.1",value:M.commission_percentage,onChange:$=>S(V=>({...V,commission_percentage:$.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(je,{children:"Expected GCI"}),e.jsx(Be,{value:D()?`$${D().toLocaleString()}`:"-",disabled:!0,className:"bg-muted"})]})]})]}),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(je,{children:"Target Close Date"}),e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("w-full justify-start text-left font-normal",!M.target_close_date&&"text-muted-foreground"),children:[e.jsx(xn,{className:"mr-2 h-4 w-4"}),M.target_close_date?Bs(M.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{mode:"single",selected:M.target_close_date,onSelect:$=>S(V=>({...V,target_close_date:$})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Contract Date"}),e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("w-full justify-start text-left font-normal",!M.contract_date&&"text-muted-foreground"),children:[e.jsx(xn,{className:"mr-2 h-4 w-4"}),M.contract_date?Bs(M.contract_date,"PPP"):"Pick a date"]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{mode:"single",selected:M.contract_date,onSelect:$=>S(V=>({...V,contract_date:$})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(M.deal_type==="seller"||M.deal_type==="dual")&&!M.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(je,{children:"Listing Date (for Days on Market)"}),e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("w-full justify-start text-left font-normal",!M.listing_date&&"text-muted-foreground"),children:[e.jsx(xn,{className:"mr-2 h-4 w-4"}),M.listing_date?Bs(M.listing_date,"PPP"):"Pick a date"]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{mode:"single",selected:M.listing_date,onSelect:$=>S(V=>({...V,listing_date:$})),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(je,{children:"Priority"}),e.jsxs(er,{value:M.priority,onValueChange:$=>S(V=>({...V,priority:$})),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:Gis.map($=>e.jsx(Et,{value:$.value,children:$.label},$.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(Be,{type:"number",min:"0",max:"100",value:M.probability,onChange:$=>S(V=>({...V,probability:$.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(je,{htmlFor:"notes",children:"Notes"}),e.jsx(Rr,{id:"notes",value:M.notes,onChange:$=>S(V=>({...V,notes:$.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(His,{formData:f,onChange:g}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{type:"submit",disabled:B,children:[B&&e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function Zis(t){return zt({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await Z.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Yis(){const t=lo(),s=vs();return Wt({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 Z.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:d}=await Z.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 Xis(){const t=vs();return Wt({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await Z.storage.from("deal-files").remove([r]);const{error:a}=await Z.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function Qis(){const t=vs();return Wt({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await Z.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 Jis(t){const{data:s,error:r}=await Z.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const ZIe={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function eos({open:t,onOpenChange:s}){const{data:r,isLoading:n}=$is(),a=Uis(),o=qis(),l=Vis(),[i,d]=T.useState(!1),[h,f]=T.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[g,v]=T.useState(""),_=async()=>{if(h.question_text.trim())try{await a.mutateAsync({question_text:h.question_text.trim(),field_type:h.field_type,options:h.field_type==="dropdown"?h.options:[],is_required:h.is_required,sort_order:((r==null?void 0:r.length)||0)+1}),f({question_text:"",field_type:"text",options:[],is_required:!1}),v(""),d(!1),be.success("Question added")}catch{be.error("Failed to add question")}},j=async S=>{try{await l.mutateAsync(S),be.success("Question removed")}catch{be.error("Failed to remove question")}},w=async(S,E)=>{try{await o.mutateAsync({id:S,is_required:E})}catch{be.error("Failed to update question")}},k=()=>{g.trim()&&(f(S=>({...S,options:[...S.options,g.trim()]})),v(""))},M=S=>{f(E=>({...E,options:E.options.filter((D,L)=>L!==S)}))};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{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(po,{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(Us,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(S=>{var E;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(lm,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:S.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(ct,{variant:"secondary",className:"text-xs",children:ZIe[S.field_type]||S.field_type}),S.is_required&&e.jsx(ct,{variant:"outline",className:"text-xs",children:"Required"})]}),S.field_type==="dropdown"&&((E=S.options)==null?void 0:E.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",S.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(ln,{checked:S.is_required,onCheckedChange:D=>w(S.id,D),className:"scale-75"}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>j(S.id),children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]})]})},S.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Question"}),e.jsx(Be,{value:h.question_text,onChange:S=>f(E=>({...E,question_text:S.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(ZIe).map(([S,E])=>e.jsx("button",{type:"button",onClick:()=>f(D=>({...D,field_type:S,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${h.field_type===S?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:E},S))})]}),h.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[h.options.map((S,E)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:S}),e.jsx("button",{onClick:()=>M(E),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Xr,{className:"h-3.5 w-3.5"})})]},E)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:g,onChange:S=>v(S.target.value),onKeyDown:S=>S.key==="Enter"&&(S.preventDefault(),k()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(Y,{variant:"outline",size:"sm",onClick:k,disabled:!g.trim(),className:"h-8",children:e.jsx(ar,{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(ln,{checked:h.is_required,onCheckedChange:S=>f(E=>({...E,is_required:S}))}),e.jsx(je,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>d(!1),className:"flex-1",children:"Cancel"}),e.jsxs(Y,{size:"sm",onClick:_,disabled:!h.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(Us,{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(Y,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function FZe({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=Ble(),[o,l]=T.useState(!1),[i,d]=T.useState(r.next_step_text||""),[h,f]=T.useState(r.next_step_video_url||""),[g,v]=T.useState(r.inspection_date||""),[_,j]=T.useState(r.appraisal_date||""),[w,k]=T.useState(r.welcome_message||""),[M,S]=T.useState(r.review_url||""),[E,D]=T.useState(r.show_post_close_tips),[L,B]=T.useState(r.require_onboarding),[$,V]=T.useState(r.allow_spouse),[W,G]=T.useState(r.visibility),[J,ne]=T.useState(r.stage_mapping||[]),{data:ie}=zt({queryKey:["pipeline-stages-for-portal",n],queryFn:async()=>{const{data:ge,error:Te}=await Z.from("deal_pipeline_stages").select("*").eq("owner_user_id",n).order("sort_order",{ascending:!0});if(Te)throw Te;return ge},enabled:t});T.useEffect(()=>{d(r.next_step_text||""),f(r.next_step_video_url||""),v(r.inspection_date||""),j(r.appraisal_date||""),k(r.welcome_message||""),S(r.review_url||""),D(r.show_post_close_tips),B(r.require_onboarding),V(r.allow_spouse),G(r.visibility),ne(r.stage_mapping||[])},[r]);const ee=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:i||null,next_step_video_url:h||null,inspection_date:g||null,appraisal_date:_||null,welcome_message:w||null,review_url:M||null,show_post_close_tips:E,require_onboarding:L,allow_spouse:$,visibility:W,stage_mapping:J.length>0?J:null}),be.success("Portal settings saved"),s(!1)}catch{be.error("Failed to save settings")}},de=()=>{ne([...J,{label:""}])},oe=ge=>{ne(J.filter((Te,ve)=>ve!==ge))},ue=(ge,Te)=>{const ve=[...J];ve[ge]={...ve[ge],label:Te},ne(ve)},ce=()=>{const Te=dBe(null).map(ve=>({label:ve.label,stageId:void 0}));ne(Te)};return e.jsxs(e.Fragment,{children:[e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Portal Settings"})}),e.jsxs(Qa,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Ga,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(Fs,{value:"general",children:"General"}),e.jsx(Fs,{value:"timeline",children:"Timeline"}),e.jsx(Fs,{value:"content",children:"Content"})]}),e.jsxs(po,{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(je,{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(ge=>e.jsx("button",{onClick:()=>G(ge),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${W===ge?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:ge.charAt(0).toUpperCase()+ge.slice(1)},ge))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{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(ln,{checked:L,onCheckedChange:B})]}),L&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(Y,{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(je,{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(ln,{checked:$,onCheckedChange:V})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{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(ln,{checked:E,onCheckedChange:D})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Inspection Date"}),e.jsx(Be,{type:"date",value:g,onChange:ge=>v(ge.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(Be,{type:"date",value:_,onChange:ge=>j(ge.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(je,{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(Y,{variant:"outline",size:"sm",onClick:ce,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. Internal pipeline stages (Lead, Consultation, etc.) are automatically translated to friendly names like "Getting Started" and "Planning Your Move."'}),J.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(Y,{variant:"outline",size:"sm",onClick:ce,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:J.map((ge,Te)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lm,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(Be,{value:ge.label,onChange:ve=>ue(Te,ve.target.value),placeholder:`Stage ${Te+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>oe(Te),children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]},Te))}),J.length>0&&e.jsxs(Y,{variant:"outline",size:"sm",onClick:de,className:"mt-2 text-xs w-full",children:[e.jsx(ar,{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(je,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:w,onChange:ge=>k(ge.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(je,{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:ge=>d(ge.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(je,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(Be,{value:h,onChange:ge=>f(ge.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(je,{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(Be,{value:M,onChange:ge=>S(ge.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(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{onClick:ee,disabled:a.isPending,children:[a.isPending?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(um,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})}),e.jsx(eos,{open:o,onOpenChange:l})]})}function zZe({open:t,onOpenChange:s,portalId:r}){const[n,a]=T.useState(""),[o,l]=T.useState(""),[i,d]=T.useState(""),[h,f]=T.useState(!1),g=Bis(),v=async()=>{if(n.trim())try{await g.mutateAsync({portal_id:r,title:n.trim(),content:o.trim()||void 0,video_url:i.trim()||void 0,is_stage_change:h}),be.success("Update posted to portal"),a(""),l(""),d(""),f(!1),s(!1)}catch{be.error("Failed to post update")}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Title *"}),e.jsx(Be,{value:n,onChange:_=>a(_.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:o,onChange:_=>l(_.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(je,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(Be,{value:i,onChange:_=>d(_.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(Wn,{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-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!h),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${h?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Mark as a milestone update"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{onClick:v,disabled:!n.trim()||g.isPending,children:[g.isPending?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})})}function BZe({open:t,onOpenChange:s,portal:r,dealName:n}){const a=Ble(),{isGmailConnected:o,gmailEmail:l}=MN(),[i,d]=T.useState(r.client_name||""),[h,f]=T.useState(r.client_email||""),[g,v]=T.useState(!1),[_,j]=T.useState(!1),w=d5(r.slug),k=i.split(" ")[0]||"there",M=`Your Transaction Portal – ${n}`,S=`Hi ${k}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${w} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,E=()=>{navigator.clipboard.writeText(w),j(!0),setTimeout(()=>j(!1),2e3),be.success("Portal link copied!")},D=async()=>{if(!h.trim()){be.error("Please enter the client email");return}v(!0);try{await a.mutateAsync({id:r.id,client_name:i||null,client_email:h||null,invite_sent_at:new Date().toISOString(),invite_method:"email"});const{error:B}=await Z.functions.invoke("gmail-send",{body:{to:h,subject:M,body:S.replace(/\n/g,"
")}});if(B)throw B;be.success(`Invite sent to ${h}`),s(!1)}catch(B){be.error(B.message||"Failed to send invite")}finally{v(!1)}},L=()=>{const B=encodeURIComponent(M),$=encodeURIComponent(S);window.open(`mailto:${h}?subject=${B}&body=${$}`,"_blank"),a.mutateAsync({id:r.id,client_name:i||null,client_email:h||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-md",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(Be,{value:i,onChange:B=>d(B.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(Be,{type:"email",value:h,onChange:B=>f(B.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-sm font-medium",children:"Portal Link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:w})}),e.jsx(Y,{variant:"outline",size:"icon",onClick:E,className:"shrink-0",children:_?e.jsx(ma,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Di,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(Y,{onClick:D,disabled:g||!h.trim(),className:"w-full",children:[g?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(Y,{onClick:L,disabled:!h.trim(),className:"w-full",variant:"outline",children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(Y,{variant:"ghost",onClick:E,className:"w-full text-muted-foreground",children:[e.jsx(Di,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function tos({deal:t}){const{isAdmin:s,user:r}=Ys(),{data:n,isLoading:a}=Ois(t.id),o=swe(),l=Ble(),[i,d]=T.useState(!1),[h,f]=T.useState(!1),[g,v]=T.useState(!1),[_,j]=T.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(Sn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Us,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var L,B;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:((B=t.contact)==null?void 0:B.phone)||void 0}),be.success("Client portal enabled!")}catch{be.error("Failed to create portal")}finally{d(!1)}},k=async L=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:L}),be.success(L?"Portal enabled":"Portal disabled")}catch{be.error("Failed to update portal")}},M=()=>{if(!n)return;const L=d5(n.slug);navigator.clipboard.writeText(L),be.success("Portal link copied!")},S=()=>{if(!n)return;const L=d5(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(Sn,{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(Y,{onClick:w,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const E=d5(n.slug),D=(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(Sn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(ct,{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(ln,{checked:n.is_enabled,onCheckedChange:k})]}),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(ct,{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:E})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(Y,{variant:"outline",size:"sm",onClick:M,className:"text-xs flex-1 min-w-0",children:[e.jsx(Di,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:S,className:"text-xs flex-1 min-w-0",children:[e.jsx(bn,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>j(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(Wa,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(B4,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>f(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(Ic,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(FZe,{open:h,onOpenChange:f,portal:n,dealOwnerId:D}),e.jsx(zZe,{open:g,onOpenChange:v,portalId:n.id}),e.jsx(BZe,{open:_,onOpenChange:j,portal:n,dealName:t.deal_name})]})}const sos={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"}},ros={note:Eo,call:Ha,email:zr,meeting:xn,stage_change:bn,task_completed:oi,document:Zn,system:ca};function nos({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var He,Ue;const{data:l,isLoading:i}=Jas((t==null?void 0:t.id)||""),{data:d,isLoading:h}=tis((t==null?void 0:t.id)||""),f=eis(),g=ris(),v=sis(),_=Qas(),{data:j,isLoading:w}=Zis((t==null?void 0:t.id)||""),k=Yis(),M=Xis(),S=Qis(),E=T.useRef(null),[D,L]=T.useState(""),[B,$]=T.useState(""),[V,W]=T.useState(!1),[G,J]=T.useState(!1);if(!t)return null;const ne=sos[t.deal_type],ie=(()=>{var wt;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const De=((wt=t.listing)==null?void 0:wt.created_at)||t.listing_date;if(!De)return null;const Ge=t.contract_date?new Date(t.contract_date):new Date;return bg(Ge,new Date(De))})(),ee=De=>De?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(De):"-",de=async()=>{if(D.trim())try{await f.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:D}),L(""),be.success("Note added")}catch{be.error("Failed to add note")}},oe=async()=>{if(B.trim())try{await g.mutateAsync({deal_id:t.id,title:B,sort_order:((d==null?void 0:d.length)||0)+1}),$(""),be.success("Task added")}catch{be.error("Failed to add task")}},ue=async(De,Ge)=>{try{await v.mutateAsync({id:De,is_completed:Ge,deal_id:t.id})}catch{be.error("Failed to update task")}},ce=async()=>{try{await _.mutateAsync(t.id),be.success("Deal deleted"),r(!1)}catch{be.error("Failed to delete deal")}},ge=(d==null?void 0:d.filter(De=>De.is_completed).length)||0,Te=(d==null?void 0:d.length)||0,ve=(j==null?void 0:j.length)||0,ye=De=>De<1024?`${De} B`:De<1024*1024?`${(De/1024).toFixed(1)} KB`:`${(De/(1024*1024)).toFixed(1)} MB`,Se=De=>De?De.startsWith("image/")?fl:De.includes("pdf")?Yn:A4:A4,Ke=async De=>{const Ge=De.target.files;if(!(!Ge||!t)){J(!0);try{for(const wt of Array.from(Ge)){if(wt.size>20*1024*1024){be.error(`${wt.name} exceeds 20MB limit`);continue}await k.mutateAsync({dealId:t.id,file:wt})}be.success("File(s) uploaded")}catch{be.error("Failed to upload file")}finally{J(!1),E.current&&(E.current.value="")}}},Ae=async(De,Ge)=>{if(t)try{await M.mutateAsync({fileId:De,storagePath:Ge,dealId:t.id}),be.success("File deleted")}catch{be.error("Failed to delete file")}},Ee=async(De,Ge)=>{try{const wt=await Jis(De),Ie=document.createElement("a");Ie.href=wt,Ie.download=Ge,Ie.target="_blank",document.body.appendChild(Ie),Ie.click(),document.body.removeChild(Ie)}catch{be.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(z6,{open:s,onOpenChange:r,children:e.jsxs(q3,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(B6,{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(ct,{variant:"outline",className:$t("text-xs",ne.color),children:ne.label}),e.jsxs(ct,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx($6,{className:"text-xl",children:t.deal_name})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(_c,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>W(!0),children:e.jsx(Ir,{className:"h-4 w-4"})})]})]})}),e.jsx(po,{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:[(He=t.contact.first_name)==null?void 0:He[0],(Ue=t.contact.last_name)==null?void 0:Ue[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(Y,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(Ha,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(Y,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(zr,{className:"h-4 w-4"})})})]})]}),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(Zn,{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:ee(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:ee(t.expected_commission)})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(Y,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(vo,{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(oi,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"Synced to Scorecard"})]}),ie!==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:$t("text-lg font-bold",ie>90?"text-red-600":ie>60?"text-amber-600":"text-foreground"),children:[ie," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(xn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",Bs(new Date(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ad,{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(tos,{deal:t}),e.jsxs(Qa,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(Ga,{className:"w-full grid grid-cols-3",children:[e.jsxs(Fs,{value:"tasks",className:"gap-1",children:[e.jsx(oi,{className:"h-4 w-4"}),"Tasks ",Te>0&&`(${ge}/${Te})`]}),e.jsxs(Fs,{value:"files",className:"gap-1",children:[e.jsx(Mk,{className:"h-4 w-4"}),"Files ",ve>0&&`(${ve})`]}),e.jsxs(Fs,{value:"activity",className:"gap-1",children:[e.jsx(ca,{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(Be,{placeholder:"Add a new task...",value:B,onChange:De=>$(De.target.value),onKeyDown:De=>De.key==="Enter"&&oe()}),e.jsx(Y,{onClick:oe,disabled:!B.trim(),children:e.jsx(ar,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(De=>e.jsxs("div",{className:$t("flex items-center gap-3 p-3 rounded-lg border transition-colors",De.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Do,{checked:De.is_completed,onCheckedChange:Ge=>ue(De.id,!!Ge)}),e.jsx("span",{className:$t("flex-1 text-sm",De.is_completed&&"line-through text-muted-foreground"),children:De.title}),De.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:Bs(new Date(De.due_date),"MMM d")})]},De.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:E,className:"hidden",multiple:!0,onChange:Ke,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(Y,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var De;return(De=E.current)==null?void 0:De.click()},disabled:G,children:[G?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ji,{className:"h-4 w-4 mr-2"}),G?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[j==null?void 0:j.map(De=>{const Ge=Se(De.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(Ge,{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:De.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ye(De.file_size)," · ",Bs(new Date(De.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(bN,{children:e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${De.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>S.mutate({fileId:De.id,visible:!De.visible_on_portal,dealId:t.id}),children:De.visible_on_portal?e.jsx(wi,{className:"h-4 w-4"}):e.jsx(Wp,{className:"h-4 w-4"})})}),e.jsx(fh,{side:"top",children:De.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ee(De.storage_path,De.file_name),children:e.jsx(Vi,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Ae(De.id,De.storage_path),children:e.jsx(Xr,{className:"h-4 w-4"})})]})]},De.id)}),(j==null?void 0:j.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(Rr,{placeholder:"Add a note...",value:D,onChange:De=>L(De.target.value),rows:2}),e.jsxs(Y,{onClick:de,disabled:!D.trim(),size:"sm",className:"w-full",children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(De=>{const Ge=ros[De.activity_type]||ca;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(Ge,{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:De.title}),De.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:De.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:_u(new Date(De.created_at),{addSuffix:!0})})]})]},De.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(Ec,{open:V,onOpenChange:W,children:e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Delete Deal?"}),e.jsxs(cc,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:ce,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function aos({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=coe(),o=IZe(),{data:l}=loe(),{data:i}=Ag(),[d,h]=T.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:Bs(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});T.useEffect(()=>{if(r&&t){const v=r.deal_type==="seller"?"seller":"buyer",_=r.expected_price||0,j=r.commission_percentage||3,w=r.expected_commission||_*j/100;h({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||Bs(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:w,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const f=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,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}),be.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(_){console.error("Error syncing to scorecard:",_),be.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(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{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(vo,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(Ps,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(en,{className:"text-center",children:"Review and confirm the details before adding this deal to your Scorecard."})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(Be,{id:"property_address",value:d.property_address,onChange:v=>h(_=>({..._,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(je,{htmlFor:"city",children:"City"}),e.jsx(Be,{id:"city",value:d.city,onChange:v=>h(_=>({..._,city:v.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"state",children:"State"}),e.jsx(Be,{id:"state",value:d.state,onChange:v=>h(_=>({..._,state:v.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"zip",children:"Zip"}),e.jsx(Be,{id:"zip",value:d.zip,onChange:v=>h(_=>({..._,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(je,{children:"Transaction Type *"}),e.jsxs(er,{value:d.transaction_type,onValueChange:v=>h(_=>({..._,transaction_type:v})),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"buyer",children:"Buyer"}),e.jsx(Et,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(je,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(Be,{id:"close_date",type:"date",value:d.close_date,onChange:v=>h(_=>({..._,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(je,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(Ad,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(Be,{id:"sale_price",type:"number",value:d.sale_price||"",onChange:v=>h(_=>({..._,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(je,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx($4,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(Be,{id:"commission_amount",type:"number",value:d.commission_amount||"",onChange:v=>h(_=>({..._,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(je,{children:"Lead Source"}),e.jsxs(er,{value:d.lead_source_id,onValueChange:v=>h(_=>({..._,lead_source_id:v})),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select source"})}),e.jsx(Js,{children:l==null?void 0:l.map(v=>e.jsx(Et,{value:v.id,children:v.name},v.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Client Type"}),e.jsxs(er,{value:d.client_type_id,onValueChange:v=>h(_=>({..._,client_type_id:v})),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select type"})}),e.jsx(Js,{children:i==null?void 0:i.map(v=>e.jsx(Et,{value:v.id,children:v.name},v.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"notes",children:"Notes"}),e.jsx(Rr,{id:"notes",value:d.notes,onChange:v=>h(_=>({..._,notes:v.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(Hn,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(Y,{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(qi,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const ios={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"}},YIe={urgent:0,high:1,medium:2,low:3};function oos({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=T.useState("target_close_date"),[l,i]=T.useState("asc"),d=_=>{a===_?i(j=>j==="asc"?"desc":"asc"):(o(_),i("asc"))},h=T.useMemo(()=>[...t].sort((_,j)=>{var k,M;let w=0;switch(a){case"deal_name":w=_.deal_name.localeCompare(j.deal_name);break;case"stage":{const S=((k=s.find(D=>D.id===_.stage_id))==null?void 0:k.sort_order)||0,E=((M=s.find(D=>D.id===j.stage_id))==null?void 0:M.sort_order)||0;w=S-E;break}case"expected_price":w=(_.expected_price||0)-(j.expected_price||0);break;case"expected_commission":w=(_.expected_commission||0)-(j.expected_commission||0);break;case"target_close_date":{const S=_.target_close_date?new Date(_.target_close_date).getTime():1/0,E=j.target_close_date?new Date(j.target_close_date).getTime():1/0;w=S-E;break}case"priority":w=YIe[_.priority]-YIe[j.priority];break}return l==="asc"?w:-w}),[t,s,a,l]),f=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):"—",g=_=>_?s.find(j=>j.id===_):null,v=({field:_,children:j})=>e.jsxs(Y,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>d(_),children:[j,a===_?l==="asc"?e.jsx(Wm,{className:"ml-2 h-4 w-4"}):e.jsx(jx,{className:"ml-2 h-4 w-4"}):e.jsx(Hp,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{className:"bg-muted/50",children:[e.jsx(Ct,{className:"w-[250px]",children:e.jsx(v,{field:"deal_name",children:"Deal Name"})}),e.jsx(Ct,{className:"w-[150px]",children:e.jsx(v,{field:"stage",children:"Stage"})}),e.jsx(Ct,{className:"w-[100px]",children:"Type"}),e.jsx(Ct,{className:"w-[120px]",children:e.jsx(v,{field:"expected_price",children:"Price"})}),e.jsx(Ct,{className:"w-[120px]",children:e.jsx(v,{field:"expected_commission",children:"GCI"})}),e.jsx(Ct,{className:"w-[130px]",children:e.jsx(v,{field:"target_close_date",children:"Close Date"})}),e.jsx(Ct,{className:"w-[100px]",children:e.jsx(v,{field:"priority",children:"Priority"})})]})}),e.jsx(Bn,{children:h.map(_=>{g(_.stage_id);const j=ios[_.deal_type],w=_.target_close_date?bg(new Date(_.target_close_date),new Date):null,k=w!==null&&w<0,M=w!==null&&w<=7&&w>=0;return e.jsxs(ws,{className:$t("cursor-pointer hover:bg-muted/50 transition-colors",k&&"bg-red-50/50"),onClick:()=>r(_),children:[e.jsx(ot,{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(ot,{onClick:S=>S.stopPropagation(),children:e.jsx(OZe,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(S,E)=>n(_.id,S,E)})}),e.jsx(ot,{children:e.jsx(ct,{variant:"outline",className:$t("text-xs",j.color),children:j.label})}),e.jsx(ot,{children:e.jsx("span",{className:"font-medium",children:f(_.expected_price)})}),e.jsx(ot,{children:e.jsx("span",{className:"text-emerald-600",children:f(_.expected_commission)})}),e.jsx(ot,{children:_.target_close_date?e.jsxs("div",{className:$t("flex items-center gap-1 text-sm",k&&"text-red-600",M&&!k&&"text-amber-600"),children:[k&&e.jsx(Qo,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:Bs(new Date(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ot,{children:e.jsx(ct,{variant:"outline",className:$t("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 los(){const t=lo();return zt({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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 cos(t){const s=lo();return zt({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await Z.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 dos(){const t=lo(),s=vs();return Wt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await Z.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 uos(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function hos(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function rwe(){const t=vs();return Wt({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await Z.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 mos(){const t=vs();return Wt({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await Z.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 pos(t){const s=lo();return zt({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=Z.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 fos(){const t=lo(),s=vs();return Wt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await Z.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 gos(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function xos(){const t=lo(),s=vs();return Wt({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await Z.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 Z.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:h,error:f}=await Z.from("deal_tasks").insert(d).select();if(f)throw f;return h},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const yos={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function vos({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:d,isLoading:h}=cos(t?r:void 0),f=mos(),g=xos(),[v,_]=T.useState(new Set),[j,w]=T.useState(!1),k=(d||[]).filter(D=>D.status!=="done");T.useEffect(()=>{k.length>0&&_(new Set(k.map(D=>D.id)))},[d]);const M=D=>{_(L=>{const B=new Set(L);return B.has(D)?B.delete(D):B.add(D),B})},S=async()=>{w(!0);try{const D=Array.from(v);D.length>0&&await f.mutateAsync(D),await i(),await g.mutateAsync({dealId:r,stageId:l}),s(!1)}catch{}finally{w(!1)}},E=async()=>{w(!0);try{await i(),await g.mutateAsync({dealId:r,stageId:l}),s(!1)}catch{}finally{w(!1)}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[480px]",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Move Deal"}),e.jsxs(en,{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(ct,{variant:"outline",className:"text-sm",children:a}),e.jsx(qi,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ct,{className:"text-sm bg-primary",children:o})]}),h?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):k.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:k.length})," incomplete task",k.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(po,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:k.map(D=>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(Do,{checked:v.has(D.id),onCheckedChange:()=>M(D.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[yos[D.priority]," ",D.title]}),D.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:D.stage.color+"20",color:D.stage.color},children:D.stage.name})]},D.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>{v.size===k.length?_(new Set):_(new Set(k.map(D=>D.id)))},children:v.size===k.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{variant:"outline",size:"sm",onClick:E,disabled:j,children:"Skip"}),e.jsxs(Y,{size:"sm",onClick:S,disabled:j,children:[j&&e.jsx(Us,{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(oi,{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(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(Y,{onClick:S,disabled:j,children:[j&&e.jsx(Us,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function _os(){const t=lo();return zt({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function bos({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=swe(),h=Ble(),f=Ris(),g=Fis(),[v,_]=T.useState(!1),j=!!(n!=null&&n.archived_at),w=async()=>{_(!0);try{await d.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),be.success("Portal enabled!")}catch{be.error("Failed to create portal")}finally{_(!1)}},k=async L=>{if(n)try{await h.mutateAsync({id:n.id,is_enabled:L}),be.success(L?"Portal enabled":"Portal disabled")}catch{be.error("Failed to update portal")}},M=()=>{n&&(navigator.clipboard.writeText(d5(n.slug)),be.success("Link copied!"))},S=()=>{n&&window.open(d5(n.slug),"_blank")},E=async()=>{if(n)try{await f.mutateAsync(n.id),be.success("Portal archived")}catch{be.error("Failed to archive portal")}},D=async()=>{if(n)try{await g.mutateAsync(n.id),be.success("Portal restored")}catch{be.error("Failed to restore portal")}};return n?j?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(ct,{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(Y,{variant:"ghost",size:"sm",onClick:D,className:"text-xs gap-1",children:[e.jsx(vE,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(Ir,{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(ct,{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(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M,title:"Copy link",children:e.jsx(Di,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,title:"Preview",children:e.jsx(bn,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx(Wa,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n.id),title:"Post update",children:e.jsx(B4,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx(Ic,{className:"h-3.5 w-3.5"})}),e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Rp,{className:"h-3.5 w-3.5"})})}),e.jsx(ju,{align:"end",children:e.jsxs(Va,{onClick:E,children:[e.jsx(N4,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(ln,{checked:n.is_enabled,onCheckedChange:k,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(Y,{size:"sm",onClick:w,disabled:v,className:"shrink-0 ml-4",children:[v?e.jsx(Us,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(Sn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function wos(){const{data:t,isLoading:s}=Fle(),{data:r,isLoading:n}=_os(),[a,o]=T.useState(""),[l,i]=T.useState("all"),d=zis(),[h,f]=T.useState(null),[g,v]=T.useState(null),[_,j]=T.useState(null),[w,k]=T.useState(null),M=lo(),S=s||n,E=new Map;r==null||r.forEach(G=>E.set(G.deal_id,G));const L=[...(t||[]).filter(G=>{var de,oe,ue,ce,ge;const J=E.get(G.id),ne=a.toLowerCase(),ie=!ne||G.deal_name.toLowerCase().includes(ne)||((oe=(de=G.contact)==null?void 0:de.first_name)==null?void 0:oe.toLowerCase().includes(ne))||((ce=(ue=G.contact)==null?void 0:ue.last_name)==null?void 0:ce.toLowerCase().includes(ne))||((ge=J==null?void 0:J.client_name)==null?void 0:ge.toLowerCase().includes(ne));let ee=!0;return l==="active"?ee=!!(J!=null&&J.is_enabled)&&!(J!=null&&J.archived_at):l==="disabled"?ee=!!J&&!J.is_enabled&&!J.archived_at:l==="archived"?ee=!!(J!=null&&J.archived_at):l==="none"?ee=!J:l==="all"&&(ee=!(J!=null&&J.archived_at)||!J),ie&&ee})].sort((G,J)=>{const ne=E.get(G.id),ie=E.get(J.id);if(ne!=null&&ne.archived_at&&!(ie!=null&&ie.archived_at))return 1;if(!(ne!=null&&ne.archived_at)&&(ie!=null&&ie.archived_at)||ne&&!ie)return-1;if(!ne&&ie)return 1;if(ne&&ie){if(ne.is_enabled&&!ie.is_enabled)return-1;if(!ne.is_enabled&&ie.is_enabled)return 1}return 0}),B=(r==null?void 0:r.filter(G=>!G.archived_at).length)||0,$=(r==null?void 0:r.filter(G=>G.is_enabled&&!G.archived_at).length)||0,V=(r==null?void 0:r.filter(G=>G.archived_at).length)||0,W=async()=>{if(w)try{await d.mutateAsync({id:w.id,dealId:w.deal_id}),be.success("Portal permanently deleted"),k(null)}catch{be.error("Failed to delete portal")}};return S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(Us,{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(Sn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[B," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[$," active · ",B-$," disabled",V>0&&` · ${V} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search deals or clients...",value:a,onChange:G=>o(G.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(Xr,{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(G=>e.jsx(Y,{variant:l===G?"secondary":"ghost",size:"sm",onClick:()=>i(G),className:"text-xs px-3 capitalize",children:G==="none"?"No Portal":G},G))})]}),e.jsx(po,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(G=>{const J=E.get(G.id)||null,ne=G.contact?`${G.contact.first_name||""} ${G.contact.last_name||""}`.trim():"";return e.jsx(bos,{dealId:G.id,dealName:G.deal_name,contactName:ne,portal:J,onSettingsOpen:f,onComposerOpen:v,onInviteOpen:(ie,ee)=>j({portal:ie,dealName:ee}),onDeleteConfirm:k},G.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(Sn,{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"})]})]})})]}),h&&e.jsx(FZe,{open:!!h,onOpenChange:G=>!G&&f(null),portal:h,dealOwnerId:M||""}),g&&e.jsx(zZe,{open:!!g,onOpenChange:G=>!G&&v(null),portalId:g}),_&&e.jsx(BZe,{open:!!_,onOpenChange:G=>!G&&j(null),portal:_.portal,dealName:_.dealName}),e.jsx(Ec,{open:!!w,onOpenChange:G=>!G&&k(null),children:e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Permanently delete this portal?"}),e.jsx(cc,{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(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:W,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class jos extends T.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(Vs,{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 kos(){var Kt;const t=Q3(),{data:s,isLoading:r}=Rle(),{data:n,isLoading:a,refetch:o}=Fle(),{data:l,isLoading:i}=nis(),d=AZe(),h=Xas(),[f,g]=T.useState("board"),[v,_]=T.useState(!1),[j,w]=T.useState(!1),[k,M]=T.useState(null),[S,E]=T.useState(null),[D,L]=T.useState(null),[B,$]=T.useState(null),[V,W]=T.useState(!1),[G,J]=T.useState(null),[ne,ie]=T.useState(""),[ee,de]=T.useState("all"),[oe,ue]=T.useState(!1),[ce,ge]=T.useState(!1),[Te,ve]=T.useState(new Set),[ye,Se]=T.useState(null),{data:Ke}=h_(),{isTeamLeader:Ae,teamMembers:Ee}=Ais(),He=T.useMemo(()=>Array.from(Te),[Te]),{data:Ue}=Eis(He),De=T.useMemo(()=>{const Xt=new Map;return Ee.forEach(ss=>Xt.set(ss.id,{name:ss.name,avatar_url:ss.avatar_url,color:ss.color})),Xt},[Ee]),Ge=T.useCallback(Xt=>Xt.owner_user_id&&De.get(Xt.owner_user_id)||null,[De]),wt=T.useCallback(Xt=>{ve(ss=>{const fs=new Set(ss);return fs.has(Xt)?fs.delete(Xt):fs.add(Xt),fs})},[]);T.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[Ie,st]=Oc(),he=T.useRef(!1);T.useEffect(()=>{const Xt=Ie.get("deal");if(Xt&&n&&n.length>0&&!he.current){const ss=n.find(fs=>fs.id===Xt);ss&&(he.current=!0,M(ss),w(!0),Ie.delete("deal"),st(Ie,{replace:!0}))}},[n,Ie]);const We=T.useMemo(()=>{if(!Ue||!s)return[];const Xt=new Map(s.map(ss=>[ss.name,ss.id]));return Ue.map(ss=>{const fs=ss._stage_name&&Xt.get(ss._stage_name)||null;return{...ss,stage_id:fs||ss.stage_id}})},[Ue,s]),et=T.useMemo(()=>[...n||[],...We],[n,We]),Ye=et.filter(Xt=>{var yt,bs,gr,Br,na,za;const ss=ne.toLowerCase(),fs=!ss||Xt.deal_name.toLowerCase().includes(ss)||((bs=(yt=Xt.contact)==null?void 0:yt.first_name)==null?void 0:bs.toLowerCase().includes(ss))||((Br=(gr=Xt.contact)==null?void 0:gr.last_name)==null?void 0:Br.toLowerCase().includes(ss))||((na=Xt.property_address)==null?void 0:na.toLowerCase().includes(ss))||((za=Xt.city)==null?void 0:za.toLowerCase().includes(ss)),fr=ee==="all"||Xt.deal_type===ee;return fs&&fr}),ke=T.useMemo(()=>{if(!s)return l||null;const Xt=new Set(s.filter(yt=>yt.is_won_stage).map(yt=>yt.id)),ss=new Set(s.filter(yt=>yt.is_lost_stage).map(yt=>yt.id)),fs=et.filter(yt=>!Xt.has(yt.stage_id)&&!ss.has(yt.stage_id)),fr=et.filter(yt=>Xt.has(yt.stage_id));return{totalDeals:et.length,activeDeals:fs.length,wonDeals:fr.length,pipelineValue:fs.reduce((yt,bs)=>yt+(bs.expected_price||0),0),expectedCommission:fs.reduce((yt,bs)=>yt+(bs.expected_commission||0),0),wonValue:fr.reduce((yt,bs)=>yt+(bs.expected_price||0),0)}},[et,s,l]),at=Xt=>{M(Xt),w(!0)},Fe=Xt=>{E(Xt||null),M(null),_(!0)},it=Xt=>{M(Xt),w(!1),_(!0)},dt=(Xt,ss)=>{L(Xt)},tt=(Xt,ss)=>{Xt.preventDefault(),Xt.dataTransfer.dropEffect="move",$(ss)},ut=async(Xt,ss)=>{if(Xt.preventDefault(),$(null),!D)return;const fs=n==null?void 0:n.find(bs=>bs.id===D),fr=s==null?void 0:s.find(bs=>bs.id===ss),yt=s==null?void 0:s.find(bs=>bs.id===(fs==null?void 0:fs.stage_id));if(!fs||!fr||fs.stage_id===ss){L(null);return}Se({dealId:D,dealName:fs.deal_name,fromStageName:(yt==null?void 0:yt.name)||"Unknown",toStageName:fr.name,toStageId:ss,isWonStage:fr.is_won_stage,deal:fs}),L(null)},xt=async()=>{if(!ye)return;const{dealId:Xt,toStageId:ss,toStageName:fs,isWonStage:fr,deal:yt}=ye;if(await h.mutateAsync({dealId:Xt,stageId:ss,stageName:fs}),be.success(`Moved to ${fs}`),fr&&!yt.scorecard_transaction_id){const bs={...yt,stage_id:ss};J(bs),W(!0)}},_t=T.useCallback(async(Xt,ss,fs)=>{const fr=n==null?void 0:n.find(gr=>gr.id===Xt),yt=s==null?void 0:s.find(gr=>gr.id===ss),bs=s==null?void 0:s.find(gr=>gr.id===(fr==null?void 0:fr.stage_id));!fr||!yt||fr.stage_id===ss||Se({dealId:Xt,dealName:fr.deal_name,fromStageName:(bs==null?void 0:bs.name)||"Unknown",toStageName:fs,toStageId:ss,isWonStage:yt.is_won_stage,deal:fr})},[n,s]),qe=Xt=>Ye.filter(ss=>ss.stage_id===Xt),Lt=r||a,Rt=t?"list":f;return e.jsxs(Vs,{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(Y,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(el,{className:"h-4 w-4"})}),!t&&e.jsx(bN,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:e.jsxs(Y,{variant:f==="board"?"secondary":"ghost",size:"sm",onClick:()=>g("board"),className:"px-3 gap-1.5",children:[e.jsx(Qm,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(fh,{children:"Kanban board view"})]}),e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:e.jsxs(Y,{variant:f==="list"?"secondary":"ghost",size:"sm",onClick:()=>g("list"),className:"px-3 gap-1.5",children:[e.jsx(dm,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(fh,{children:"Grouped list view"})]}),e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:e.jsxs(Y,{variant:f==="table"?"secondary":"ghost",size:"sm",onClick:()=>g("table"),className:"px-3 gap-1.5",children:[e.jsx(V4,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(fh,{children:"Sortable table view"})]}),e.jsxs(em,{children:[e.jsx(tm,{asChild:!0,children:e.jsxs(Y,{variant:f==="portals"?"secondary":"ghost",size:"sm",onClick:()=>g("portals"),className:"px-3 gap-1.5",children:[e.jsx(Sn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(fh,{children:"Client portal management"})]})]})}),Ke&&!Ae&&e.jsxs(Y,{variant:"outline",onClick:()=>ue(!0),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(Y,{onClick:()=>Fe(),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Rt!=="portals"&&e.jsx(Dis,{stats:ke,isLoading:i}),Rt!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search deals, contacts, addresses...",value:ne,onChange:Xt=>ie(Xt.target.value),className:"pl-9 pr-8"}),ne&&e.jsx("button",{onClick:()=>ie(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Xr,{className:"h-4 w-4"})})]}),e.jsxs(er,{value:ee,onValueChange:de,children:[e.jsx(Qs,{className:"w-[140px]",children:e.jsx(tr,{placeholder:"All Types"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Types"}),e.jsx(Et,{value:"buyer",children:"Buyer"}),e.jsx(Et,{value:"seller",children:"Seller"}),e.jsx(Et,{value:"dual",children:"Dual"}),e.jsx(Et,{value:"referral",children:"Referral"}),e.jsx(Et,{value:"lease",children:"Lease"})]})]}),(ne||ee!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Ye.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[Ae&&!t&&Ee.length>0&&e.jsx(Tis,{members:Ee,enabledMembers:Te,onToggleMember:wt,isOpen:ce,onToggleOpen:()=>ge(Xt=>!Xt)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Lt?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Xt=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(ys,{className:"h-full rounded-xl"})},Xt))}):Rt==="board"?e.jsxs(po,{className:"h-full -mx-4 md:-mx-6 px-4 md:px-6",children:[e.jsx("div",{className:"flex gap-4 h-full pb-4",children:s==null?void 0:s.map(Xt=>e.jsx(Lis,{stage:Xt,deals:qe(Xt.id),onDealClick:at,onAddDeal:Fe,onDragStart:dt,onDragOver:tt,onDrop:ut,isDragOver:B===Xt.id,isWonStage:Xt.is_won_stage,getOwnerInfo:Ge},Xt.id))}),e.jsx(Zie,{orientation:"horizontal"})]}):Rt==="table"?e.jsx(po,{className:"h-full",children:e.jsx(oos,{deals:Ye,stages:s||[],onDealClick:at,onStageChange:_t})}):Rt==="portals"?e.jsx(wos,{}):e.jsx(po,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Xt=>{const ss=qe(Xt.id);return ss.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Xt.color}}),e.jsx("h3",{className:"font-semibold",children:Xt.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",ss.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:ss.map(fs=>e.jsx(RZe,{deal:fs,onClick:()=>at(fs),stages:s,onStageChange:_t,showStagePicker:!0,isWonStage:Xt.is_won_stage,ownerInfo:Ge(fs)},fs.id))})]},Xt.id)}),(n==null?void 0:n.length)===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(Qm,{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(Y,{onClick:()=>Fe(),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&Ye.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(On,{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(Y,{variant:"outline",onClick:()=>{ie(""),de("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(Kis,{open:v,onOpenChange:_,deal:k,defaultStageId:S}),e.jsx(nos,{deal:k,open:j,onOpenChange:w,onEdit:it,isWonStage:k?(Kt=s==null?void 0:s.find(Xt=>Xt.id===k.stage_id))==null?void 0:Kt.is_won_stage:!1,onAddToScorecard:Xt=>{J(Xt),W(!0),w(!1)}}),e.jsx(aos,{open:V,onOpenChange:W,deal:G,onComplete:()=>{o(),J(null)}}),ye&&e.jsx(vos,{open:!!ye,onOpenChange:Xt=>{Xt||Se(null)},dealId:ye.dealId,dealName:ye.dealName,fromStageName:ye.fromStageName,toStageName:ye.toStageName,toStageId:ye.toStageId,onConfirm:xt}),e.jsx(Mis,{open:oe,onOpenChange:ue})]})}function Nos(){return e.jsx(jos,{children:e.jsx(kos,{})})}function $Ze({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var ie;const o=dos(),l=uos(),{data:i}=Fle(),d=lo(),{data:h}=zt({queryKey:["contacts-for-tasks",d],queryFn:async()=>{if(!d)return[];const{data:ee,error:de}=await Z.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",d).order("first_name").limit(500);if(de)throw de;return ee},enabled:!!d&&t}),[f,g]=T.useState(""),[v,_]=T.useState(""),[j,w]=T.useState("none"),[k,M]=T.useState("none"),[S,E]=T.useState("medium"),[D,L]=T.useState("todo"),[B,$]=T.useState(),[V,W]=T.useState(!1),[G,J]=T.useState(!1);T.useEffect(()=>{r?(g(r.title),_(r.description||""),w(r.deal_id||"none"),M(r.contact_id||"none"),E(r.priority),L(r.status),$(r.due_date?ph(r.due_date):void 0)):(g(""),_(""),w(n||"none"),M("none"),E("medium"),L("todo"),$(void 0))},[r,t,n]);const ne=async()=>{if(!f.trim()){be.error("Task title is required");return}try{const ee={title:f.trim(),description:v.trim()||null,deal_id:j==="none"?null:j,contact_id:k==="none"?null:k,stage_id:a||null,priority:S,status:D,due_date:B?Bs(B,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...ee}),be.success("Task updated")):(await o.mutateAsync(ee),be.success("Task created")),s(!1)}catch{be.error("Failed to save task")}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[480px]",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Title *"}),e.jsx(Be,{value:f,onChange:ee=>g(ee.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Description"}),e.jsx(Rr,{value:v,onChange:ee=>_(ee.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Priority"}),e.jsxs(er,{value:S,onValueChange:ee=>E(ee),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"low",children:"🟢 Low"}),e.jsx(Et,{value:"medium",children:"🟡 Medium"}),e.jsx(Et,{value:"high",children:"🟠 High"}),e.jsx(Et,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Status"}),e.jsxs(er,{value:D,onValueChange:ee=>L(ee),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"todo",children:"To Do"}),e.jsx(Et,{value:"in_progress",children:"In Progress"}),e.jsx(Et,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Due Date"}),e.jsxs(_l,{children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",className:$t("w-full justify-start text-left font-normal",!B&&"text-muted-foreground"),children:[e.jsx(xn,{className:"mr-2 h-4 w-4"}),B?Bs(B,"PPP"):"Pick a date"]})}),e.jsx(nl,{className:"w-auto p-0",align:"start",children:e.jsx(Qp,{mode:"single",selected:B,onSelect:$,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Link to Deal"}),e.jsxs(_l,{open:V,onOpenChange:W,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{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(Ya,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),j!=="none"?((ie=i==null?void 0:i.find(ee=>ee.id===j))==null?void 0:ie.deal_name)||"Select deal":"No Deal"]}),e.jsx(mg,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(nl,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wg,{children:[e.jsx(jg,{placeholder:"Search deals..."}),e.jsxs(kg,{children:[e.jsx(Ng,{children:"No deals found."}),e.jsxs(Sg,{children:[e.jsxs(Vm,{value:"no-deal",onSelect:()=>{w("none"),W(!1)},children:[e.jsx(ma,{className:$t("mr-2 h-4 w-4",j==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(ee=>e.jsxs(Vm,{value:ee.deal_name,onSelect:()=>{w(ee.id),W(!1)},children:[e.jsx(ma,{className:$t("mr-2 h-4 w-4",j===ee.id?"opacity-100":"opacity-0")}),ee.deal_name]},ee.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Link to Contact"}),e.jsxs(_l,{open:G,onOpenChange:J,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{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(Wo,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),k!=="none"?(()=>{const ee=h==null?void 0:h.find(de=>de.id===k);return ee?`${ee.first_name} ${ee.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(mg,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(nl,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wg,{children:[e.jsx(jg,{placeholder:"Search contacts..."}),e.jsxs(kg,{children:[e.jsx(Ng,{children:"No contacts found."}),e.jsxs(Sg,{children:[e.jsxs(Vm,{value:"no-contact",onSelect:()=>{M("none"),J(!1)},children:[e.jsx(ma,{className:$t("mr-2 h-4 w-4",k==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),h==null?void 0:h.map(ee=>e.jsxs(Vm,{value:`${ee.first_name} ${ee.last_name}`,onSelect:()=>{M(ee.id),J(!1)},children:[e.jsx(ma,{className:$t("mr-2 h-4 w-4",k===ee.id?"opacity-100":"opacity-0")}),ee.first_name," ",ee.last_name]},ee.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Y,{onClick:ne,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const Sos={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 Cos({tasks:t}){const s=rwe(),r=hos(),n=Yr(),[a,o]=T.useState(null),l=async f=>{const g=f.status==="done"?"todo":"done";try{await s.mutateAsync({id:f.id,status:g})}catch{be.error("Failed to update task")}},i=async f=>{try{await r.mutateAsync(f),be.success("Task deleted")}catch{be.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(oi,{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,h=[];return t.forEach(f=>{if(f.deal){const g=d.get(f.deal.id)||{dealName:f.deal.deal_name,tasks:[]};g.tasks.push(f),d.set(f.deal.id,g)}else h.push(f)}),e.jsxs("div",{className:"space-y-4",children:[h.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"})}),h.map(f=>e.jsx(XIe,{task:f,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:g=>n(`/mission-control/pipeline?deal=${g}`)},f.id))]}),Array.from(d.entries()).map(([f,g])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${f}`),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(Ya,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:g.dealName}),e.jsxs(ct,{variant:"secondary",className:"ml-auto text-xs",children:[g.tasks.filter(v=>v.status==="done").length,"/",g.tasks.length]}),e.jsx(Ri,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),g.tasks.map(v=>e.jsx(XIe,{task:v,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},v.id))]},f)),a&&e.jsx($Ze,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function XIe({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&Ix(ph(t.due_date))&&!Sd(ph(t.due_date)),i=!o&&t.due_date&&Sd(ph(t.due_date)),d=Sos[t.priority];return e.jsxs("div",{className:$t("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(oi,{className:"h-5 w-5 text-emerald-500"}):e.jsx(Td,{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:$t("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(Wo,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(ct,{variant:"outline",className:$t("text-[10px] shrink-0",d.color),children:[d.dot," ",d.label]}),t.due_date&&e.jsxs("span",{className:$t("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(ca,{className:"h-3 w-3"}),Bs(ph(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(_c,{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(Ir,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const Mos=[{status:"todo",label:"To Do",icon:Td,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:Om,color:"border-t-blue-500"},{status:"done",label:"Done",icon:oi,color:"border-t-emerald-500"}],Tos={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Aos({tasks:t}){const s=rwe(),r=T.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(h=>h.id===i);if(!(!d||d.status===l))try{await s.mutateAsync({id:i,status:l})}catch{be.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:Mos.map(o=>e.jsxs("div",{className:$t("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(ct,{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(Eos,{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 Eos({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&Ix(ph(t.due_date))&&!Sd(ph(t.due_date)),a=!r&&t.due_date&&Sd(ph(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:$t("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:Tos[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:$t("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(Ya,{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(Wo,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:$t("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(ca,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",Bs(ph(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 QIe={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Ios({tasks:t}){const[s,r]=T.useState(new Date),n=rwe(),a=Nh(s),o=F6(s),l=Uu(a),i=qie(o),d=Fxt({start:l,end:i}),h=T.useMemo(()=>{const v=new Map;return t.forEach(_=>{if(!_.due_date)return;const j=_.due_date,w=v.get(j)||[];w.push(_),v.set(j,w)}),v},[t]),f=T.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{be.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(Y,{variant:"ghost",size:"icon",onClick:()=>r(nBe(s,1)),children:e.jsx(hc,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:Bs(s,"MMMM yyyy")}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>r(Ch(s,1)),children:e.jsx(Ri,{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 _=Bs(v,"yyyy-MM-dd"),j=h.get(_)||[],w=Wie(v,s),k=Sd(v);return e.jsxs("div",{className:$t("border-r border-b min-h-[100px] p-1",!w&&"bg-muted/30",k&&"bg-primary/5"),children:[e.jsx("div",{className:$t("text-xs font-medium mb-1 text-right px-1",!w&&"text-muted-foreground/40",k&&"text-primary font-bold"),children:Bs(v,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[j.slice(0,3).map(M=>e.jsxs("button",{onClick:()=>g(M),className:$t("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",M.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[M.status==="done"?e.jsx(oi,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(Td,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[QIe[M.priority]," ",M.title]})]},M.id)),j.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",j.length-3," more"]})]})]},_)})}),f.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 (",f.length,")"]}),e.jsx("div",{className:"space-y-1",children:f.map(v=>e.jsxs("button",{onClick:()=>g(v),className:$t("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(oi,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(Td,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[QIe[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 Pos={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Los({open:t,onOpenChange:s,stages:r}){var M;const[n,a]=T.useState(((M=r[0])==null?void 0:M.id)||""),{data:o,isLoading:l}=pos(n||void 0),i=fos(),d=gos(),[h,f]=T.useState(""),[g,v]=T.useState("medium"),[_,j]=T.useState(""),w=async()=>{if(!(!h.trim()||!n))try{await i.mutateAsync({stage_id:n,title:h.trim(),priority:g,default_due_offset_days:_?parseInt(_):null,sort_order:((o==null?void 0:o.length)||0)+1}),f(""),j(""),be.success("Template added")}catch{be.error("Failed to add template")}},k=async S=>{try{await d.mutateAsync(S),be.success("Template deleted")}catch{be.error("Failed to delete template")}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-[560px]",children:[e.jsx(Ls,{children:e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(kE,{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(je,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(S=>!S.is_won_stage&&!S.is_lost_stage).map(S=>e.jsx("button",{onClick:()=>a(S.id),className:$t("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===S.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:S.name},S.id))})]}),e.jsx(po,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((S,E)=>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:Pos[S.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:S.title}),S.default_due_offset_days&&e.jsxs(ct,{variant:"outline",className:"text-[10px]",children:["+",S.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>k(S.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(Ir,{className:"h-3.5 w-3.5 text-destructive"})})]},S.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(je,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{placeholder:"Task title...",value:h,onChange:S=>f(S.target.value),className:"flex-1",onKeyDown:S=>S.key==="Enter"&&w()}),e.jsxs(er,{value:g,onValueChange:S=>v(S),children:[e.jsx(Qs,{className:"w-[100px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"low",children:"🟢 Low"}),e.jsx(Et,{value:"medium",children:"🟡 Med"}),e.jsx(Et,{value:"high",children:"🟠 High"}),e.jsx(Et,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(je,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(Be,{type:"number",placeholder:"e.g., 7",value:_,onChange:S=>j(S.target.value)})]}),e.jsxs(Y,{onClick:w,disabled:!h.trim()||i.isPending,children:[e.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function Dos(){const{data:t,isLoading:s}=los(),{data:r}=Rle(),[n,a]=T.useState("list"),[o,l]=T.useState(""),[i,d]=T.useState("active"),[h,f]=T.useState("all"),[g,v]=T.useState("all"),[_,j]=T.useState(!1),[w,k]=T.useState(!1),M=T.useMemo(()=>{if(!t)return[];const D=new Map;return t.forEach(L=>{L.deal&&D.set(L.deal.id,L.deal.deal_name)}),Array.from(D,([L,B])=>({id:L,name:B}))},[t]),S=T.useMemo(()=>t?t.filter(D=>{var G,J,ne,ie;const L=o.toLowerCase(),B=!L||D.title.toLowerCase().includes(L)||((J=(G=D.deal)==null?void 0:G.deal_name)==null?void 0:J.toLowerCase().includes(L))||`${((ne=D.contact)==null?void 0:ne.first_name)||""} ${((ie=D.contact)==null?void 0:ie.last_name)||""}`.toLowerCase().includes(L),$=i==="all"||i==="active"&&D.status!=="done"||i==="todo"&&D.status==="todo"||i==="in_progress"&&D.status==="in_progress"||i==="done"&&D.status==="done"||i==="overdue"&&D.status!=="done"&&D.due_date&&Ix(ph(D.due_date))&&!Sd(ph(D.due_date)),V=h==="all"||D.priority===h,W=g==="all"||g==="no_deal"&&!D.deal_id||D.deal_id===g;return B&&$&&V&&W}):[],[t,o,i,h,g]),E=T.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const D=t.filter(L=>L.status!=="done");return{total:D.length,overdue:D.filter(L=>L.due_date&&Ix(ph(L.due_date))&&!Sd(ph(L.due_date))).length,dueToday:D.filter(L=>L.due_date&&Sd(ph(L.due_date))).length,dueThisWeek:D.filter(L=>L.due_date&&L0t(ph(L.due_date))).length,completed:t.filter(L=>L.status==="done").length}},[t]);return e.jsx(Vs,{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(Y,{variant:"outline",size:"sm",onClick:()=>k(!0),children:[e.jsx(Jy,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(Y,{size:"sm",onClick:()=>j(!0),children:[e.jsx(ar,{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(dm,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:E.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(Lu,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:E.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(ca,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:E.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(Km,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:E.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(oi,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:E.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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search tasks...",value:o,onChange:D=>l(D.target.value),className:"pl-9"})]}),e.jsxs(er,{value:h,onValueChange:f,children:[e.jsx(Qs,{className:"w-[130px]",children:e.jsx(tr,{placeholder:"Priority"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Priorities"}),e.jsx(Et,{value:"urgent",children:"🔴 Urgent"}),e.jsx(Et,{value:"high",children:"🟠 High"}),e.jsx(Et,{value:"medium",children:"🟡 Medium"}),e.jsx(Et,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(er,{value:g,onValueChange:v,children:[e.jsx(Qs,{className:"w-[160px]",children:e.jsx(tr,{placeholder:"Deal"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Deals"}),e.jsx(Et,{value:"no_deal",children:"No Deal"}),M.map(D=>e.jsx(Et,{value:D.id,children:D.name},D.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(dm,{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(Sx,{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(Km,{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(Cos,{tasks:S}),n==="kanban"&&e.jsx(Aos,{tasks:S}),n==="calendar"&&e.jsx(Ios,{tasks:S})]}),e.jsx($Ze,{open:_,onOpenChange:j}),e.jsx(Los,{open:w,onOpenChange:k,stages:r||[]})]})})}const wye=[{value:"video_intro",label:"Video Intro",icon:Wn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:LE,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Kp,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:Jm,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:Kc,description:"Links to your social profiles"}],Oos=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],Ros={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function UZe({cardId:t}){const{data:s,isLoading:r}=Ugt(t),n=qgt(),a=Vgt(),o=Hgt(),[l,i]=T.useState(!1),[d,h]=T.useState(""),[f,g]=T.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ys,{className:"h-16 w-full"}),e.jsx(ys,{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:Ros[d]||{}},{onSuccess:()=>{i(!1),h("")}})},_=S=>{a.mutate({id:S.id,is_visible:!S.is_visible})},j=(S,E)=>{if(!s)return;const D=s.findIndex($=>$.id===S.id),L=E==="up"?D-1:D+1;if(L<0||L>=s.length)return;const B=s[L];a.mutate({id:S.id,sort_order:B.sort_order}),a.mutate({id:B.id,sort_order:S.sort_order})},w=S=>{confirm("Remove this block from this card?")&&o.mutate(S.id)},k=(S,E)=>{a.mutate({id:S.id,config:E},{onSuccess:()=>g(null)})},M=S=>wye.find(E=>E.value===S);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(Y,{size:"sm",onClick:()=>i(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((S,E)=>{const D=M(S.block_type),L=(D==null?void 0:D.icon)||Kp;return e.jsx(Oe,{className:S.is_visible?"":"opacity-50",children:e.jsx($e,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lm,{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:(D==null?void 0:D.label)||S.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Fos(S)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>j(S,"up"),disabled:E===0,children:e.jsx(Wm,{className:"h-3 w-3"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>j(S,"down"),disabled:E===s.length-1,children:e.jsx(jx,{className:"h-3 w-3"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S),children:S.is_visible?e.jsx(wi,{className:"h-3 w-3"}):e.jsx(Wp,{className:"h-3 w-3"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>g(S),children:"Edit"}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>w(S),children:e.jsx(Ir,{className:"h-3 w-3"})})]})]})})},S.id)}),e.jsxs(Y,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(js,{open:l,onOpenChange:i,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:wye.map(S=>{const E=S.icon;return e.jsxs("button",{onClick:()=>h(S.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${d===S.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(E,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:S.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.description})]})]},S.value)})}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(Y,{onClick:v,disabled:!d||n.isPending,children:"Add Block"})]})]})}),f&&e.jsx(zos,{block:f,onSave:S=>k(f,S),onClose:()=>g(null)})]})}function Fos(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 zos({block:t,onSave:s,onClose:r}){const[n,a]=T.useState(t.config),o=wye.find(l=>l.value===t.block_type);return e.jsx(js,{open:!0,onOpenChange:r,children:e.jsxs(_s,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(Bos,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx($os,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(Uos,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(qos,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(Vos,{config:n,onChange:a}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(Y,{onClick:()=>s(n),children:"Save"})]})]})})}function Bos({config:t,onChange:s,cardId:r}){var _,j;const[n,a]=T.useState(""),[o,l]=T.useState((_=t.video_url)!=null&&_.includes("youtube")||(j=t.video_url)!=null&&j.includes("youtu.be")?"youtube":"library"),{data:i}=zt({queryKey:["card-owner",r],queryFn:async()=>{const{data:w}=await Z.from("agent_cards").select("user_id").eq("id",r).single();return w==null?void 0:w.user_id},enabled:!!r}),{data:d,isLoading:h}=zt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:w,error:k}=await Z.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(k)throw k;return w||[]},enabled:!!i}),f=(d==null?void 0:d.filter(w=>!n||(w.title||"").toLowerCase().includes(n.toLowerCase())))||[],g=t.bunny_video_id,v=w=>{var E;const k=(E=w.playback_url)==null?void 0:E.match(/\/(?:play|embed)\/(\d+)\//),S=`https://iframe.mediadelivery.net/embed/${k?k[1]:"570924"}/${w.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:S,bunny_video_id:w.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(Qa,{value:o,onValueChange:l,children:[e.jsxs(Ga,{className:"w-full",children:[e.jsx(Fs,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(Fs,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search videos...",value:n,onChange:w=>a(w.target.value),className:"pl-9"})]}),e.jsx(po,{className:"h-[240px]",children:h?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ys,{className:"h-14 w-full"}),e.jsx(ys,{className:"h-14 w-full"})]}):f.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:f.map(w=>e.jsxs("button",{onClick:()=>v(w),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${g===w.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:k=>{var M;k.currentTarget.style.display="none",(M=k.currentTarget.nextElementSibling)==null||M.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${w.thumbnail_url?"hidden":""}`,children:e.jsx(Wn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:w.title||"Untitled Video"}),g===w.bunny_video_id&&e.jsx(ma,{className:"h-4 w-4 text-primary flex-shrink-0"})]},w.id))})})]}),e.jsx(Zs,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(je,{children:"YouTube URL"}),e.jsx(Be,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:w=>s({...t,video_url:w.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function $os({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,d)=>{const h=[...r];h[l]={...h[l],[i]:d},s({...t,testimonials:h})},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(Oe,{children:e.jsxs($e,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(je,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),r.length>1&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(Ir,{className:"h-3 w-3"})})]}),e.jsx(Be,{placeholder:"Client name",value:l.name,onChange:d=>n(i,"name",d.target.value)}),e.jsx(Be,{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(Y,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(ar,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function Uos({config:t,onChange:s}){const r=t.tags||[],[n,a]=T.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(je,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Oos.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(je,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(Y,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(je,{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 qos({config:t,onChange:s}){const r=t.links||[],n=(l,i,d)=>{const h=[...r];h[l]={...h[l],[i]:d},s({...t,links:h})},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(Be,{placeholder:"Button label",value:l.label,onChange:d=>n(i,"label",d.target.value)}),e.jsx(Be,{placeholder:"https://...",value:l.url,onChange:d=>n(i,"url",d.target.value)})]}),r.length>1&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(Ir,{className:"h-3 w-3"})})]},i)),e.jsxs(Y,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(ar,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const JIe=[{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 Vos({config:t,onChange:s}){const r=t.platforms||[],n=d=>{r.find(h=>h.platform===d)||s({...t,platforms:[...r,{platform:d,url:""}]})},a=(d,h)=>{const f=[...r];f[d]={...f[d],url:h},s({...t,platforms:f})},o=d=>{s({...t,platforms:r.filter((h,f)=>f!==d)})},l=JIe.filter(d=>!r.find(h=>h.platform===d.value)),i=d=>{const h=Ofe[d],f=JIe.find(g=>g.value===d);return{label:(f==null?void 0:f.label)||d,color:(h==null?void 0:h.color)||"#666",iconPath:h==null?void 0:h.icon}};return e.jsxs("div",{className:"space-y-4",children:[r.length>0&&e.jsx("div",{className:"space-y-3",children:r.map((d,h)=>{const f=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:f.color+"30",backgroundColor:f.color+"10"},children:f.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:f.color,children:e.jsx("path",{d:f.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(Be,{placeholder:`Your ${f.label} profile URL`,value:d.url,onChange:g=>a(h,g.target.value)})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(h),children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]},h)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(je,{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 h=Ofe[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:[(h==null?void 0:h.icon)&&e.jsx("svg",{viewBox:"0 0 24 24",width:12,height:12,fill:h.color,children:e.jsx("path",{d:h.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 Hos=Object.defineProperty,$ae=Object.getOwnPropertySymbols,qZe=Object.prototype.hasOwnProperty,VZe=Object.prototype.propertyIsEnumerable,ePe=(t,s,r)=>s in t?Hos(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,jye=(t,s)=>{for(var r in s||(s={}))qZe.call(s,r)&&ePe(t,r,s[r]);if($ae)for(var r of $ae(s))VZe.call(s,r)&&ePe(t,r,s[r]);return t},kye=(t,s)=>{var r={};for(var n in t)qZe.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&$ae)for(var n of $ae(t))s.indexOf(n)<0&&VZe.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var yN;(t=>{const s=class Ji{constructor(d,h,f,g){if(this.version=d,this.errorCorrectionLevel=h,this.modules=[],this.isFunction=[],dJi.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 j=0;j7)throw new RangeError("Invalid value");let j,w;for(j=f;;j++){const E=Ji.getNumDataCodewords(j,h)*8,D=l.getTotalBits(d,j);if(D<=E){w=D;break}if(j>=g)throw new RangeError("Data too long")}for(const E of[Ji.Ecc.MEDIUM,Ji.Ecc.QUARTILE,Ji.Ecc.HIGH])_&&w<=Ji.getNumDataCodewords(j,E)*8&&(h=E);let k=[];for(const E of d){r(E.mode.modeBits,4,k),r(E.numChars,E.mode.numCharCountBits(j),k);for(const D of E.getData())k.push(D)}a(k.length==w);const M=Ji.getNumDataCodewords(j,h)*8;a(k.length<=M),r(0,Math.min(4,M-k.length),k),r(0,(8-k.length%8)%8,k),a(k.length%8==0);for(let E=236;k.lengthS[D>>>3]|=E<<7-(D&7)),new Ji(j,h,S,v)}getModule(d,h){return 0<=d&&d>>9)*1335;const g=(h<<10|f)^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 f=0;f<12;f++)d=d<<1^(d>>>11)*7973;const h=this.version<<12|d;a(h>>>18==0);for(let f=0;f<18;f++){const g=n(h,f),v=this.size-11+f%3,_=Math.floor(f/3);this.setFunctionModule(v,_,g),this.setFunctionModule(_,v,g)}}drawFinderPattern(d,h){for(let f=-4;f<=4;f++)for(let g=-4;g<=4;g++){const v=Math.max(Math.abs(g),Math.abs(f)),_=d+g,j=h+f;0<=_&&_{(E!=w-v||L>=j)&&S.push(D[E])});return a(S.length==_),S}drawCodewords(d){if(d.length!=Math.floor(Ji.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let h=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let g=0;g>>3],7-(h&7)),h++)}}a(h==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let h=0;h5&&d++):(this.finderPenaltyAddHistory(j,w),_||(d+=this.finderPenaltyCountPatterns(w)*Ji.PENALTY_N3),_=this.modules[v][k],j=1);d+=this.finderPenaltyTerminateAndCount(_,j,w)*Ji.PENALTY_N3}for(let v=0;v5&&d++):(this.finderPenaltyAddHistory(j,w),_||(d+=this.finderPenaltyCountPatterns(w)*Ji.PENALTY_N3),_=this.modules[k][v],j=1);d+=this.finderPenaltyTerminateAndCount(_,j,w)*Ji.PENALTY_N3}for(let v=0;v_+(j?1:0),h);const f=this.size*this.size,g=Math.ceil(Math.abs(h*20-f*10)/f)-1;return a(0<=g&&g<=9),d+=g*Ji.PENALTY_N4,a(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,h=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let f=[6];for(let g=this.size-7;f.lengthJi.MAX_VERSION)throw new RangeError("Version number out of range");let h=(16*d+128)*d+64;if(d>=2){const f=Math.floor(d/7)+2;h-=(25*f-10)*f-55,d>=7&&(h-=36)}return a(208<=h&&h<=29648),h}static getNumDataCodewords(d,h){return Math.floor(Ji.getNumRawDataModules(d)/8)-Ji.ECC_CODEWORDS_PER_BLOCK[h.ordinal][d]*Ji.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let h=[];for(let g=0;g0);for(const g of d){const v=g^f.shift();f.push(0),h.forEach((_,j)=>f[j]^=Ji.reedSolomonMultiply(_,v))}return f}static reedSolomonMultiply(d,h){if(d>>>8||h>>>8)throw new RangeError("Byte out of range");let f=0;for(let g=7;g>=0;g--)f=f<<1^(f>>>7)*285,f^=(h>>>g&1)*d;return a(f>>>8==0),f}finderPenaltyCountPatterns(d){const h=d[1];a(h<=this.size*3);const f=h>0&&d[2]==h&&d[3]==h*3&&d[4]==h&&d[5]==h;return(f&&d[0]>=h*4&&d[6]>=h?1:0)+(f&&d[6]>=h*4&&d[0]>=h?1:0)}finderPenaltyTerminateAndCount(d,h,f){return d&&(this.finderPenaltyAddHistory(h,f),h=0),h+=this.size,this.finderPenaltyAddHistory(h,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(d,h){h[0]==0&&(d+=this.size),h.pop(),h.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,h){if(d<0||d>31||i>>>d)throw new RangeError("Value out of range");for(let f=d-1;f>=0;f--)h.push(i>>>f&1)}function n(i,d){return(i>>>d&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class yc{constructor(d,h,f){if(this.mode=d,this.numChars=h,this.bitData=f,h<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(d){let h=[];for(const f of d)r(f,8,h);return new yc(yc.Mode.BYTE,d.length,h)}static makeNumeric(d){if(!yc.isNumeric(d))throw new RangeError("String contains non-numeric characters");let h=[];for(let f=0;f=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={}))})(yN||(yN={}));(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={}))})(yN||(yN={}));var d4=yN;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var Wos={L:d4.QrCode.Ecc.LOW,M:d4.QrCode.Ecc.MEDIUM,Q:d4.QrCode.Ecc.QUARTILE,H:d4.QrCode.Ecc.HIGH},HZe=128,WZe="L",GZe="#FFFFFF",KZe="#000000",ZZe=!1,YZe=1,Gos=4,Kos=0,Zos=.1;function XZe(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 QZe(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 Yos(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*Zos),l=a/s,i=(n.width||o)*l,d=(n.height||o)*l,h=n.x==null?t.length/2-i/2:n.x*l,f=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 j=Math.floor(h),w=Math.floor(f),k=Math.ceil(i+h-j),M=Math.ceil(d+f-w);v={x:j,y:w,w:k,h:M}}const _=n.crossOrigin;return{x:h,y:f,h:d,w:i,excavation:v,opacity:g,crossOrigin:_}}function Xos(t,s){return s!=null?Math.max(Math.floor(s),0):t?Gos:Kos}function JZe({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let d=lt.useMemo(()=>{const j=(Array.isArray(t)?t:[t]).reduce((w,k)=>(w.push(...d4.QrSegment.makeSegments(k)),w),[]);return d4.QrCode.encodeSegments(j,Wos[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:h,margin:f,numCells:g,calculatedImageSettings:v}=lt.useMemo(()=>{let _=d.getModules();const j=Xos(n,a),w=_.length+j*2,k=Yos(_,l,j,o);return{cells:_,margin:j,numCells:w,calculatedImageSettings:k}},[d,l,o,n,a]);return{qrcode:d,margin:f,cells:h,numCells:g,calculatedImageSettings:v}}var Qos=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Jos=lt.forwardRef(function(s,r){const n=s,{value:a,size:o=HZe,level:l=WZe,bgColor:i=GZe,fgColor:d=KZe,includeMargin:h=ZZe,minVersion:f=YZe,boostLevel:g,marginSize:v,imageSettings:_}=n,w=kye(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:k}=w,M=kye(w,["style"]),S=_==null?void 0:_.src,E=lt.useRef(null),D=lt.useRef(null),L=lt.useCallback(ee=>{E.current=ee,typeof r=="function"?r(ee):r&&(r.current=ee)},[r]),[B,$]=lt.useState(!1),{margin:V,cells:W,numCells:G,calculatedImageSettings:J}=JZe({value:a,level:l,minVersion:f,boostLevel:g,includeMargin:h,marginSize:v,imageSettings:_,size:o});lt.useEffect(()=>{if(E.current!=null){const ee=E.current,de=ee.getContext("2d");if(!de)return;let oe=W;const ue=D.current,ce=J!=null&&ue!==null&&ue.complete&&ue.naturalHeight!==0&&ue.naturalWidth!==0;ce&&J.excavation!=null&&(oe=QZe(W,J.excavation));const ge=window.devicePixelRatio||1;ee.height=ee.width=o*ge;const Te=o/G*ge;de.scale(Te,Te),de.fillStyle=i,de.fillRect(0,0,G,G),de.fillStyle=d,Qos?de.fill(new Path2D(XZe(oe,V))):W.forEach(function(ve,ye){ve.forEach(function(Se,Ke){Se&&de.fillRect(Ke+V,ye+V,1,1)})}),J&&(de.globalAlpha=J.opacity),ce&&de.drawImage(ue,J.x+V,J.y+V,J.w,J.h)}}),lt.useEffect(()=>{$(!1)},[S]);const ne=jye({height:o,width:o},k);let ie=null;return S!=null&&(ie=lt.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{$(!0)},ref:D,crossOrigin:J==null?void 0:J.crossOrigin})),lt.createElement(lt.Fragment,null,lt.createElement("canvas",jye({style:ne,height:o,width:o,ref:L,role:"img"},M)),ie)});Jos.displayName="QRCodeCanvas";var nwe=lt.forwardRef(function(s,r){const n=s,{value:a,size:o=HZe,level:l=WZe,bgColor:i=GZe,fgColor:d=KZe,includeMargin:h=ZZe,minVersion:f=YZe,boostLevel:g,title:v,marginSize:_,imageSettings:j}=n,w=kye(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:k,cells:M,numCells:S,calculatedImageSettings:E}=JZe({value:a,level:l,minVersion:f,boostLevel:g,includeMargin:h,marginSize:_,imageSettings:j,size:o});let D=M,L=null;j!=null&&E!=null&&(E.excavation!=null&&(D=QZe(M,E.excavation)),L=lt.createElement("image",{href:j.src,height:E.h,width:E.w,x:E.x+k,y:E.y+k,preserveAspectRatio:"none",opacity:E.opacity,crossOrigin:E.crossOrigin}));const B=XZe(D,k);return lt.createElement("svg",jye({height:o,width:o,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},w),!!v&<.createElement("title",null,v),lt.createElement("path",{fill:i,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),lt.createElement("path",{fill:d,d:B,shapeRendering:"crispEdges"}),L)});nwe.displayName="QRCodeSVG";function els({slug:t,agentName:s}){const r=T.useRef(null),n=`https://cards.relevelup.com/${t}`,a=T.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 h=new XMLSerializer().serializeToString(o),f=new Image;f.onload=()=>{d.fillStyle="#ffffff",d.fillRect(0,0,i,i),d.drawImage(f,0,0,i,i);const v=document.createElement("a");v.download=`${t}-qr-code.png`,v.href=l.toDataURL("image/png"),v.click(),be.success("QR code downloaded!")},f.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(h)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{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(nwe,{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(Y,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(Vi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function jme(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 tls(){const{user:t}=Ys(),{data:s,isLoading:r}=zgt(t==null?void 0:t.id),n=Q3(),[a,o]=T.useState(null),l=T.useMemo(()=>a||(s?jme(s):null),[a,s]);if(r)return e.jsx(Vs,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-32 w-full"}),e.jsx(ys,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Vs,{children:e.jsx(rls,{userId:t==null?void 0:t.id})});const i=l||jme(s),d=h=>{o(f=>{const g=f||jme(s);return typeof h=="function"?h(g):h})};return e.jsx(Vs,{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(nls,{card:s}),e.jsx(lls,{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(Ck,{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(sls,{card:s,form:i})})]})})]})})}function sls({card:t,form:s}){const{data:r}=zt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await Z.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 Z.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=Z.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=T.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(Kve,{card:n})})}function rls({userId:t}){var d;const[s,r]=T.useState(""),n=T7e(),{data:a}=zt({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:h}=await Z.from("profiles").select("name").eq("id",t).single();return h},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 h=(s.trim()||o).toLowerCase().replace(/[^a-z0-9-]/g,"-");if(!h){be.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:h,is_published:!0},{onSuccess:()=>be.success("Your digital card has been created!")})},i=[{icon:pg,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Ax,title:"Lead Capture",desc:"Collect leads automatically"},{icon:Bu,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:hd,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(Sn,{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(h=>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(h.icon,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:h.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h.desc})]})]},h.title))}),e.jsxs(Oe,{className:"shadow-lg border-2",children:[e.jsxs(Ht,{className:"text-center pb-2",children:[e.jsx(Gt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(Tr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs($e,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(je,{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(Be,{value:s||o,onChange:h=>r(h.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(Y,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function nls({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),be.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(ct,{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(pg,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",t.slug]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Y,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(Di,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(Y,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(bn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function als({userId:t}){const s=vs(),r=T.useRef(null),[n,a]=T.useState(!1),[o,l]=T.useState(""),{data:i,isLoading:d}=zt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:J}=await Z.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let ne=(J==null?void 0:J.avatar_url)||null;if(!ne){const{data:ie}=await Z.storage.from("avatars").list(`${t}`);if(ie&&ie.length>0){const{data:ee}=Z.storage.from("avatars").getPublicUrl(`${t}/${ie[0].name}`);ne=`${ee.publicUrl}?t=${Date.now()}`,await Z.from("profiles").update({avatar_url:ne}).eq("id",t)}}return{...J,avatar_url:ne}}}),[h,f]=T.useState(null),[g,v]=T.useState(null),[_,j]=T.useState(null),[w,k]=T.useState(!1),M=h??(i==null?void 0:i.name)??"",S=g??(i==null?void 0:i.phone)??"",E=_??(i==null?void 0:i.email)??"",D=i==null?void 0:i.avatar_url,L=((i==null?void 0:i.name)||"A").split(" ").map(J=>J[0]).join("").toUpperCase().slice(0,2),B=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),$=Wt({mutationFn:async J=>{const{error:ne}=await Z.from("profiles").update(J).eq("id",t);if(ne)throw ne},onSuccess:()=>{s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),be.success("Profile updated!")},onError:()=>be.error("Failed to update profile")}),V=()=>{const J={};if(h!==null&&h!==(i==null?void 0:i.name)&&(J.name=h),g!==null&&g!==(i==null?void 0:i.phone)&&(J.phone=g||null),_!==null&&_!==(i==null?void 0:i.email)&&(J.email=_),Object.keys(J).length===0){be.info("No changes to save");return}$.mutate(J)},W=J=>{var ee;const ne=(ee=J.target.files)==null?void 0:ee[0];if(!ne)return;if(!ne.type.startsWith("image/")){be.error("Please select an image file");return}const ie=new FileReader;ie.onloadend=()=>{l(ie.result),a(!0)},ie.readAsDataURL(ne),J.target.value=""},G=async J=>{k(!0);try{const{data:ne}=await Z.storage.from("avatars").list(`${t}`);ne&&ne.length>0&&await Z.storage.from("avatars").remove(ne.map(ue=>`${t}/${ue.name}`));const ie=`${t}/avatar.jpg`,{error:ee}=await Z.storage.from("avatars").upload(ie,J,{upsert:!0,contentType:"image/jpeg"});if(ee)throw ee;const{data:de}=Z.storage.from("avatars").getPublicUrl(ie),oe=de.publicUrl+"?t="+Date.now();await Z.from("profiles").update({avatar_url:oe}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),be.success("Photo updated!")}catch{be.error("Failed to upload photo")}finally{k(!1)}};return d?e.jsx(ys,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:B?"border-amber-300 dark:border-amber-700":"",children:e.jsxs($e,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(je,{className:"text-sm font-semibold",children:"Profile Info"}),B&&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 J;return(J=r.current)==null?void 0:J.click()},children:[e.jsxs(fn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(_a,{src:D||void 0,alt:M}),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(hg,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:W})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:w?"Uploading...":D?"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(je,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(Be,{value:M,onChange:J=>f(J.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(je,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(Be,{value:S,onChange:J=>v(J.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(Be,{value:E,onChange:J=>j(J.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(Y,{variant:"outline",size:"sm",onClick:V,disabled:$.isPending,className:"w-full",children:$.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(b_e,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:G,aspectRatio:1})]})}function ils({form:t,setForm:s,userId:r}){const[n,a]=T.useState(null),[o,l]=T.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=T.useState(t.team_logo_url?"logo":"name"),h=_=>{l(_),s(_==="name"?j=>({...j,brokerage_logo_url:""}):j=>({...j,brokerage_display_name:""}))},f=_=>{d(_),s(_==="name"?j=>({...j,team_logo_url:""}):j=>({...j,team_name:""}))},g=async(_,j)=>{var k;const w=(k=_.target.files)==null?void 0:k[0];if(w){if(!w.type.startsWith("image/")){be.error("Please select an image file");return}a(j);try{const M=w.name.split(".").pop()||"png",E=`${r}/${j==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${M}`,{error:D}=await Z.storage.from("card-logos").upload(E,w,{upsert:!0});if(D)throw D;const{data:L}=Z.storage.from("card-logos").getPublicUrl(E),B=L.publicUrl+"?t="+Date.now();s(j==="brokerage_logo_url"?$=>({...$,[j]:B,brokerage_display_name:""}):$=>({...$,[j]:B,team_name:""})),be.success("Logo uploaded!")}catch{be.error("Failed to upload logo")}finally{a(null),_.target.value=""}}},v=_=>{s(j=>({...j,[_]:""}))};return e.jsx(Oe,{children:e.jsxs($e,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(je,{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(je,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>h("name"),children:"Use Name"}),e.jsx(Y,{type:"button",variant:o==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>h("logo"),children:"Use Logo"})]}),o==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(Be,{value:t.brokerage_display_name,onChange:_=>s(j=>({...j,brokerage_display_name:_.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{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(hg,{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(je,{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(og,{value:[t.brokerage_logo_size||56],onValueChange:([_])=>s(j=>({...j,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(je,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>f("name"),children:"Use Name"}),e.jsx(Y,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>f("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(Be,{value:t.team_name,onChange:_=>s(j=>({...j,team_name:_.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{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(hg,{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(je,{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(og,{value:[t.team_logo_size||56],onValueChange:([_])=>s(j=>({...j,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function ols({form:t,setForm:s}){const r={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=t.bold_theme_colors||r,a=(i,d)=>{s(h=>({...h,bold_theme_colors:{...r,...h.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(je,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(hd,{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(Y,{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:h})=>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:f=>a(i,f.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:h})]}),e.jsx(Be,{value:n[i],onChange:f=>{const g=f.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 lls({card:t,form:s,setForm:r}){var w;const n=A7e(),a=vs(),{data:o}=E7e(t.id),[l,i]=T.useState(t.slug),[d,h]=T.useState(!1),[f,g]=T.useState("idle"),v=T.useRef(JSON.stringify(s)),_=T.useRef(null);T.useEffect(()=>{const k=JSON.stringify(s);if(k!==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=k,g("saved"),setTimeout(()=>g("idle"),2e3)},onError:()=>g("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[s]);const j=async()=>{const k=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!k){be.error("Please enter a valid URL");return}if(k===t.slug){be.info("No changes to save");return}h(!0);try{const{data:M}=await Z.from("agent_cards").select("id").eq("slug",k).neq("id",t.id).maybeSingle();if(M){be.error("This URL is already taken. Try another one.");return}const{error:S}=await Z.from("agent_cards").update({slug:k}).eq("id",t.id);if(S)throw S;i(k),a.invalidateQueries({queryKey:["agent-card"]}),be.success("Card address updated!")}catch{be.error("Failed to update card address")}finally{h(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Qa,{defaultValue:"content",children:[e.jsxs(Ga,{className:"w-full h-11 p-1",children:[e.jsxs(Fs,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Zm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(Fs,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(wi,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(Fs,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Ax,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(Fs,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Ak,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(Fs,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(A1,{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(als,{userId:t.user_id}),e.jsx(ils,{form:s,setForm:r,userId:t.user_id}),e.jsx(Oe,{children:e.jsxs($e,{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(je,{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(ln,{checked:s.is_published,onCheckedChange:k=>r(M=>({...M,is_published:k}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{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(Be,{value:l,onChange:k=>i(k.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(Y,{variant:"outline",size:"sm",onClick:j,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(je,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(Be,{value:s.display_email,onChange:k=>r(M=>({...M,display_email:k.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(je,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(er,{value:s.theme,onValueChange:k=>r(M=>({...M,theme:k})),children:[e.jsx(Qs,{className:"h-11",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(Et,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(Et,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(Et,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(ols,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(Be,{value:s.title,onChange:k=>r(M=>({...M,title:k.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(je,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(Be,{value:s.positioning_statement,onChange:k=>r(M=>({...M,positioning_statement:k.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Rr,{value:s.bio,onChange:k=>r(M=>({...M,bio:k.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(je,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(Be,{value:s.review_snippet,onChange:k=>r(M=>({...M,review_snippet:k.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(Be,{value:s.review_source_url,onChange:k=>r(M=>({...M,review_source_url:k.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(Be,{value:s.booking_url,onChange:k=>r(M=>({...M,booking_url:k.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(je,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(Be,{value:s.custom_cta_label,onChange:k=>r(M=>({...M,custom_cta_label:k.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(Zs,{value:"sections",className:"mt-4",children:e.jsx(Oe,{children:e.jsx($e,{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:k,label:M,desc:S})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(je,{className:"text-sm font-medium",children:M}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsx(ln,{checked:s[k],onCheckedChange:E=>r(D=>({...D,[k]:E}))})]},k))})})}),e.jsx(Zs,{value:"blocks",className:"mt-4",children:e.jsx(UZe,{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:wi,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:A1,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((w=o==null?void 0:o.leads)==null?void 0:w.length)??0,icon:Zc,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(k=>e.jsx(Oe,{className:"overflow-hidden",children:e.jsxs($e,{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 ${k.color}`,children:e.jsx(k.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:k.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:k.value})]})},k.label))}),o&&o.leads.length>0&&e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsx(Gt,{className:"text-base",children:"Recent Leads"})}),e.jsx($e,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(k=>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:k.name}),k.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:k.phone})]}),k.intent&&e.jsx(ct,{variant:"secondary",className:"text-xs",children:k.intent})]},k.id))})]}),(!o||o.leads.length===0)&&e.jsx(Oe,{children:e.jsxs($e,{className:"p-8 text-center",children:[e.jsx(A1,{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(Oe,{children:e.jsx($e,{className:"p-6",children:e.jsx(els,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[f==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),f==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),f==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function cls(){const{isAdmin:t}=Ys(),s=vs(),[r,n]=T.useState(!1),[a,o]=T.useState(!1),[l,i]=T.useState(!1),{data:d,isLoading:h}=zt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:D,error:L}=await Z.from("gmail_integrations").select("*").maybeSingle();if(L)throw L;return D}}),{data:f}=zt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:D}}=await Z.auth.getUser();if(!D)return[];const{data:L,error:B}=await Z.from("social_accounts").select("*").eq("user_id",D.id).order("created_at",{ascending:!1});if(B)throw B;return L}}),g=async()=>{n(!0);try{const{data:D,error:L}=await Z.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(L)throw L;if(D!=null&&D.authUrl)window.location.href=D.authUrl;else throw new Error("Failed to get authorization URL")}catch(D){console.error("Gmail OAuth error:",D),be.error("Failed to start Gmail connection"),n(!1)}},v=async()=>{o(!0);try{const{data:D,error:L}=await Z.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(L)throw L;if(D!=null&&D.authUrl)window.location.href=D.authUrl;else throw new Error("Failed to get authorization URL")}catch(D){console.error("Meta OAuth error:",D),be.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},_=async()=>{i(!0);try{const{data:D,error:L}=await Z.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(L)throw L;if(D!=null&&D.authUrl)window.location.href=D.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(D){console.error("LinkedIn OAuth error:",D),be.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},j=Wt({mutationFn:async D=>{const{error:L}=await Z.from("gmail_integrations").delete().eq("id",D);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),be.success("Gmail disconnected")},onError:()=>{be.error("Failed to disconnect Gmail")}}),w=Wt({mutationFn:async D=>{const{error:L}=await Z.from("social_accounts").delete().eq("id",D);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),be.success("Account disconnected")},onError:()=>{be.error("Failed to disconnect account")}}),k=!!(d!=null&&d.is_active),M=(f==null?void 0:f.filter(D=>D.platform==="facebook"))||[],S=(f==null?void 0:f.filter(D=>D.platform==="instagram"))||[],E=(f==null?void 0:f.filter(D=>D.platform==="linkedin"))||[];return e.jsx(Vs,{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(Oe,{children:[e.jsx(Ht,{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(zr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:["Gmail",k&&e.jsx(ct,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(Tr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx($e,{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(yi,{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(yi,{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(yi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),k?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(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect Gmail?"}),e.jsx(cc,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:()=>j.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(Y,{className:"mt-4",onClick:g,disabled:r||h,children:[r?e.jsx(el,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(qi,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Oe,{className:t?"":"opacity-70",children:[e.jsx(Ht,{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(Qd,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?M.length>0?e.jsx(ct,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(ct,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(Tr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs($e,{className:"space-y-3",children:[M.length>0&&e.jsx("div",{className:"space-y-2",children:M.map(D=>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(_a,{src:D.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Qd,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:D.page_name||D.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect Facebook?"}),e.jsx(cc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:()=>w.mutate(D.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},D.id))}),e.jsxs(Y,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(el,{className:"h-4 w-4 animate-spin"}):e.jsx(ar,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Oe,{className:t?"":"opacity-70",children:[e.jsx(Ht,{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(vu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?S.length>0?e.jsx(ct,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(ct,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(Tr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs($e,{className:"space-y-3",children:[S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(D=>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(_a,{src:D.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(vu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",D.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect Instagram?"}),e.jsx(cc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:()=>w.mutate(D.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},D.id))}),e.jsxs(Y,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(el,{className:"h-4 w-4 animate-spin"}):e.jsx(ar,{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(Oe,{className:t?"":"opacity-70",children:[e.jsx(Ht,{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(cm,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?E.length>0?e.jsx(ct,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(ct,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(Tr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs($e,{className:"space-y-3",children:[E.length>0&&e.jsx("div",{className:"space-y-2",children:E.map(D=>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(_a,{src:D.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(cm,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:D.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect LinkedIn?"}),e.jsx(cc,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:()=>w.mutate(D.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},D.id))}),e.jsxs(Y,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(el,{className:"h-4 w-4 animate-spin"}):e.jsx(ar,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]})]})})}function dls(){const[t]=Oc(),s=Yr(),[r,n]=T.useState("loading"),[a,o]=T.useState("Connecting your Gmail account...");return T.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),h=t.get("error_description"),f=t.get("state");if(d){n("error"),o(h||"Authorization was denied"),be.error("Connection failed: "+(h||d));return}if(!i){n("error"),o("No authorization code received"),be.error("No authorization code received");return}try{const{data:g,error:v}=await Z.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:f}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Gmail connected successfully!"),be.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"),be.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(Oe,{className:"w-full max-w-md",children:[e.jsxs(Ht,{className:"text-center",children:[r==="loading"&&e.jsx(Us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(yi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Cc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Gt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(Tr,{children:a})]}),e.jsx($e,{className:"flex justify-center",children:r!=="loading"&&e.jsx(Y,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function uls(){const t=Yr();return T.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 hls(){const[t]=Oc(),s=Yr(),[r,n]=T.useState("loading"),[a,o]=T.useState("Processing your connection...");return T.useEffect(()=>{(async()=>{var g;const i=t.get("code"),d=t.get("error"),h=t.get("error_description"),f=t.get("state");if(d){n("error"),o(h||"Authorization was denied"),be.error("Connection failed: "+(h||d));return}if(!i){n("error"),o("No authorization code received"),be.error("No authorization code received");return}try{const{data:v,error:_}=await Z.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:f,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)!`),be.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"),be.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(Oe,{className:"w-full max-w-md",children:[e.jsxs(Ht,{className:"text-center",children:[r==="loading"&&e.jsx(Us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(yi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Cc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Gt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(Tr,{children:a})]}),e.jsx($e,{className:"flex justify-center",children:r!=="loading"&&e.jsx(Y,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const eYe=new Date().getFullYear(),mls=Array.from({length:5},(t,s)=>eYe-s);function pls(){const[t,s]=T.useState(eYe),r=Yr(),{data:n,isLoading:a}=s2t();return a?e.jsx(Vs,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(ys,{className:"h-24"},o))}),e.jsx(ys,{className:"h-96"})]})}):e.jsx(Vs,{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(er,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Qs,{className:"w-[120px]",children:e.jsx(tr,{})}),e.jsx(Js,{children:mls.map(o=>e.jsx(Et,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(br,{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(Oe,{children:e.jsxs($e,{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:"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(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Agents with Scorecards"}),e.jsx(Tr,{children:"Click to view individual agent scorecards"})]}),e.jsx($e,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Sc,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:n.map(o=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:o.name}),e.jsx(ot,{className:"text-muted-foreground",children:o.email}),e.jsx(ot,{className:"text-right",children:e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const tYe=new Date().getFullYear(),fls=Array.from({length:10},(t,s)=>tYe-s);function gls(){var v;const{userId:t}=wl(),s=Yr(),[r,n]=T.useState(tYe),{data:a,isLoading:o}=zt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:_,error:j}=await Z.from("profiles").select("id, name, email").eq("id",t).single();if(j)throw j;return _},enabled:!!t}),{data:l,isLoading:i}=I1e(r,t),{yearStats:d,lifetimeStats:h,showCommission:f}=J9e(r,t),{data:g}=Q9e(r,t);return o?e.jsx(Vs,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(_=>e.jsx(ys,{className:"h-24"},_))})]})}):e.jsx(Vs,{title:`${a==null?void 0:a.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(Y,{variant:"ghost",size:"icon",onClick:()=>s("/admin/scorecard"),children:e.jsx(bi,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:a==null?void 0:a.name}),e.jsx("p",{className:"text-muted-foreground",children:a==null?void 0:a.email})]})]}),e.jsxs(er,{value:String(r),onValueChange:_=>n(Number(_)),children:[e.jsx(Qs,{className:"w-[120px]",children:e.jsx(tr,{})}),e.jsx(Js,{children:fls.map(_=>e.jsx(Et,{value:String(_),children:_},_))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Zn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:d.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[h.totalTransactions," lifetime"]})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(br,{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:[d.buyerCount,"/",d.sellerCount]})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ad,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:fu(d.totalVolume,!0)})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jd,{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:fu(d.averagePrice,!0)})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{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=d.topLeadSource)==null?void 0:v.name)||"-"})]})})]}),g&&e.jsx(OHe,{goals:g,stats:d,year:r,showCommission:f}),e.jsxs(Qa,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"transactions",children:"Transactions"}),e.jsx(Fs,{value:"charts",children:"Charts"}),e.jsxs(Fs,{value:"map",children:[e.jsx(Gi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(Zs,{value:"transactions",children:e.jsx(DHe,{transactions:l||[],showCommission:f,isLoading:i})}),e.jsx(Zs,{value:"charts",children:e.jsx(SZe,{stats:d,year:r})}),e.jsx(Zs,{value:"map",children:e.jsx(CZe,{transactions:l||[],isLoading:i})})]})]})})}function xls(){const t=vs(),[s,r]=T.useState(""),[n,a]=T.useState("all");pBe();const{data:o,refetch:l}=zt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:S}=await Z.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(S==null?void 0:S.enabled)??!1}}),{data:i,isLoading:d}=zt({queryKey:["admin-listings"],queryFn:async()=>{const{data:S,error:E}=await Z.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(E)throw E;return S}}),{data:h}=zt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:S}=await Z.from("listings").select("id, is_approved, status"),{data:E}=await Z.from("listing_shares").select("id"),{data:D}=await Z.from("listing_views").select("id");return{total:(S==null?void 0:S.length)||0,pending:(S==null?void 0:S.filter(L=>!L.is_approved).length)||0,active:(S==null?void 0:S.filter(L=>L.status==="active").length)||0,totalShares:(E==null?void 0:E.length)||0,totalViews:(D==null?void 0:D.length)||0}}}),f=Wt({mutationFn:async({id:S,approved:E})=>{const{error:D}=await Z.from("listings").update({is_approved:E}).eq("id",S);if(D)throw D},onSuccess:(S,{approved:E})=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),be.success(E?"Listing approved":"Listing unapproved")}}),g=Wt({mutationFn:async({id:S,featured:E})=>{const{error:D}=await Z.from("listings").update({is_featured:E}).eq("id",S);if(D)throw D},onSuccess:(S,{featured:E})=>{t.invalidateQueries({queryKey:["admin-listings"]}),be.success(E?"Listing featured":"Listing unfeatured")}}),v=Wt({mutationFn:async S=>{const{error:E}=await Z.from("listings").delete().eq("id",S);if(E)throw E},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),be.success("Listing deleted")}}),_=Wt({mutationFn:async S=>{const{error:E}=await Z.from("feature_flags").update({enabled:S}).eq("key","listing_exchange_enabled");if(E)throw E},onSuccess:()=>{l(),be.success("Feature flag updated")}}),j=o??!1,w=i==null?void 0:i.filter(S=>{var L,B,$,V;const E=((L=S.city)==null?void 0:L.toLowerCase().includes(s.toLowerCase()))||(($=(B=S.agent)==null?void 0:B.name)==null?void 0:$.toLowerCase().includes(s.toLowerCase()))||((V=S.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),D=n==="all"||n==="pending"&&!S.is_approved||n==="approved"&&S.is_approved;return E&&D}),k=S=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(S),M=S=>{const E={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 E[S]||E.active};return e.jsx(Vs,{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.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),e.jsx(ln,{checked:j,onCheckedChange:S=>_.mutate(S)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ya,{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:(h==null?void 0:h.total)||0})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jd,{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:(h==null?void 0:h.active)||0})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(br,{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:(h==null?void 0:h.pending)||0})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wi,{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:(h==null?void 0:h.totalViews)||0})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kc,{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:(h==null?void 0:h.totalShares)||0})]})})]}),e.jsx(Oe,{children:e.jsx($e,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by city, address, or agent...",value:s,onChange:S=>r(S.target.value),className:"pl-9"})]}),e.jsx(Qa,{value:n,onValueChange:S=>a(S),children:e.jsxs(Ga,{children:[e.jsx(Fs,{value:"all",children:"All"}),e.jsx(Fs,{value:"pending",children:"Pending"}),e.jsx(Fs,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{children:["Listings (",(w==null?void 0:w.length)||0,")"]})}),e.jsx($e,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Property"}),e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{children:"Price"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-center",children:"Approved"}),e.jsx(Ct,{className:"text-center",children:"Featured"}),e.jsx(Ct,{children:"Views"}),e.jsx(Ct,{children:"Shares"}),e.jsx(Ct,{children:"Date"}),e.jsx(Ct,{})]})}),e.jsx(Bn,{children:d?e.jsx(ws,{children:e.jsx(ot,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(w==null?void 0:w.length)===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):w==null?void 0:w.map(S=>{var E,D,L,B,$;return e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(D=(E=S.photos)==null?void 0:E[0])!=null&&D.photo_url?e.jsx("img",{src:S.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(Ya,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:S.property_address||`${S.city}, ${S.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(L=S.property_type)==null?void 0:L.replace("_"," ")})]})]})}),e.jsx(ot,{children:e.jsx("p",{className:"text-sm",children:((B=S.agent)==null?void 0:B.name)||"Unknown"})}),e.jsx(ot,{className:"font-medium",children:k(S.price)}),e.jsx(ot,{children:e.jsx(ct,{variant:"outline",className:M(S.status),children:($=S.status)==null?void 0:$.replace("_"," ")})}),e.jsx(ot,{className:"text-center",children:e.jsx(ln,{checked:S.is_approved??!1,onCheckedChange:V=>f.mutate({id:S.id,approved:V})})}),e.jsx(ot,{className:"text-center",children:e.jsx(ln,{checked:S.is_featured??!1,onCheckedChange:V=>g.mutate({id:S.id,featured:V})})}),e.jsx(ot,{children:S.view_count||0}),e.jsx(ot,{children:S.share_count||0}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:Bs(new Date(S.created_at),"MMM d, yyyy")}),e.jsx(ot,{children:e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",children:e.jsx(Rp,{className:"h-4 w-4"})})}),e.jsxs(ju,{align:"end",children:[e.jsxs(Va,{onClick:()=>window.open(`/mission-control/listings/${S.id}`,"_blank"),children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Va,{onClick:()=>g.mutate({id:S.id,featured:!S.is_featured}),children:[e.jsx(qn,{className:"h-4 w-4 mr-2"}),S.is_featured?"Unfeature":"Feature"]}),e.jsxs(Va,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&v.mutate(S.id)},children:[e.jsx(Xr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},S.id)})})]})})})]})]})})}const yls=()=>{var g,v;const[t,s]=T.useState(""),[r,n]=T.useState(null),{data:a,isLoading:o}=zt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:_,error:j}=await Z.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(j)throw j;const w=(_==null?void 0:_.map(S=>S.user_id))||[],{data:k}=await Z.from("profiles").select("id, name, email").in("id",w);return _==null?void 0:_.map(S=>({...S,profiles:(k==null?void 0:k.find(E=>E.id===S.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var w,k,M,S,E;const j=t.toLowerCase();return((k=(w=_.profiles)==null?void 0:w.name)==null?void 0:k.toLowerCase().includes(j))||((S=(M=_.profiles)==null?void 0:M.email)==null?void 0:S.toLowerCase().includes(j))||((E=_.review_text)==null?void 0:E.toLowerCase().includes(j))}),i=a!=null&&a.length?(a.reduce((_,j)=>_+j.rating,0)/a.length).toFixed(1):"0.0",d=a==null?void 0:a.reduce((_,j)=>(_[j.rating]=(_[j.rating]||0)+1,_),{}),h=(a==null?void 0:a.filter(_=>_.posted_to_google).length)||0,f=_=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(j=>e.jsx(qn,{className:$t("h-4 w-4",_>=j?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},j))});return e.jsx(Vs,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{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(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"Total Reviews"}),e.jsx(Gt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"Average Rating"}),e.jsxs(Gt,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(qn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"5-Star Reviews"}),e.jsx(Gt,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(Oe,{children:e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Tr,{children:"Posted to Google"}),e.jsxs(Gt,{className:"flex items-center gap-2 text-3xl",children:[h,e.jsx(bn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(On,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name, email, or review...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsx(Oe,{children:e.jsx($e,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Member"}),e.jsx(Ct,{children:"Rating"}),e.jsx(Ct,{className:"hidden md:table-cell",children:"Review"}),e.jsx(Ct,{children:"Google"}),e.jsx(Ct,{children:"Date"})]})}),e.jsx(Bn,{children:o?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(_=>{var j,w;return e.jsxs(ws,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(_),children:[e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((j=_.profiles)==null?void 0:j.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(w=_.profiles)==null?void 0:w.email})]})}),e.jsx(ot,{children:f(_.rating)}),e.jsx(ot,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:_.review_text||"-"})}),e.jsx(ot,{children:_.posted_to_google?e.jsx(ct,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(ct,{variant:"outline",children:"No"})}),e.jsx(ot,{className:"text-sm text-muted-foreground",children:Bs(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(js,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsx(Ls,{children:e.jsx(Ps,{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(zr,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[f(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(xn,{className:"h-4 w-4"}),Bs(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(ct,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(bn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(ct,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},vls=[{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"}],_ls=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 bls(){const t=vs(),{user:s}=Ys(),[r,n]=T.useState(!1),[a,o]=T.useState(!1),[l,i]=T.useState(!1),{data:d,isLoading:h}=zt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:V,error:W}=await Z.from("weekly_digest_settings").select("*").single();if(W)throw W;return V}}),{data:f,isLoading:g}=zt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:V,error:W}=await Z.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(W)throw W;return V}}),{data:v}=zt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:V,error:W}=await Z.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(W)throw W;return V||0}}),{data:_,refetch:j}=zt({queryKey:["digest-queue-status"],queryFn:async()=>{const V=new Date;V.setUTCHours(0,0,0,0);const[W,G,J,ne]=await Promise.all([Z.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",V.toISOString()),Z.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",V.toISOString()),Z.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",V.toISOString()),Z.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",V.toISOString())]);return{pending:W.count||0,processing:G.count||0,sent:J.count||0,failed:ne.count||0,total:(W.count||0)+(G.count||0)+(J.count||0)+(ne.count||0)}},refetchInterval:5e3});T.useEffect(()=>{if(_&&(_.pending>0||_.processing>0)){const V=setInterval(()=>{j(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(V)}},[_,j,t]);const{data:w=0}=zt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const V=new Date;V.setUTCHours(0,0,0,0);const{count:W,error:G}=await Z.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",V.toISOString());if(G)throw G;return W||0}}),k=Wt({mutationFn:async V=>{const{error:W}=await Z.from("weekly_digest_settings").update(V).eq("id",d==null?void 0:d.id);if(W)throw W},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),be.success("Settings updated")},onError:V=>{be.error("Failed to update settings: "+V.message)}}),M=async()=>{n(!0);try{const{data:V,error:W}=await Z.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(W)throw W;V.queued?be.success(`${V.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):V.sent!==void 0&&be.success(`Digest sent! ${V.sent} emails delivered, ${V.failed} failed`),j(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(V){be.error("Failed to send digest: "+V.message)}finally{n(!1)}},S=async()=>{var V,W,G,J,ne,ie;if(!(s!=null&&s.email)){be.error("No email found for your account");return}o(!0);try{const{data:ee,error:de}=await Z.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(de)throw de;const oe=ee==null?void 0:ee.resendId,ue=ee==null?void 0:ee.resendDetails,ce=ue==null?void 0:ue.status,ge=((V=ue==null?void 0:ue.body)==null?void 0:V.status)||((G=(W=ue==null?void 0:ue.body)==null?void 0:W.data)==null?void 0:G.status),Te=((ne=(J=ue==null?void 0:ue.body)==null?void 0:J.error)==null?void 0:ne.message)||((ie=ue==null?void 0:ue.body)==null?void 0:ie.message);be.success(oe?`Preview accepted by email provider (id: ${oe})${ce?`, status check: ${ce}`:""}${ge?`, provider: ${ge}`:""}${Te?` (${Te})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(ee){be.error("Failed to send preview: "+ee.message)}finally{o(!1)}},E=async()=>{i(!0);try{const{data:V,error:W}=await Z.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(W)throw W;V.queued===0||V.sent===0&&V.failed===0&&!V.queued?be.info("No failed emails to retry"):V.queued?be.success(`${V.queued} emails queued for retry!`):be.success(`Retry complete! ${V.sent} emails delivered, ${V.failed} failed`),j(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(V){be.error("Failed to retry: "+V.message)}finally{i(!1)}},D=_!=null&&_.total?Math.round((_.sent+_.failed)/_.total*100):0,L=((_==null?void 0:_.pending)||0)>0||((_==null?void 0:_.processing)||0)>0,{data:B}=zt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var ie,ee;const V=new Date;V.setUTCHours(0,0,0,0);const[W,G,J,ne]=await Promise.all([Z.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",V.toISOString()),Z.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",V.toISOString()),Z.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",V.toISOString()),Z.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:W.count||0,totalFailed:G.count||0,agentOsEngaged:J.count||0,lastSent:((ee=(ie=ne.data)==null?void 0:ie[0])==null?void 0:ee.sent_at)||null}},refetchInterval:L?5e3:!1}),$={totalSent:(B==null?void 0:B.totalSent)||0,totalFailed:(B==null?void 0:B.totalFailed)||0,lastSent:B==null?void 0:B.lastSent,agentOsEngaged:(B==null?void 0:B.agentOsEngaged)||0};return h?e.jsx(Vs,{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(Vs,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(Qa,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(Ga,{children:[e.jsxs(Fs,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(Ic,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(Fs,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(Sc,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(Zs,{value:"settings",className:"space-y-6",children:[L&&_&&e.jsx(Oe,{className:"border-primary/50 bg-primary/5",children:e.jsxs($e,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(Us,{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:[D,"%"]})]}),e.jsx(rl,{value:D,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(Oe,{children:e.jsx($e,{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(br,{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(Oe,{children:e.jsx($e,{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(oi,{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(Oe,{children:e.jsx($e,{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(Cc,{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(Oe,{children:e.jsx($e,{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(ca,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.lastSent?Bs(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(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(ca,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(Tr,{children:"Configure when the digest is sent"})]}),e.jsxs($e,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(ln,{checked:d==null?void 0:d.is_enabled,onCheckedChange:V=>k.mutate({is_enabled:V})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Cron Frequency"}),e.jsxs(er,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:V=>k.mutate({cron_frequency:V}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(Et,{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(je,{children:"Day of Week"}),e.jsxs(er,{value:String(d==null?void 0:d.send_day),onValueChange:V=>k.mutate({send_day:parseInt(V)}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:vls.map(V=>e.jsx(Et,{value:V.value,children:V.label},V.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Time (UTC)"}),e.jsxs(er,{value:String(d==null?void 0:d.send_hour),onValueChange:V=>k.mutate({send_hour:parseInt(V)}),disabled:(d==null?void 0:d.cron_frequency)==="daily",children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:_ls.map(V=>e.jsx(Et,{value:V.value,children:V.label},V.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Y,{onClick:S,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(Y,{onClick:M,disabled:r,className:"flex-1",children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),w>0&&e.jsxs(Y,{onClick:E,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(el,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${w} Failed`]})]})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Yn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(Tr,{children:"Choose what to include in the digest"})]}),e.jsxs($e,{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(Yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(je,{children:"New Resources"})]}),e.jsx(ln,{checked:d==null?void 0:d.include_new_resources,onCheckedChange:V=>k.mutate({include_new_resources:V})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(je,{children:"Community Highlights"})]}),e.jsx(ln,{checked:d==null?void 0:d.include_community_posts,onCheckedChange:V=>k.mutate({include_community_posts:V})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sc,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(je,{children:"Agent OS Stats"})]}),e.jsx(ln,{checked:d==null?void 0:d.include_agent_os_stats,onCheckedChange:V=>k.mutate({include_agent_os_stats:V})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(je,{children:"Upcoming Events"})]}),e.jsx(ln,{checked:d==null?void 0:d.include_upcoming_events,onCheckedChange:V=>k.mutate({include_upcoming_events:V})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hm,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(je,{children:"Goals Progress"})]}),e.jsx(ln,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:V=>k.mutate({include_goals_progress:V})})]})]})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Custom Introduction"}),e.jsx(Tr,{children:"Personalize the intro message (optional)"})]}),e.jsx($e,{children:e.jsx(Rr,{placeholder:"Here's what's new this week to help you grow your business...",value:(d==null?void 0:d.custom_intro_text)||"",onChange:V=>k.mutate({custom_intro_text:V.target.value||null}),rows:3})})]})]}),e.jsx(Zs,{value:"stats",children:e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(Tr,{children:"Recent digest emails sent to members"})]}),e.jsx($e,{children:g?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(V=>e.jsx("div",{className:"h-12 bg-muted rounded"},V))}):f&&f.length>0?e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Email"}),e.jsx(Ct,{children:"Sent At"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{children:"Resources"}),e.jsx(Ct,{children:"Agent OS"})]})}),e.jsx(Bn,{children:f.map(V=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:V.email_sent_to}),e.jsx(ot,{children:Bs(new Date(V.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(ot,{children:e.jsx(ct,{variant:V.delivery_status==="sent"?"default":"destructive",children:V.delivery_status})}),e.jsx(ot,{children:V.resources_count}),e.jsx(ot,{children:V.has_agent_os_activity?e.jsx(ct,{variant:"secondary",children:"Active"}):e.jsx(ct,{variant:"outline",children:"Not Started"})})]},V.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(zr,{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 wls={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 jls(){var ye,Se,Ke;const t=vs(),[s,r]=T.useState(""),[n,a]=T.useState(null),[o,l]=T.useState(!1),[i,d]=T.useState(!1),[h,f]=T.useState(""),[g,v]=T.useState(""),[_,j]=T.useState(!0),[w,k]=T.useState(!1),[M,S]=T.useState(""),[E,D]=T.useState(null),{data:L,isLoading:B}=zt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Ae,error:Ee}=await Z.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Ee)throw Ee;const He=(Ae==null?void 0:Ae.map(Ge=>Ge.user_id))||[],{data:Ue}=await Z.from("profiles").select("id, name, email").in("id",He),De=new Map((Ue==null?void 0:Ue.map(Ge=>[Ge.id,{name:Ge.name,email:Ge.email}]))||[]);return Ae==null?void 0:Ae.map(Ge=>({...Ge,profile:De.get(Ge.user_id)||null}))}}),{data:$}=zt({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const Ee=[];let He=0;for(;;){const{data:Ue,error:De}=await Z.from("profiles").select("id, name, email").order("name").range(He,He+1e3-1);if(De)throw De;if(Ee.push(...Ue),!Ue||Ue.length<1e3)break;He+=1e3}return Ee}}),W=(($==null?void 0:$.filter(Ae=>!(L!=null&&L.some(Ee=>Ee.user_id===Ae.id))))||[]).filter(Ae=>{var He,Ue;if(!M)return!0;const Ee=M.toLowerCase();return((He=Ae.name)==null?void 0:He.toLowerCase().includes(Ee))||((Ue=Ae.email)==null?void 0:Ue.toLowerCase().includes(Ee))}),{data:G,isLoading:J}=zt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ae,error:Ee}=await Z.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Ee)throw Ee;return Ae},enabled:!!(n!=null&&n.user_id)&&i}),{data:ne}=zt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ae,error:Ee}=await Z.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Ee)throw Ee;return Ae},enabled:!!(n!=null&&n.user_id)}),ie=Wt({mutationFn:async({userId:Ae,points:Ee,reason:He})=>{const{error:Ue}=await Z.from("agent_points").insert({user_id:Ae,points:Ee,reason:He});if(Ue)throw Ue;const{data:De}=await Z.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Ae).maybeSingle(),Ge=((De==null?void 0:De.total_points)||0)+Ee,wt=((De==null?void 0:De.spendable_points)||0)+Ee,{error:Ie}=await Z.from("agent_attendance_stats").upsert({user_id:Ae,total_points:Math.max(0,Ge),spendable_points:Math.max(0,wt),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(Ie)throw Ie},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),f(""),v(""),be.success(_?"Points awarded successfully!":"Points deducted successfully!")},onError:Ae=>{console.error("Error modifying points:",Ae),be.error("Failed to modify points")}}),ee=()=>{if(!n||!h||!g){be.error("Please fill in all fields");return}const Ae=parseInt(h);if(isNaN(Ae)||Ae<=0){be.error("Please enter a valid positive number");return}ie.mutate({userId:n.user_id,points:_?Ae:-Ae,reason:g})},de=()=>{if(!E||!h||!g){be.error("Please fill in all fields");return}const Ae=parseInt(h);if(isNaN(Ae)||Ae<=0){be.error("Please enter a valid positive number");return}ie.mutate({userId:E.id,points:Ae,reason:g},{onSuccess:()=>{k(!1),D(null),S("")}})},oe=(Ae,Ee)=>{a(Ae),j(Ee),l(!0)},ue=Ae=>{a(Ae),d(!0)},ce=L==null?void 0:L.filter(Ae=>{var De,Ge,wt,Ie;const Ee=((Ge=(De=Ae.profile)==null?void 0:De.name)==null?void 0:Ge.toLowerCase())||"",He=((Ie=(wt=Ae.profile)==null?void 0:wt.email)==null?void 0:Ie.toLowerCase())||"",Ue=s.toLowerCase();return Ee.includes(Ue)||He.includes(Ue)}),ge=(L==null?void 0:L.reduce((Ae,Ee)=>Ae+Ee.total_points,0))||0,Te=(L==null?void 0:L.length)||0,ve=Te>0?Math.round(ge/Te):0;return B?e.jsx(Vs,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Ae=>e.jsx(ys,{className:"h-24"},Ae))}),e.jsx(ys,{className:"h-96"})]})}):e.jsx(Vs,{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(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(br,{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:Te}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(vo,{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:ge.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jd,{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:ve}),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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search agents...",value:s,onChange:Ae=>r(Ae.target.value),className:"pl-10"})]}),e.jsxs(Y,{onClick:()=>k(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsx(Gt,{children:"Agent Leaderboard"}),e.jsx(Tr,{children:"All agents with their points, events, and streaks"})]}),e.jsx($e,{children:!ce||ce.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(vo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-12",children:"#"}),e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{className:"text-center",children:"Total Points"}),e.jsx(Ct,{className:"text-center",children:"Spendable"}),e.jsx(Ct,{className:"text-center",children:"Events"}),e.jsx(Ct,{className:"text-center",children:"Streak"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:ce.map((Ae,Ee)=>{var He,Ue,De,Ge;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:Ee<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Ee===0?"bg-yellow-100 text-yellow-700":Ee===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Ee+1}):e.jsx("span",{className:"text-muted-foreground",children:Ee+1})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fn,{className:"h-8 w-8",children:e.jsx(gn,{children:((Ue=(He=Ae.profile)==null?void 0:He.name)==null?void 0:Ue.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((De=Ae.profile)==null?void 0:De.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Ge=Ae.profile)==null?void 0:Ge.email})]})]})}),e.jsx(ot,{className:"text-center",children:e.jsxs(ct,{variant:"secondary",className:"font-bold",children:[e.jsx(qn,{className:"h-3 w-3 mr-1"}),Ae.total_points]})}),e.jsx(ot,{className:"text-center",children:e.jsxs(ct,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(oo,{className:"h-3 w-3 mr-1"}),Ae.spendable_points||0]})}),e.jsx(ot,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3 text-muted-foreground"}),Ae.total_events_attended]})}),e.jsx(ot,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Ym,{className:"h-3 w-3 text-orange-500"}),Ae.current_streak]})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>oe(Ae,!0),title:"Award points",children:e.jsx(ar,{className:"h-4 w-4 text-green-600"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>oe(Ae,!1),title:"Deduct points",children:e.jsx(T1,{className:"h-4 w-4 text-red-600"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>ue(Ae),title:"View history",children:e.jsx(I4,{className:"h-4 w-4"})})]})})]},Ae.user_id)})})]})})]}),e.jsx(js,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:_?"Award Points":"Deduct Points"}),e.jsxs(en,{children:[_?"Award":"Deduct"," points ",_?"to":"from"," ",((ye=n==null?void 0:n.profile)==null?void 0:ye.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"points",children:"Points Amount"}),e.jsx(Be,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:h,onChange:Ae=>f(Ae.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"reason",children:"Reason"}),e.jsx(Rr,{id:"reason",placeholder:"Enter reason for this adjustment...",value:g,onChange:Ae=>v(Ae.target.value)})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Y,{onClick:ee,disabled:ie.isPending,className:_?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:ie.isPending?"Saving...":_?"Award Points":"Deduct Points"})]})]})}),e.jsx(js,{open:i,onOpenChange:d,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{children:["Point History: ",(Se=n==null?void 0:n.profile)==null?void 0:Se.name]}),e.jsx(en,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(Qa,{defaultValue:"history",className:"w-full",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-2",children:[e.jsx(Fs,{value:"history",children:"Point History"}),e.jsx(Fs,{value:"badges",children:"Badges"})]}),e.jsx(Zs,{value:"history",className:"mt-4",children:J?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Ae=>e.jsx(ys,{className:"h-12"},Ae))}):!G||G.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(I4,{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:G.map(Ae=>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:Ae.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Bs(new Date(Ae.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(ct,{variant:Ae.points>=0?"default":"destructive",className:Ae.points>=0?"bg-green-100 text-green-800":"",children:[Ae.points>=0?"+":"",Ae.points]})]},Ae.id))})}),e.jsx(Zs,{value:"badges",className:"mt-4",children:!ne||ne.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(nc,{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:ne.map(Ae=>e.jsxs("div",{className:`p-3 rounded-lg ${wls[Ae.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Ae.badge_name})]}),Ae.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Ae.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",Bs(new Date(Ae.earned_at),"MMM d, yyyy")]})]},Ae.id))})})]})]})}),e.jsx(js,{open:w,onOpenChange:Ae=>{k(Ae),Ae||(D(null),S(""),f(""),v(""))},children:e.jsxs(_s,{className:"max-w-md",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Award Points to New Agent"}),e.jsx(en,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:E?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=E.name)==null?void 0:Ke.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:E.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:E.email})]}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>D(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(Be,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:h,onChange:Ae=>f(Ae.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Rr,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:g,onChange:Ae=>v(Ae.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name or email...",value:M,onChange:Ae=>S(Ae.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:W.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(br,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:M?"No matching agents found":"All agents already have points"})]}):W.slice(0,20).map(Ae=>{var Ee;return e.jsxs("button",{onClick:()=>D(Ae),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:((Ee=Ae.name)==null?void 0:Ee.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Ae.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ae.email})]})]},Ae.id)})})]})}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),E&&e.jsxs(Y,{onClick:de,disabled:ie.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function kls(){const{data:t,isLoading:s}=Fgt(),[r,n]=T.useState(null),[a,o]=T.useState(!1),[l,i]=T.useState(""),[d,h]=T.useState("all"),[f,g]=T.useState("newest"),[v,_]=T.useState("table"),j=T.useMemo(()=>(t==null?void 0:t.map(E=>E.user_id))||[],[t]),w=T.useMemo(()=>(t==null?void 0:t.map(E=>E.id))||[],[t]),{data:k}=zt({queryKey:["card-profiles-lookup",j],queryFn:async()=>{if(j.length===0)return{};const{data:E}=await Z.from("profiles").select("id, name, email").in("id",j),D={};return E==null||E.forEach(L=>{D[L.id]={name:L.name||"",email:L.email||""}}),D},enabled:j.length>0}),{data:M}=zt({queryKey:["card-stats-all",w],queryFn:async()=>{if(w.length===0)return{};const E={};w.forEach(B=>{E[B]={views:0,leads:0}});const{data:D}=await Z.from("agent_card_interactions").select("card_id").in("card_id",w).eq("interaction_type","card_view");D==null||D.forEach(B=>{E[B.card_id]&&E[B.card_id].views++});const{data:L}=await Z.from("agent_card_leads").select("card_id").in("card_id",w);return L==null||L.forEach(B=>{E[B.card_id]&&E[B.card_id].leads++}),E},enabled:w.length>0}),S=T.useMemo(()=>{if(!t)return[];let E=[...t];if(d==="live"?E=E.filter(D=>D.is_published):d==="draft"&&(E=E.filter(D=>!D.is_published)),l.trim()){const D=l.toLowerCase();E=E.filter(L=>{var $,V;const B=k==null?void 0:k[L.user_id];return L.slug.toLowerCase().includes(D)||(($=B==null?void 0:B.name)==null?void 0:$.toLowerCase().includes(D))||((V=B==null?void 0:B.email)==null?void 0:V.toLowerCase().includes(D))})}return f==="newest"?E.sort((D,L)=>new Date(L.created_at).getTime()-new Date(D.created_at).getTime()):f==="oldest"?E.sort((D,L)=>new Date(D.created_at).getTime()-new Date(L.created_at).getTime()):f==="name"?E.sort((D,L)=>{var B,$;return(((B=k==null?void 0:k[D.user_id])==null?void 0:B.name)||"").localeCompare((($=k==null?void 0:k[L.user_id])==null?void 0:$.name)||"")}):f==="slug"?E.sort((D,L)=>D.slug.localeCompare(L.slug)):f==="views_desc"?E.sort((D,L)=>{var B,$;return(((B=M==null?void 0:M[L.id])==null?void 0:B.views)||0)-((($=M==null?void 0:M[D.id])==null?void 0:$.views)||0)}):f==="views_asc"?E.sort((D,L)=>{var B,$;return(((B=M==null?void 0:M[D.id])==null?void 0:B.views)||0)-((($=M==null?void 0:M[L.id])==null?void 0:$.views)||0)}):f==="leads_desc"?E.sort((D,L)=>{var B,$;return(((B=M==null?void 0:M[L.id])==null?void 0:B.leads)||0)-((($=M==null?void 0:M[D.id])==null?void 0:$.leads)||0)}):f==="leads_asc"&&E.sort((D,L)=>{var B,$;return(((B=M==null?void 0:M[D.id])==null?void 0:B.leads)||0)-((($=M==null?void 0:M[L.id])==null?void 0:$.leads)||0)}),E},[t,d,l,f,k]);return e.jsxs(Vs,{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(Y,{onClick:()=>o(!0),children:[e.jsx(ar,{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(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name, email, or slug...",value:l,onChange:E=>i(E.target.value),className:"pl-9"})]}),e.jsxs(er,{value:d,onValueChange:h,children:[e.jsx(Qs,{className:"w-full sm:w-36",children:e.jsx(tr,{placeholder:"Status"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All Status"}),e.jsx(Et,{value:"live",children:"Live"}),e.jsx(Et,{value:"draft",children:"Draft"})]})]}),e.jsxs(er,{value:f,onValueChange:g,children:[e.jsx(Qs,{className:"w-full sm:w-44",children:e.jsx(tr,{placeholder:"Sort by"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"newest",children:"Newest First"}),e.jsx(Et,{value:"oldest",children:"Oldest First"}),e.jsx(Et,{value:"name",children:"Name A–Z"}),e.jsx(Et,{value:"slug",children:"Slug A–Z"}),e.jsx(Et,{value:"views_desc",children:"Most Views"}),e.jsx(Et,{value:"views_asc",children:"Fewest Views"}),e.jsx(Et,{value:"leads_desc",children:"Most Leads"}),e.jsx(Et,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(Y,{variant:v==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:e.jsx(V4,{className:"h-4 w-4"})}),e.jsx(Y,{variant:v==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(Qm,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",S.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(E=>e.jsx(ys,{className:"h-48"},E))}):S.length>0?v==="table"?e.jsx(Nls,{cards:S,cardProfiles:k,cardStats:M,onEdit:n,sortBy:f,setSortBy:g}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:S.map(E=>e.jsx(Sls,{card:E,onEdit:()=>n(E),stats:M==null?void 0:M[E.id]},E.id))}):t&&t.length>0?e.jsx(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(On,{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(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(br,{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(Y,{onClick:()=>o(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(Cls,{open:a,onOpenChange:o}),r&&e.jsx(Mls,{card:r,open:!!r,onOpenChange:E=>!E&&n(null)})]})}function Nls({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(jx,{className:"h-3 w-3"}):a===`${d}_asc`?e.jsx(Wm,{className:"h-3 w-3"}):e.jsx(Hp,{className:"h-3 w-3 opacity-40"});return e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b 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(Wm,{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 h=s==null?void 0:s[d.user_id],f=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:(h==null?void 0:h.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(h==null?void 0:h.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(ct,{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:(f==null?void 0:f.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(f==null?void 0:f.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>n(d),className:"h-8 w-8 p-0",children:e.jsx(Xa,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(g),be.success("Link copied!")},children:e.jsx(Di,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{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(bn,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function Sls({card:t,onEdit:s,stats:r}){const[n,a]=T.useState(null);T.useEffect(()=>{(async()=>{const{data:d}=await Z.from("profiles").select("name").eq("id",t.user_id).single();let h=null;try{const{data:f}=await Z.storage.from("avatars").list(`${t.user_id}`);if(f&&f.length>0){const{data:g}=Z.storage.from("avatars").getPublicUrl(`${t.user_id}/${f[0].name}`);h=g.publicUrl}}catch{}a({name:(d==null?void 0:d.name)||"Unknown",avatar_url:h})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),be.success("Link copied!")};return e.jsx(Oe,{children:e.jsxs($e,{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(_a,{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(ct,{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(wi,{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(br,{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(Y,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(Xa,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(Y,{variant:"outline",size:"sm",onClick:l,children:e.jsx(Di,{className:"h-3 w-3"})}),e.jsx(Y,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(bn,{className:"h-3 w-3"})})})]})]})})}function Cls({open:t,onOpenChange:s}){const[r,n]=T.useState(""),[a,o]=T.useState(""),[l,i]=T.useState(""),[d,h]=T.useState(!1),f=T7e(),g=l.trim(),{data:v}=zt({queryKey:["profiles-search-for-cards",g],queryFn:async()=>{let S=Z.from("profiles").select("id, name, email").order("name").limit(50);g.length>=2&&(S=S.or(`name.ilike.%${g}%,email.ilike.%${g}%`));const{data:E}=await S;return E||[]},enabled:t}),[_,j]=T.useState(null),w=(v==null?void 0:v.find(S=>S.id===r))||_,k=()=>{if(!r||!a.trim()){be.error("Select an agent and enter a slug");return}f.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},M=S=>{var D;n(S),h(!1);const E=v==null?void 0:v.find(L=>L.id===S);E&&(j(E),o(((D=E.name)==null?void 0:D.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Create Agent Card"}),e.jsx(en,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Agent"}),e.jsxs(_l,{open:d,onOpenChange:h,children:[e.jsx(bl,{asChild:!0,children:e.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",children:[w?`${w.name} (${w.email})`:"Search for an agent...",e.jsx(mg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(nl,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(wg,{shouldFilter:!1,children:[e.jsx(jg,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(kg,{children:[e.jsx(Ng,{children:"No agents found."}),e.jsx(Sg,{children:(v||[]).map(S=>e.jsxs(Vm,{value:S.id,onSelect:M,children:[e.jsx(ma,{className:$t("mr-2 h-4 w-4",r===S.id?"opacity-100":"opacity-0")}),S.name," (",S.email,")"]},S.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(je,{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(Be,{value:a,onChange:S=>o(S.target.value),placeholder:"john-doe"})]})]}),e.jsx(Y,{onClick:k,disabled:f.isPending,className:"w-full",children:f.isPending?"Creating...":"Create Card"})]})]})})}function Mls({card:t,open:s,onOpenChange:r}){const n=A7e(),{data:a}=E7e(t.id),o=vs(),[l,i]=T.useState(null),[d,h]=T.useState(!1),[f,g]=T.useState(!1),[v,_]=T.useState(""),[j,w]=T.useState(t.slug),[k,M]=T.useState(!1),[S,E]=T.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});T.useEffect(()=>{s&&(async()=>{try{const{data:G}=await Z.storage.from("avatars").list(`${t.user_id}`);if(G&&G.length>0){const{data:J}=Z.storage.from("avatars").getPublicUrl(`${t.user_id}/${G[0].name}`);i(`${J.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const D=W=>{var ne;const G=(ne=W.target.files)==null?void 0:ne[0];if(!G)return;if(!G.type.startsWith("image/")){be.error("Please select an image file");return}if(G.size>5*1024*1024){be.error("Image must be under 5MB");return}const J=new FileReader;J.onloadend=()=>{_(J.result),g(!0)},J.readAsDataURL(G),W.target.value=""},L=async W=>{h(!0);try{const{data:G}=await Z.storage.from("avatars").list(`${t.user_id}`);G&&G.length>0&&await Z.storage.from("avatars").remove(G.map(de=>`${t.user_id}/${de.name}`));const J=`${t.user_id}/avatar.jpg`,{error:ne}=await Z.storage.from("avatars").upload(J,W,{upsert:!0,contentType:"image/jpeg"});if(ne)throw ne;const{data:ie}=Z.storage.from("avatars").getPublicUrl(J),ee=`${ie.publicUrl}?t=${Date.now()}`;i(ee),await Z.from("profiles").update({avatar_url:ee}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),be.success("Photo updated!")}catch(G){be.error(G.message||"Upload failed")}finally{h(!1)}},B=async()=>{const W=j.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!W){be.error("Please enter a valid URL");return}if(W===t.slug){be.info("No changes to save");return}M(!0);try{const{data:G}=await Z.from("agent_cards").select("id").eq("slug",W).neq("id",t.id).maybeSingle();if(G){be.error("This URL is already taken. Try another one.");return}const{error:J}=await Z.from("agent_cards").update({slug:W}).eq("id",t.id);if(J)throw J;w(W),o.invalidateQueries({queryKey:["agent-cards-admin"]}),be.success("Card address updated!")}catch{be.error("Failed to update card address")}finally{M(!1)}},$=async(W,G)=>{var ne;const J=(ne=W.target.files)==null?void 0:ne[0];if(J){if(!J.type.startsWith("image/")){be.error("Please select an image file");return}try{const ie=J.name.split(".").pop()||"png",ee=G==="brokerage_logo_url"?"brokerage-logo":"team-logo",de=`${t.user_id}/${ee}.${ie}`,{error:oe}=await Z.storage.from("card-logos").upload(de,J,{upsert:!0});if(oe)throw oe;const{data:ue}=Z.storage.from("card-logos").getPublicUrl(de),ce=ue.publicUrl+"?t="+Date.now();E(G==="brokerage_logo_url"?ge=>({...ge,[G]:ce,brokerage_display_name:""}):ge=>({...ge,[G]:ce,team_name:""})),be.success("Logo uploaded!")}catch{be.error("Failed to upload logo")}finally{W.target.value=""}}},V=()=>{n.mutate({id:t.id,...S,title:S.title||null,positioning_statement:S.positioning_statement||null,bio:S.bio||null,review_snippet:S.review_snippet||null,review_source_url:S.review_source_url||null,booking_url:S.booking_url||null,custom_cta_label:S.custom_cta_label||null,custom_cta_url:S.custom_cta_url||null,brokerage_display_name:S.brokerage_display_name||null,brokerage_logo_url:S.brokerage_logo_url||null,brokerage_logo_size:S.brokerage_logo_size,team_name:S.team_name||null,team_logo_url:S.team_logo_url||null,team_logo_size:S.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(js,{open:s,onOpenChange:r,children:e.jsxs(_s,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Edit Agent Card"}),e.jsxs(en,{children:["/card/",t.slug]})]}),e.jsxs(Qa,{defaultValue:"content",children:[e.jsxs(Ga,{className:"w-full",children:[e.jsx(Fs,{value:"content",className:"flex-1",children:"Content"}),e.jsx(Fs,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(Fs,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(Fs,{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(je,{children:"Published"}),e.jsx(ln,{checked:S.is_published,onCheckedChange:W=>E(G=>({...G,is_published:W}))})]}),e.jsxs("div",{children:[e.jsx(je,{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(_a,{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:D,disabled:d}),e.jsx(Y,{variant:"outline",size:"sm",asChild:!0,disabled:d,children:e.jsx("span",{children:d?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ji,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{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(Be,{value:j,onChange:W=>w(W.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(Y,{variant:"outline",size:"sm",onClick:B,disabled:k||j===t.slug,className:"shrink-0",children:k?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Theme"}),e.jsxs(er,{value:S.theme,onValueChange:W=>E(G=>({...G,theme:W})),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(Et,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(Et,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(Et,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Title / Tagline"}),e.jsx(Be,{value:S.title,onChange:W=>E(G=>({...G,title:W.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(je,{children:"Positioning Statement"}),e.jsx(Be,{value:S.positioning_statement,onChange:W=>E(G=>({...G,positioning_statement:W.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Bio"}),e.jsx(Rr,{value:S.bio,onChange:W=>E(G=>({...G,bio:W.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Review Snippet"}),e.jsx(Be,{value:S.review_snippet,onChange:W=>E(G=>({...G,review_snippet:W.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Review Source URL"}),e.jsx(Be,{value:S.review_source_url,onChange:W=>E(G=>({...G,review_source_url:W.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(Be,{value:S.booking_url,onChange:W=>E(G=>({...G,booking_url:W.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Custom CTA Label (optional)"}),e.jsx(Be,{value:S.custom_cta_label,onChange:W=>E(G=>({...G,custom_cta_label:W.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Custom CTA URL (optional)"}),e.jsx(Be,{value:S.custom_cta_url,onChange:W=>E(G=>({...G,custom_cta_url:W.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(je,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{value:S.brokerage_display_name,onChange:W=>E(G=>({...G,brokerage_display_name:W.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!S.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${S.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>E(W=>({...W,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(ji,{className:"h-3.5 w-3.5"}),S.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:W=>$(W,"brokerage_logo_url")})]})]}),S.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.brokerage_logo_size||56,"px"]})]}),e.jsx(og,{value:[S.brokerage_logo_size||56],onValueChange:([W])=>E(G=>({...G,brokerage_logo_size:W})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(je,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{value:S.team_name,onChange:W=>E(G=>({...G,team_name:W.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!S.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.team_logo_url,alt:"Team logo",style:{height:`${S.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>E(W=>({...W,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(ji,{className:"h-3.5 w-3.5"}),S.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:W=>$(W,"team_logo_url")})]})]}),S.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(je,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.team_logo_size||56,"px"]})]}),e.jsx(og,{value:[S.team_logo_size||56],onValueChange:([W])=>E(G=>({...G,team_logo_size:W})),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:W,label:G,hint:J})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(je,{children:G}),J&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[J," ",W==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(ln,{checked:S[W],onCheckedChange:ne=>E(ie=>({...ie,[W]:ne}))})]},W))}),e.jsx(Zs,{value:"blocks",className:"mt-4",children:e.jsx(UZe,{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(Oe,{children:e.jsxs($e,{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(Oe,{children:e.jsxs($e,{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(Oe,{children:e.jsxs($e,{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(W=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:W.name}),W.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",W.phone]}),W.intent&&e.jsx(ct,{variant:"secondary",className:"ml-2 text-xs",children:W.intent})]},W.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(Y,{onClick:V,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(b_e,{open:f,onClose:()=>g(!1),imageSrc:v,onCropComplete:L,aspectRatio:1})]})}const u5={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"},awe={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 iwe(t=!0){return zt({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=Z.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 Tls(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),be.success("Category created successfully")},onError:s=>{be.error("Failed to create category: "+s.message)}})}function Als(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),be.success("Category updated successfully")},onError:s=>{be.error("Failed to update category: "+s.message)}})}function Els(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),be.success("Category deleted successfully")},onError:s=>{be.error("Failed to delete category: "+s.message)}})}function sYe(t,s=!0){return zt({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=Z.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 Ils(t){return zt({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await Z.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 Pls(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),be.success("Product created successfully")},onError:s=>{be.error("Failed to create product: "+s.message)}})}function Lls(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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]}),be.success("Product updated successfully")},onError:s=>{be.error("Failed to update product: "+s.message)}})}function Dls(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),be.success("Product deleted successfully")},onError:s=>{be.error("Failed to delete product: "+s.message)}})}function Ols(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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 Rls(){const t=vs();return Wt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await Z.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]}),be.success("Image deleted successfully")},onError:s=>{be.error("Failed to delete image: "+s.message)}})}function Fls(){const t=vs();return Wt({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await Z.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await Z.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]}),be.success("Primary image updated")},onError:s=>{be.error("Failed to set primary image: "+s.message)}})}function zls(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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]}),be.success("Variant added successfully")}})}function Bls(){const t=vs();return Wt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await Z.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]}),be.success("Variant deleted successfully")}})}function $ls(){const t=vs();return Wt({mutationFn:async({productId:s,videoUrl:r})=>{await Z.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await Z.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]}),be.success("Video updated successfully")}})}function Uls(t){const{isAdmin:s}=Ys();return zt({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=Z.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 Z.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 qls(){const{user:t}=Ys();return zt({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await Z.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 Vls(t){return zt({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await Z.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 Hls(){const t=vs(),{user:s}=Ys();return Wt({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:h}=await Z.from("marketplace_orders").update(d).eq("id",r);if(h)throw h;const{error:f}=await Z.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(f)throw f;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await Z.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"]}),be.success("Order status updated")},onError:r=>{be.error("Failed to update order: "+r.message)}})}function Wls(){const t=vs();return Wt({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await Z.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await Z.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await Z.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"]}),be.success("Proof uploaded & customer notified")}})}function Gls(){const t=vs();return Wt({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await Z.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"]}),be.success("Proof approved")}})}function Kls(){const t=vs();return Wt({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await Z.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"]}),be.success("Proof rejected - please upload a new proof")}})}function Zls(){const{data:t,isLoading:s}=iwe(!1),r=Tls(),n=Als(),a=Els(),[o,l]=T.useState(!1),[i,d]=T.useState(null),[h,f]=T.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),g=()=>{f({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),d(null)},v=w=>{d(w),f({name:w.name,description:w.description||"",image_url:w.image_url||"",sort_order:w.sort_order,is_active:w.is_active}),l(!0)},_=async w=>{w.preventDefault(),i?await n.mutateAsync({id:i.id,...h}):await r.mutateAsync(h),l(!1),g()},j=async w=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(w)};return s?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx($e,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(w=>e.jsx(ys,{className:"h-12 w-full"},w))})})]}):e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsx(Gt,{children:"Categories"}),e.jsxs(js,{open:o,onOpenChange:w=>{l(w),w||g()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{htmlFor:"name",children:"Name"}),e.jsx(Be,{id:"name",value:h.name,onChange:w=>f({...h,name:w.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",value:h.description,onChange:w=>f({...h,description:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"image_url",children:"Image URL"}),e.jsx(Be,{id:"image_url",value:h.image_url,onChange:w=>f({...h,image_url:w.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Be,{id:"sort_order",type:"number",value:h.sort_order,onChange:w=>f({...h,sort_order:parseInt(w.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{id:"is_active",checked:h.is_active,onCheckedChange:w=>f({...h,is_active:w})}),e.jsx(je,{htmlFor:"is_active",children:"Active"})]}),e.jsx(Y,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx($e,{children:t&&t.length>0?e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{children:"Sort Order"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(w=>e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium",children:w.name}),e.jsx(ot,{className:"max-w-xs truncate",children:w.description}),e.jsx(ot,{children:w.sort_order}),e.jsx(ot,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${w.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:w.is_active?"Active":"Inactive"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>v(w),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>j(w.id),disabled:a.isPending,children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},w.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function Yls(){var ve,ye;const{data:t,isLoading:s}=sYe(void 0,!1),{data:r}=iwe(!1),n=Pls(),a=Lls(),o=Dls(),l=Ols(),i=Rls(),d=Fls(),h=zls(),f=Bls(),g=$ls(),[v,_]=T.useState(!1),[j,w]=T.useState(!1),[k,M]=T.useState(!1),[S,E]=T.useState(null),[D,L]=T.useState(null),[B,$]=T.useState(!1),[V,W]=T.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}),[G,J]=T.useState({name:"",price_adjustment:0}),[ne,ie]=T.useState(""),ee=()=>{W({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),E(null)},de=Se=>{E(Se),W({name:Se.name,description:Se.description||"",base_price:Number(Se.base_price),shipping_fee:Number(Se.shipping_fee),category_id:Se.category_id||"",allow_artwork_upload:Se.allow_artwork_upload,requires_proof_approval:Se.requires_proof_approval,is_active:Se.is_active,sort_order:Se.sort_order}),_(!0)},oe=async Se=>{Se.preventDefault();const Ke={...V,category_id:V.category_id||null};S?await a.mutateAsync({id:S.id,...Ke}):await n.mutateAsync(Ke),_(!1),ee()},ue=async Se=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(Se)},ce=async Se=>{if(!D||!Se.target.files||Se.target.files.length===0)return;$(!0);const Ke=Se.target.files[0],Ae=Ke.name.split(".").pop(),Ee=`products/${D.id}/${Date.now()}.${Ae}`;try{const{error:He}=await Z.storage.from("marketplace").upload(Ee,Ke);if(He)throw He;const{data:{publicUrl:Ue}}=Z.storage.from("marketplace").getPublicUrl(Ee);await l.mutateAsync({product_id:D.id,image_url:Ue,is_primary:!D.images||D.images.length===0}),be.success("Image uploaded successfully")}catch(He){be.error("Failed to upload image: "+He.message)}finally{$(!1)}},ge=async Se=>{Se.preventDefault(),D&&(await h.mutateAsync({product_id:D.id,name:G.name,price_adjustment:G.price_adjustment}),J({name:"",price_adjustment:0}))},Te=async()=>{!D||!ne||(await g.mutateAsync({productId:D.id,videoUrl:ne}),ie(""))};return s?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx($e,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(Se=>e.jsx(ys,{className:"h-64 w-full"},Se))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsx(Gt,{children:"Products"}),e.jsxs(js,{open:v,onOpenChange:Se=>{_(Se),Se||ee()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:S?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:oe,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(je,{htmlFor:"name",children:"Product Name"}),e.jsx(Be,{id:"name",value:V.name,onChange:Se=>W({...V,name:Se.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"category",children:"Category"}),e.jsxs(er,{value:V.category_id,onValueChange:Se=>W({...V,category_id:Se}),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select category"})}),e.jsx(Js,{children:r==null?void 0:r.map(Se=>e.jsx(Et,{value:Se.id,children:Se.name},Se.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"description",children:"Description"}),e.jsx(Rr,{id:"description",value:V.description,onChange:Se=>W({...V,description:Se.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(je,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(Be,{id:"base_price",type:"number",step:"0.01",min:"0",value:V.base_price,onChange:Se=>W({...V,base_price:parseFloat(Se.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(Be,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:V.shipping_fee,onChange:Se=>W({...V,shipping_fee:parseFloat(Se.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Be,{id:"sort_order",type:"number",value:V.sort_order,onChange:Se=>W({...V,sort_order:parseInt(Se.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{id:"allow_artwork_upload",checked:V.allow_artwork_upload,onCheckedChange:Se=>W({...V,allow_artwork_upload:Se})}),e.jsx(je,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{id:"requires_proof_approval",checked:V.requires_proof_approval,onCheckedChange:Se=>W({...V,requires_proof_approval:Se})}),e.jsx(je,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{id:"is_active",checked:V.is_active,onCheckedChange:Se=>W({...V,is_active:Se})}),e.jsx(je,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(Y,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:S?"Update Product":"Create Product"})]})]})]})]}),e.jsx($e,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(Se=>{var Ke,Ae;return e.jsxs(Oe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[Se.images&&Se.images.length>0?e.jsx("img",{src:((Ke=Se.images.find(Ee=>Ee.is_primary))==null?void 0:Ke.image_url)||Se.images[0].image_url,alt:Se.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"}),!Se.is_active&&e.jsx(ct,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs($e,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:Se.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Ae=Se.category)==null?void 0:Ae.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(Se.base_price).toFixed(2)]}),Number(Se.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(Se.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[Se.allow_artwork_upload&&e.jsx(ct,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),Se.requires_proof_approval&&e.jsx(ct,{variant:"outline",className:"text-xs",children:"Proof Required"}),Se.variants&&Se.variants.length>0&&e.jsxs(ct,{variant:"outline",className:"text-xs",children:[Se.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>de(Se),children:[e.jsx(Xa,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>{L(Se),w(!0)},children:[e.jsx(M1,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>{L(Se),M(!0)},children:[e.jsx(Kp,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>ue(Se.id),children:e.jsx(Ir,{className:"h-3 w-3 text-destructive"})})]})]})]},Se.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(js,{open:j,onOpenChange:w,children:e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:["Manage Images - ",D==null?void 0:D.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(ve=D==null?void 0:D.images)==null?void 0:ve.map(Se=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:Se.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),Se.is_primary&&e.jsx(ct,{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:[!Se.is_primary&&e.jsx(Y,{variant:"secondary",size:"icon",onClick:async()=>{var Ke;await d.mutateAsync({imageId:Se.id,productId:D.id}),L({...D,images:(Ke=D.images)==null?void 0:Ke.map(Ae=>({...Ae,is_primary:Ae.id===Se.id}))})},disabled:d.isPending,title:"Set as primary",children:e.jsx(qn,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"destructive",size:"icon",onClick:async()=>{var Ae;await i.mutateAsync({id:Se.id,productId:D.id});const Ke=t==null?void 0:t.find(Ee=>Ee.id===D.id);Ke&&L({...Ke,images:(Ae=Ke.images)==null?void 0:Ae.filter(Ee=>Ee.id!==Se.id)})},disabled:i.isPending,children:e.jsx(Ir,{className:"h-4 w-4"})})]})]},Se.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:ce,className:"hidden",id:"image-upload",disabled:B}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(M1,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:B?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(je,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(Be,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:ne,onChange:Se=>ie(Se.target.value)}),e.jsxs(Y,{onClick:Te,disabled:!ne,children:[e.jsx(Wn,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(D==null?void 0:D.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",D.video.video_url]})]})]})]})}),e.jsx(js,{open:k,onOpenChange:M,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:["Manage Variants - ",D==null?void 0:D.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:ge,className:"flex gap-2",children:[e.jsx(Be,{placeholder:"Variant name (e.g., 500 count)",value:G.name,onChange:Se=>J({...G,name:Se.target.value}),required:!0}),e.jsx(Be,{type:"number",step:"0.01",placeholder:"Price adj.",value:G.price_adjustment,onChange:Se=>J({...G,price_adjustment:parseFloat(Se.target.value)||0}),className:"w-32"}),e.jsx(Y,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(ye=D==null?void 0:D.variants)==null?void 0:ye.map(Se=>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:Se.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(Se.price_adjustment)>=0?"+":"","$",Number(Se.price_adjustment).toFixed(2)]})]}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>f.mutateAsync({id:Se.id,productId:D.id}),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]},Se.id)),(!(D!=null&&D.variants)||D.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 Xls=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function Qls(){var w,k,M;const{data:t,isLoading:s}=Uls(),r=Hls(),n=Wls(),[a,o]=T.useState(null),[l,i]=T.useState(!1),[d,h]=T.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[f,g]=T.useState(!1),v=S=>{o(S),h({status:S.status,notes:"",trackingNumber:S.tracking_number||"",trackingUrl:S.tracking_url||""}),i(!0)},_=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:d.status,notes:d.notes,trackingNumber:d.trackingNumber,trackingUrl:d.trackingUrl,previousStatus:a.status}),i(!1))},j=async(S,E)=>{if(!a||!S.target.files||S.target.files.length===0)return;g(!0);const D=S.target.files[0],L=D.name.split(".").pop(),B=`proofs/${a.id}/${E}/${Date.now()}.${L}`;try{const{error:$}=await Z.storage.from("marketplace").upload(B,D);if($)throw $;const{data:{publicUrl:V}}=Z.storage.from("marketplace").getPublicUrl(B);await n.mutateAsync({itemId:E,proofUrl:V,orderId:a.id}),be.success("Proof uploaded successfully")}catch($){be.error("Failed to upload proof: "+$.message)}finally{g(!1)}};return s?e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(ys,{className:"h-8 w-48"})}),e.jsx($e,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(S=>e.jsx(ys,{className:"h-16 w-full"},S))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Orders"})}),e.jsx($e,{children:t&&t.length>0?e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Order #"}),e.jsx(Ct,{children:"Customer"}),e.jsx(Ct,{children:"Date"}),e.jsx(Ct,{children:"Total"}),e.jsx(Ct,{children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(S=>{var E,D;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-mono",children:S.order_number}),e.jsx(ot,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((E=S.user)==null?void 0:E.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(D=S.user)==null?void 0:D.email})]})}),e.jsx(ot,{children:Bs(new Date(S.created_at),"MMM d, yyyy")}),e.jsxs(ot,{className:"font-bold",children:["$",Number(S.total).toFixed(2)]}),e.jsx(ot,{children:e.jsx(ct,{className:awe[S.status],children:u5[S.status]})}),e.jsx(ot,{className:"text-right",children:e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>v(S),children:[e.jsx(wi,{className:"h-4 w-4 mr-1"}),"View"]})})]},S.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(js,{open:l,onOpenChange:i,children:e.jsxs(_s,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:["Order ",a==null?void 0:a.order_number]})}),a&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),e.jsx("p",{children:(w=a.user)==null?void 0:w.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(k=a.user)==null?void 0:k.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:(M=a.items)==null?void 0:M.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(S.unit_price).toFixed(2)," x ",S.quantity]})]}),S.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(ct,{variant:S.proof_status==="approved"?"default":"secondary",children:S.proof_status||"No proof yet"})]}),S.proof_url?e.jsx("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:E=>j(E,S.id),className:"hidden",id:`proof-${S.id}`,disabled:f}),e.jsx("label",{htmlFor:`proof-${S.id}`,children:e.jsx(Y,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(ji,{className:"h-4 w-4 mr-1"}),f?"Uploading...":"Upload Proof"]})})})]})]})})]},S.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Status"}),e.jsxs(er,{value:d.status,onValueChange:S=>h({...d,status:S}),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:Xls.map(S=>e.jsx(Et,{value:S,children:u5[S]},S))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Tracking Number"}),e.jsx(Be,{value:d.trackingNumber,onChange:S=>h({...d,trackingNumber:S.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Tracking URL"}),e.jsx(Be,{value:d.trackingUrl,onChange:S=>h({...d,trackingUrl:S.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Notes (optional)"}),e.jsx(Rr,{value:d.notes,onChange:S=>h({...d,notes:S.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(Y,{onClick:_,disabled:r.isPending,className:"w-full",children:[e.jsx(mc,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(S=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(ct,{variant:"outline",children:u5[S.status]}),S.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:S.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:Bs(new Date(S.created_at),"MMM d, h:mm a")})]},S.id))})]})]})]})})]})}function Jls(){const[t,s]=T.useState("products"),r=Yr();return e.jsx(Vs,{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(Y,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(Qa,{value:t,onValueChange:s,children:[e.jsxs(Ga,{className:"grid w-full grid-cols-3",children:[e.jsxs(Fs,{value:"products",className:"flex items-center gap-2",children:[e.jsx(mc,{className:"h-4 w-4"}),"Products"]}),e.jsxs(Fs,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(om,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(Fs,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(Jh,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(Zs,{value:"products",children:e.jsx(Yls,{})}),e.jsx(Zs,{value:"categories",children:e.jsx(Zls,{})}),e.jsx(Zs,{value:"orders",children:e.jsx(Qls,{})})]})]})})}function rYe(){return zt({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await Z.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function ecs(t){return zt({queryKey:["reward-items",t],queryFn:async()=>{let s=Z.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 tcs(t){return zt({queryKey:["active-reward-items",t],queryFn:async()=>{let s=Z.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 scs(t){return zt({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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 rcs(){return zt({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await Z.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 Z.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 ncs(t){return zt({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await Z.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 acs(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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 ics(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function ocs(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function lcs(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function ccs(){const t=vs();return Wt({mutationFn:async s=>{const{data:r,error:n}=await Z.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 dcs(){const t=vs();return Wt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await Z.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 ucs(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.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 hcs(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function kme(t,s){const r=hcs(t);if(r)try{const{data:n,error:a}=await Z.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),be.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),be.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),be.error("Failed to download file")}}function nYe(){return zt({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await Z.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function mcs(){const t=vs();return Wt({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 Z.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 pcs(){const{user:t}=Ys(),[s,r]=T.useState("items"),[n,a]=T.useState(!1),[o,l]=T.useState(null),[i,d]=T.useState(""),[h,f]=T.useState(""),[g,v]=T.useState(""),[_,j]=T.useState(null),[w,k]=T.useState(!1),[M,S]=T.useState(null),[E,D]=T.useState(""),[L,B]=T.useState(""),[$,V]=T.useState(null),[W,G]=T.useState(""),[J,ne]=T.useState("file"),[ie,ee]=T.useState(""),[de,oe]=T.useState(""),[ue,ce]=T.useState(""),[ge,Te]=T.useState(!0),[ve,ye]=T.useState(null),[Se,Ke]=T.useState(!1),[Ae,Ee]=T.useState(!1),He=T.useRef(null),Ue=T.useRef(null),{data:De,isLoading:Ge}=rYe(),{data:wt,isLoading:Ie}=ecs(),{data:st,isLoading:he}=rcs(),{data:We,isLoading:et}=nYe(),Ye=ics(),ke=ocs(),at=lcs(),Fe=ccs(),it=dcs(),dt=ucs(),tt=mcs(),[ut,xt]=T.useState({}),_t=yt=>{yt?(l(yt),d(yt.name),f(yt.description||""),v(yt.icon||"")):(l(null),d(""),f(""),v("")),a(!0)},qe=async()=>{if(!i.trim()){be.error("Please enter a category name");return}try{o?(await ke.mutateAsync({id:o.id,name:i,description:h||null,icon:g||null}),be.success("Category updated successfully")):(await Ye.mutateAsync({name:i,description:h||null,icon:g||null,sort_order:((De==null?void 0:De.length)||0)+1}),be.success("Category created successfully")),a(!1)}catch(yt){console.error("Error saving category:",yt),be.error("Failed to save category")}},Lt=async()=>{if(_)try{await at.mutateAsync(_),be.success("Category deleted successfully"),j(null)}catch(yt){console.error("Error deleting category:",yt),be.error("Failed to delete category")}},Rt=yt=>{var bs;yt?(S(yt),D(yt.name),B(yt.description||""),V(yt.category_id),G(yt.points_cost.toString()),ne(yt.item_type),ee(yt.file_url||""),oe(yt.preview_image_url||""),ce(((bs=yt.max_quantity)==null?void 0:bs.toString())||""),Te(yt.is_active)):(S(null),D(""),B(""),V(null),G(""),ne("file"),ee(""),oe(""),ce(""),Te(!0)),k(!0)},Kt=async(yt,bs)=>{bs==="file"?Ke(!0):Ee(!0);try{const gr=yt.name.split(".").pop(),Br=`${Date.now()}-${Math.random().toString(36).substring(7)}.${gr}`,na=`${bs==="file"?"items":"previews"}/${Br}`,{error:za}=await Z.storage.from("reward-store").upload(na,yt);if(za)throw za;const{data:{publicUrl:go}}=Z.storage.from("reward-store").getPublicUrl(na);bs==="file"?ee(go):oe(go),be.success("File uploaded successfully")}catch(gr){console.error("Error uploading file:",gr),be.error("Failed to upload file")}finally{bs==="file"?Ke(!1):Ee(!1)}},Xt=async()=>{if(!E.trim()){be.error("Please enter an item name");return}if(!W||parseInt(W)<0){be.error("Please enter a valid points cost");return}try{const yt={name:E,description:L||null,category_id:$,points_cost:parseInt(W),item_type:J,file_url:ie||null,preview_image_url:de||null,max_quantity:ue?parseInt(ue):null,current_quantity:ue?parseInt(ue):null,is_active:ge,created_by:t==null?void 0:t.id};M?(await it.mutateAsync({id:M.id,...yt,current_quantity:M.max_quantity!==(ue?parseInt(ue):null)?ue?parseInt(ue):null:M.current_quantity}),be.success("Item updated successfully")):(await Fe.mutateAsync(yt),be.success("Item created successfully")),k(!1)}catch(yt){console.error("Error saving item:",yt),be.error("Failed to save item")}},ss=async()=>{if(ve)try{await dt.mutateAsync(ve),be.success("Item deleted successfully"),ye(null)}catch(yt){console.error("Error deleting item:",yt),be.error("Failed to delete item")}},fs=async(yt,bs)=>{const gr=ut[yt];if(gr===void 0||gr===bs.toString())return;const Br=parseInt(gr);if(isNaN(Br)||Br<0){be.error("Please enter a valid positive number");return}try{await tt.mutateAsync({id:yt,points:Br}),be.success("Points updated successfully"),xt(na=>{const za={...na};return delete za[yt],za})}catch(na){console.error("Error updating points:",na),be.error("Failed to update points")}};return Ge||Ie||he||et?e.jsx(Vs,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{className:"h-8 w-64"}),e.jsx(ys,{className:"h-96"})]})}):e.jsxs(Vs,{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(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mc,{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:(wt==null?void 0:wt.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(wt==null?void 0:wt.filter(yt=>yt.is_active).length)||0," active"]})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(om,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(De==null?void 0:De.length)||0})]})}),e.jsx(Oe,{children:e.jsxs($e,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(qn,{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:[wt&&wt.length>0?Math.round(wt.reduce((yt,bs)=>yt+bs.points_cost,0)/wt.length):0," pts"]})]})})]}),e.jsxs(Qa,{value:s,onValueChange:r,children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"items",children:"Items"}),e.jsx(Fs,{value:"categories",children:"Categories"}),e.jsx(Fs,{value:"purchases",children:"Purchases"}),e.jsx(Fs,{value:"point-settings",children:"Point Settings"})]}),e.jsx(Zs,{value:"items",className:"mt-4",children:e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Store Items"}),e.jsx(Tr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(Y,{onClick:()=>Rt(),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx($e,{children:!wt||wt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(oo,{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(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Item"}),e.jsx(Ct,{children:"Category"}),e.jsx(Ct,{className:"text-center",children:"Cost"}),e.jsx(Ct,{className:"text-center",children:"Type"}),e.jsx(Ct,{className:"text-center",children:"Quantity"}),e.jsx(Ct,{className:"text-center",children:"Status"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:wt.map(yt=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[yt.preview_image_url?e.jsx("img",{src:yt.preview_image_url,alt:yt.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(oo,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:yt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:yt.description||"No description"})]})]})}),e.jsx(ot,{children:yt.category?e.jsx(ct,{variant:"outline",children:yt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ot,{className:"text-center",children:e.jsxs(ct,{variant:"secondary",className:"font-bold",children:[e.jsx(qn,{className:"h-3 w-3 mr-1"}),yt.points_cost]})}),e.jsx(ot,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[yt.item_type==="file"?e.jsx(Yn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ro,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:yt.item_type})]})}),e.jsx(ot,{className:"text-center",children:yt.max_quantity!==null?e.jsxs("span",{className:yt.current_quantity===0?"text-red-500":"",children:[yt.current_quantity,"/",yt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(ot,{className:"text-center",children:e.jsx(ct,{variant:yt.is_active?"default":"secondary",children:yt.is_active?"Active":"Inactive"})}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>Rt(yt),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>ye(yt.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},yt.id))})]})})]})}),e.jsx(Zs,{value:"categories",className:"mt-4",children:e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{children:"Categories"}),e.jsx(Tr,{children:"Organize your store items into categories"})]}),e.jsxs(Y,{onClick:()=>_t(),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx($e,{children:!De||De.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(om,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Name"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{className:"text-center",children:"Items"}),e.jsx(Ct,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:De.map(yt=>e.jsxs(ws,{children:[e.jsxs(ot,{className:"font-medium",children:[yt.icon&&e.jsx("span",{className:"mr-2",children:yt.icon}),yt.name]}),e.jsx(ot,{className:"text-muted-foreground",children:yt.description||"—"}),e.jsx(ot,{className:"text-center",children:(wt==null?void 0:wt.filter(bs=>bs.category_id===yt.id).length)||0}),e.jsx(ot,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>_t(yt),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>j(yt.id),children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})})]})})]},yt.id))})]})})]})}),e.jsx(Zs,{value:"purchases",className:"mt-4",children:e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Jh,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(Tr,{children:"View all reward redemptions by agents"})]}),e.jsx($e,{children:!st||st.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Jh,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Date"}),e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{children:"Item"}),e.jsx(Ct,{className:"text-center",children:"Points Spent"})]})}),e.jsx(Bn,{children:st.map(yt=>{var bs,gr,Br,na;return e.jsxs(ws,{children:[e.jsx(ot,{className:"text-muted-foreground",children:Bs(new Date(yt.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(ot,{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(Wo,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((bs=yt.user)==null?void 0:bs.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((gr=yt.user)==null?void 0:gr.email)||"—"})]})]})}),e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Br=yt.item)!=null&&Br.preview_image_url?e.jsx("img",{src:yt.item.preview_image_url,alt:yt.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(oo,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((na=yt.item)==null?void 0:na.name)||"Deleted item"})]})}),e.jsx(ot,{className:"text-center",children:e.jsxs(ct,{variant:"secondary",className:"font-bold",children:[e.jsx(qn,{className:"h-3 w-3 mr-1"}),yt.points_spent]})})]},yt.id)})})]})})]})})]})]}),e.jsx(js,{open:n,onOpenChange:a,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:o?"Edit Category":"Add Category"}),e.jsx(en,{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(je,{htmlFor:"categoryName",children:"Name"}),e.jsx(Be,{id:"categoryName",value:i,onChange:yt=>d(yt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Rr,{id:"categoryDescription",value:h,onChange:yt=>f(yt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(Be,{id:"categoryIcon",value:g,onChange:yt=>v(yt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Y,{onClick:qe,disabled:Ye.isPending||ke.isPending,children:Ye.isPending||ke.isPending?"Saving...":"Save"})]})]})}),e.jsx(js,{open:w,onOpenChange:k,children:e.jsxs(_s,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:M?"Edit Item":"Add Item"}),e.jsx(en,{children:M?"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(je,{htmlFor:"itemName",children:"Name *"}),e.jsx(Be,{id:"itemName",value:E,onChange:yt=>D(yt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Rr,{id:"itemDescription",value:L,onChange:yt=>B(yt.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(je,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(er,{value:$||"none",onValueChange:yt=>V(yt==="none"?null:yt),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select category"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No category"}),De==null?void 0:De.map(yt=>e.jsxs(Et,{value:yt.id,children:[yt.icon&&`${yt.icon} `,yt.name]},yt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(Be,{id:"itemPointsCost",type:"number",min:"0",value:W,onChange:yt=>G(yt.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(je,{htmlFor:"itemType",children:"Type"}),e.jsxs(er,{value:J,onValueChange:ne,children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"file",children:"File Download"}),e.jsx(Et,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(Be,{id:"itemMaxQuantity",type:"number",min:"1",value:ue,onChange:yt=>ce(yt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:ie,onChange:yt=>ee(yt.target.value),placeholder:J==="file"?"Upload a file or paste URL":"Paste external link"}),J==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{type:"button",variant:"outline",size:"icon",onClick:()=>{var yt;return(yt=He.current)==null?void 0:yt.click()},disabled:Se,children:e.jsx(ji,{className:"h-4 w-4"})}),e.jsx("input",{ref:He,type:"file",className:"hidden",onChange:yt=>{var gr;const bs=(gr=yt.target.files)==null?void 0:gr[0];bs&&Kt(bs,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{value:de,onChange:yt=>oe(yt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(Y,{type:"button",variant:"outline",size:"icon",onClick:()=>{var yt;return(yt=Ue.current)==null?void 0:yt.click()},disabled:Ae,children:e.jsx(fl,{className:"h-4 w-4"})}),e.jsx("input",{ref:Ue,type:"file",accept:"image/*",className:"hidden",onChange:yt=>{var gr;const bs=(gr=yt.target.files)==null?void 0:gr[0];bs&&Kt(bs,"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(ln,{id:"itemIsActive",checked:ge,onCheckedChange:Te}),e.jsx(je,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),e.jsx(Y,{onClick:Xt,disabled:Fe.isPending||it.isPending,children:Fe.isPending||it.isPending?"Saving...":"Save"})]})]})}),e.jsx(Ec,{open:!!_,onOpenChange:()=>j(null),children:e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Delete Category"}),e.jsx(cc,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:Lt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(Ec,{open:!!ve,onOpenChange:()=>ye(null),children:e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Delete Item"}),e.jsx(cc,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:ss,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Oe,{className:"mt-4",children:[e.jsx(Ht,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ic,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Gt,{children:"Point Reward Settings"}),e.jsx(Tr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx($e,{children:!We||We.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ic,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Action"}),e.jsx(Ct,{children:"Description"}),e.jsx(Ct,{className:"text-center w-32",children:"Points"}),e.jsx(Ct,{className:"text-right w-24",children:"Save"})]})}),e.jsx(Bn,{children:We.map(yt=>e.jsxs(ws,{children:[e.jsx(ot,{children:e.jsx("p",{className:"font-medium",children:yt.action_name})}),e.jsx(ot,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:yt.description})}),e.jsx(ot,{className:"text-center",children:e.jsx(Be,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:ut[yt.id]??yt.points.toString(),onChange:bs=>xt(gr=>({...gr,[yt.id]:bs.target.value}))})}),e.jsx(ot,{className:"text-right",children:e.jsx(Y,{size:"sm",variant:"outline",disabled:ut[yt.id]===void 0||ut[yt.id]===yt.points.toString()||tt.isPending,onClick:()=>fs(yt.id,yt.points),children:e.jsx(um,{className:"h-4 w-4"})})})]},yt.id))})]})})]})]})}const tPe=()=>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"})]}),sPe=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function fcs(){const t=vs(),[s,r]=T.useState(!1),[n,a]=T.useState(!1),[o,l]=T.useState(!1),[i,d]=T.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:h,isLoading:f}=zt({queryKey:["canva-integration"],queryFn:async()=>{const{data:S,error:E}=await Z.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(E)throw E;return S}}),{data:g}=zt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:S,error:E}=await Z.from("brokerages").select("id, name").order("name");if(E)throw E;return S}}),{data:v}=zt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:S,error:E}=await Z.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(E)throw E;return S}}),_=async()=>{var S;r(!0);try{const{data:E}=await Z.auth.getSession(),D=(S=E==null?void 0:E.session)==null?void 0:S.access_token;if(!D)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 ${D}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),V=await $.json();if(!$.ok||V!=null&&V.error)throw new Error((V==null?void 0:V.error)||"Failed to get authorization URL");if(V!=null&&V.authUrl){localStorage.setItem("canva_code_verifier",V.codeVerifier),localStorage.setItem("canva_oauth_state",V.state);const W=window.open(V.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!W){be.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const G=ne=>{var ie,ee;ne.origin===window.location.origin&&(((ie=ne.data)==null?void 0:ie.type)==="canva-oauth-success"?(window.removeEventListener("message",G),be.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((ee=ne.data)==null?void 0:ee.type)==="canva-oauth-error"&&(window.removeEventListener("message",G),be.error("Canva connection failed: "+(ne.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",G);const J=setInterval(()=>{W.closed&&(clearInterval(J),window.removeEventListener("message",G),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(E){console.error("Canva connect error:",E);const D=(E==null?void 0:E.message)||"";D.includes("CANVA_CLIENT_ID")?be.error("Canva app credentials not configured yet."):be.error(D||"Failed to start Canva connection"),r(!1)}},j=Wt({mutationFn:async S=>{var W;const{data:E}=await Z.auth.getSession(),D=(W=E==null?void 0:E.session)==null?void 0:W.access_token;if(!D)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 ${D}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:S})}),V=await $.json();if(!$.ok||V!=null&&V.error)throw new Error((V==null?void 0:V.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),be.success("Canva disconnected")},onError:S=>{be.error(S.message||"Failed to disconnect Canva")}}),w=Wt({mutationFn:async S=>{const{error:E}=await Z.from("canva_brokerage_folders").insert({brokerage_id:S.brokerage_id,folder_id:S.folder_id.trim(),folder_name:S.folder_name.trim(),folder_type:S.folder_type,description:S.description.trim()||null,sort_order:(v==null?void 0:v.length)||0});if(E)throw E},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),be.success("Folder added"),l(!1),d({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>be.error("Failed to add folder")}),k=Wt({mutationFn:async S=>{const{error:E}=await Z.from("canva_brokerage_folders").delete().eq("id",S);if(E)throw E},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),be.success("Folder removed")},onError:()=>be.error("Failed to remove folder")}),M=!!h;return e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{children:[e.jsx(Ht,{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(tPe,{})}),e.jsxs("div",{children:[e.jsxs(Gt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",M&&e.jsx(ct,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(ct,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(Tr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx($e,{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(yi,{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(yi,{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(yi,{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"})]}),M?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:h.canva_team_id?`Team: ${h.canva_team_id}`:"Canva Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h.expires_at?`Token expires ${new Date(h.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect Canva?"}),e.jsx(cc,{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(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:()=>j.mutate(h.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(om,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",v&&v.length>0&&e.jsx(ct,{variant:"secondary",className:"text-xs",children:v.length})]}),n?e.jsx(kx,{className:"h-4 w-4"}):e.jsx(Gc,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[v&&v.length>0?v.map(S=>{var E,D;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:S.folder_name}),e.jsx(ct,{variant:"outline",className:"text-xs shrink-0",children:((E=sPe.find(L=>L.value===S.folder_type))==null?void 0:E.label)||S.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(D=S.brokerages)==null?void 0:D.name," · ID: ",e.jsx("span",{className:"font-mono",children:S.folder_id})]})]}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>k.mutate(S.id),children:e.jsx(Xr,{className:"h-3.5 w-3.5"})})]},S.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(Y,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx(ar,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(Y,{className:"mt-4",onClick:_,disabled:s||f,children:[s?e.jsx(el,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(tPe,{})}),"Connect Canva",e.jsx(qi,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(js,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{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(je,{children:"Brokerage"}),e.jsxs(er,{value:i.brokerage_id,onValueChange:S=>d(E=>({...E,brokerage_id:S})),children:[e.jsx(Qs,{children:e.jsx(tr,{placeholder:"Select a brokerage…"})}),e.jsx(Js,{children:g==null?void 0:g.map(S=>e.jsx(Et,{value:S.id,children:S.name},S.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{children:"Canva Folder ID"}),e.jsx(Be,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:S=>d(E=>({...E,folder_id:S.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{children:"Folder Display Name"}),e.jsx(Be,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:S=>d(E=>({...E,folder_name:S.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{children:"Folder Type"}),e.jsxs(er,{value:i.folder_type,onValueChange:S=>d(E=>({...E,folder_type:S})),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:sPe.map(S=>e.jsx(Et,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(je,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(Be,{placeholder:"What's in this folder?",value:i.description,onChange:S=>d(E=>({...E,description:S.target.value}))})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(Y,{onClick:()=>w.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||w.isPending,children:[w.isPending?e.jsx(el,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function gcs(){return e.jsx(Vs,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(Yu,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(fcs,{})]})})}const xcs={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 UA(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function ycs(){var J,ne,ie,ee,de;const t=vs(),[s,r]=T.useState("Test Push"),[n,a]=T.useState("Testing web push notification"),[o,l]=T.useState("/community"),[i,d]=T.useState(!1),[h,f]=T.useState(!1),[g,v]=T.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,j]=T.useState(null),[w,k]=T.useState(null),{data:M,isLoading:S}=zt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:oe,error:ue}=await Z.from("push_notification_settings").select("*").order("setting_key");if(ue)throw ue;return oe}}),{data:E,isLoading:D}=zt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:oe,error:ue}=await Z.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ue)throw ue;return{totalSubscriptions:oe||0}}}),L=Wt({mutationFn:async({settingKey:oe,isEnabled:ue})=>{const{error:ce}=await Z.from("push_notification_settings").update({is_enabled:ue}).eq("setting_key",oe);if(ce)throw ce},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),be.success("Notification setting updated")},onError:oe=>{be.error("Failed to update setting: "+oe.message)}}),B=T.useMemo(()=>{var oe,ue;return g.isSupported?`perm=${g.permission??"unknown"} · controller=${g.controllerPresent?"yes":"no"} · sw=${((oe=g.serviceWorker)==null?void 0:oe.activeState)??"unknown"} · sub=${(ue=g.subscription)!=null&&ue.endpoint?"yes":"no"}`:"Push not supported in this browser."},[g]);T.useEffect(()=>{let oe=!0;const ue=async()=>{var ve,ye,Se,Ke,Ae,Ee,He;const ge="serviceWorker"in navigator&&"PushManager"in window,Te={isSupported:ge,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ve=navigator.serviceWorker)!=null&&ve.controller)};if(!ge){oe&&v(Te);return}try{const{data:Ue,error:De}=await Z.functions.invoke("get-vapid-public-key",{body:{}});if(De)throw De;Te.vapidPublicKey=Ue==null?void 0:Ue.vapidPublicKey;const wt=(await navigator.serviceWorker.getRegistrations()).find(Ie=>{var he,We,et;return(((he=Ie.active)==null?void 0:he.scriptURL)||((We=Ie.waiting)==null?void 0:We.scriptURL)||((et=Ie.installing)==null?void 0:et.scriptURL)||"").includes("/sw.js")});if(wt){Te.pushWorkerScriptUrl=((ye=wt.active)==null?void 0:ye.scriptURL)||((Se=wt.waiting)==null?void 0:Se.scriptURL)||((Ke=wt.installing)==null?void 0:Ke.scriptURL),Te.serviceWorker={scope:wt.scope,activeState:(Ae=wt.active)==null?void 0:Ae.state};const Ie=await wt.pushManager.getSubscription();if(Ie){const st=Ie.toJSON();Te.subscription={endpoint:st.endpoint,p256dh:(Ee=st.keys)==null?void 0:Ee.p256dh,auth:(He=st.keys)==null?void 0:He.auth}}}}catch(Ue){Te.error=(Ue==null?void 0:Ue.message)||String(Ue)}oe&&v(Te)};ue();const ce=window.setInterval(ue,4e3);return()=>{oe=!1,window.clearInterval(ce)}},[]);const $=async()=>{if(typeof Notification>"u"){be.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){be.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),be.success("Triggered a local notification (not push).")}catch(oe){be.error(`Local notification failed: ${(oe==null?void 0:oe.message)||String(oe)}`)}},V=async()=>{d(!0),j(null);try{const{data:oe,error:ue}=await Z.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ue)throw ue;j({sent:oe==null?void 0:oe.sent,failed:oe==null?void 0:oe.failed,expiredCleaned:oe==null?void 0:oe.expiredCleaned,vapidPublicKey:oe==null?void 0:oe.vapidPublicKey}),(oe==null?void 0:oe.sent)>0?be.success(`Test notification sent to ${oe.sent} subscriber(s)`):(oe==null?void 0:oe.failed)>0?be.warning(`Notification failed for ${oe.failed} subscriber(s). ${oe.expired||0} expired subscriptions cleaned up.`):be.info("No active subscriptions to send to")}catch(oe){console.error("Error sending test notification:",oe),j({error:(oe==null?void 0:oe.message)||String(oe)}),be.error("Failed to send test notification: "+(oe.message||"Unknown error"))}finally{d(!1)}},W=async()=>{f(!0),k(null);try{const{data:oe,error:ue}=await Z.functions.invoke("generate-vapid-keys",{body:{}});if(ue)throw ue;const ce=oe==null?void 0:oe.publicKey,ge=oe==null?void 0:oe.privateKey;if(!ce||!ge)throw new Error("generate-vapid-keys did not return keys");k({publicKey:ce,privateKey:ge}),be.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(oe){console.error("Error generating VAPID keys:",oe),be.error("Failed to generate VAPID keys: "+((oe==null?void 0:oe.message)||"Unknown error"))}finally{f(!1)}},G=Wt({mutationFn:async()=>{const{error:oe}=await Z.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(oe)throw oe},onSuccess:()=>{be.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:oe=>{be.error("Failed to clear subscriptions: "+oe.message)}});return e.jsx(Vs,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Yu,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(Tr,{children:"Current active push notification subscriptions"})]}),e.jsx($e,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:D?"...":(E==null?void 0:E.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Ic,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(Tr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx($e,{children:S?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:M==null?void 0:M.map(oe=>{const ue=xcs[oe.setting_key]||{label:oe.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:ue.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ue.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:oe.description})]})]}),e.jsx(ln,{checked:oe.is_enabled,onCheckedChange:ce=>L.mutate({settingKey:oe.setting_key,isEnabled:ce}),disabled:L.isPending})]},oe.id)})})})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(dg,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(Tr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs($e,{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:B}),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?UA(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: ",(J=g.serviceWorker)!=null&&J.scope?UA(g.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((ne=g.serviceWorker)==null?void 0:ne.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: ",(ie=g.subscription)!=null&&ie.endpoint?UA(g.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(ee=g.subscription)!=null&&ee.p256dh?UA(g.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(de=g.subscription)!=null&&de.auth?UA(g.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(Y,{variant:"outline",onClick:$,children:"Local notification test"}),e.jsx(Y,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(Be,{id:"test-title",value:s,onChange:oe=>r(oe.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Rr,{id:"test-body",value:n,onChange:oe=>a(oe.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(Be,{id:"test-url",value:o,onChange:oe=>l(oe.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(Y,{onClick:V,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(Wa,{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(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Ir,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(Tr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs($e,{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(Y,{variant:"destructive",onClick:()=>G.mutate(),disabled:G.isPending,children:[e.jsx(Ir,{className:"h-4 w-4 mr-2"}),G.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(Y,{variant:"outline",onClick:W,disabled:h,children:h?"Generating…":"Generate VAPID keys"})}),w&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.privateKey})]})]})]})]})]})]})})}function vcs(){const{toast:t}=Sa(),[s,r]=T.useState([]),[n,a]=T.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=T.useState(!0);T.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:h,error:f}=await Z.rpc("get_admin_presentation_stats");if(f)throw f;if(!h||h.length===0){l(!1);return}const g=h.map(k=>k.owner_user_id),{data:v,error:_}=await Z.from("profiles").select("id, name, email, avatar_url").in("id",g);if(_)throw _;const j=new Map((v==null?void 0:v.map(k=>[k.id,k]))||[]),w=h.map(k=>{const M=j.get(k.owner_user_id);return{owner_user_id:k.owner_user_id,name:(M==null?void 0:M.name)||"Unknown",email:(M==null?void 0:M.email)||"",avatar_url:(M==null?void 0:M.avatar_url)||null,presentation_count:Number(k.presentation_count),total_views:Number(k.total_views),total_leads:Number(k.total_leads),total_cta_clicks:Number(k.total_cta_clicks)}});w.sort((k,M)=>M.presentation_count-k.presentation_count),r(w),a({totalPresentations:w.reduce((k,M)=>k+M.presentation_count,0),totalViews:w.reduce((k,M)=>k+M.total_views,0),totalLeads:w.reduce((k,M)=>k+M.total_leads,0),totalCtaClicks:w.reduce((k,M)=>k+M.total_cta_clicks,0),agentsUsing:w.length})}catch(h){console.error("Error loading presentation stats:",h),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:br,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Gp,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:wi,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:Zc,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:A1,color:"text-rose-600"}];return e.jsx(Vs,{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:d.map(h=>e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:h.label}),e.jsx(h.icon,{className:`h-4 w-4 ${h.color}`})]}),e.jsx($e,{children:o?e.jsx(ys,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:h.value.toLocaleString()})})]},h.label))}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Jd,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx($e,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((h,f)=>e.jsx(ys,{className:"h-12 w-full"},f))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{className:"text-center",children:"Presentations"}),e.jsx(Ct,{className:"text-center",children:"Views"}),e.jsx(Ct,{className:"text-center",children:"Leads"}),e.jsx(Ct,{className:"text-center",children:"CTA Clicks"}),e.jsx(Ct,{className:"text-center",children:"Conversion"})]})}),e.jsx(Bn,{children:s.map(h=>{var g,v;const f=h.total_views>0?(h.total_leads/h.total_views*100).toFixed(1):"0.0";return e.jsxs(ws,{children:[e.jsx(ot,{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:h.avatar_url?e.jsx("img",{src:h.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((v=(g=h.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:h.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:h.email})]})]})}),e.jsx(ot,{className:"text-center font-medium",children:h.presentation_count}),e.jsx(ot,{className:"text-center",children:h.total_views.toLocaleString()}),e.jsx(ot,{className:"text-center",children:h.total_leads>0?e.jsx(ct,{variant:"secondary",children:h.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ot,{className:"text-center",children:h.total_cta_clicks}),e.jsx(ot,{className:"text-center",children:e.jsxs("span",{className:Number(f)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[f,"%"]})})]},h.owner_user_id)})})]})})]})]})})}function _cs(){const{toast:t}=Sa(),[s,r]=T.useState([]),[n,a]=T.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=T.useState(!0);T.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:h,error:f}=await Z.rpc("get_admin_guest_book_stats");if(f)throw f;if(!h||h.length===0){l(!1);return}const g=h.map(k=>k.agent_id),{data:v,error:_}=await Z.from("profiles").select("id, name, email, avatar_url").in("id",g);if(_)throw _;const j=new Map((v==null?void 0:v.map(k=>[k.id,k]))||[]),w=h.map(k=>{const M=j.get(k.agent_id);return{agent_id:k.agent_id,name:(M==null?void 0:M.name)||"Unknown",email:(M==null?void 0:M.email)||"",avatar_url:(M==null?void 0:M.avatar_url)||null,open_house_count:Number(k.open_house_count),total_visitors:Number(k.total_visitors),total_leads:Number(k.total_leads),active_count:Number(k.active_count)}});w.sort((k,M)=>M.total_visitors-k.total_visitors),r(w),a({totalOpenHouses:w.reduce((k,M)=>k+M.open_house_count,0),totalVisitors:w.reduce((k,M)=>k+M.total_visitors,0),totalLeads:w.reduce((k,M)=>k+M.total_leads,0),activeOpenHouses:w.reduce((k,M)=>k+M.active_count,0),agentsUsing:w.length})}catch(h){console.error("Error loading guest book stats:",h),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:br,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Zn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:yi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:wi,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:Zc,color:"text-rose-600"}];return e.jsx(Vs,{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(h=>e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Gt,{className:"text-sm font-medium",children:h.label}),e.jsx(h.icon,{className:`h-4 w-4 ${h.color}`})]}),e.jsx($e,{children:o?e.jsx(ys,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:h.value.toLocaleString()})})]},h.label))}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(Jd,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx($e,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((h,f)=>e.jsx(ys,{className:"h-12 w-full"},f))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{children:"Agent"}),e.jsx(Ct,{className:"text-center",children:"Open Houses"}),e.jsx(Ct,{className:"text-center",children:"Active"}),e.jsx(Ct,{className:"text-center",children:"Visitors"}),e.jsx(Ct,{className:"text-center",children:"Leads"}),e.jsx(Ct,{className:"text-center",children:"Conversion"})]})}),e.jsx(Bn,{children:s.map(h=>{var g,v;const f=h.total_visitors>0?(h.total_leads/h.total_visitors*100).toFixed(1):"0.0";return e.jsxs(ws,{children:[e.jsx(ot,{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:h.avatar_url?e.jsx("img",{src:h.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((v=(g=h.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:h.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:h.email})]})]})}),e.jsx(ot,{className:"text-center font-medium",children:h.open_house_count}),e.jsx(ot,{className:"text-center",children:h.active_count>0?e.jsx(ct,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:h.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ot,{className:"text-center",children:h.total_visitors.toLocaleString()}),e.jsx(ot,{className:"text-center",children:h.total_leads>0?e.jsx(ct,{variant:"secondary",children:h.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ot,{className:"text-center",children:e.jsxs("span",{className:Number(f)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[f,"%"]})})]},h.agent_id)})})]})})]})]})})}function bcs(){const[t]=Oc(),s=Yr(),[r,n]=T.useState("loading"),[a,o]=T.useState("Processing connection...");return T.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),h=t.get("error_description"),f=t.get("state");if(d){n("error"),o(h||"Authorization was denied"),be.error("Failed to connect: "+(h||d));return}if(!i){n("error"),o("No authorization code received"),be.error("Failed to connect: No authorization code");return}try{const{data:g,error:v}=await Z.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:f}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Accounts connected successfully!"),be.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"),be.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(Oe,{className:"w-full max-w-md",children:[e.jsxs(Ht,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(Us,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(yi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(Cc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Gt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(Tr,{children:a})]}),e.jsx($e,{className:"flex justify-center",children:e.jsx(Y,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function wcs(){const t=vs(),[s,r]=T.useState(""),[n,a]=T.useState(""),[o,l]=T.useState([]),i=T.useRef(null),{data:d,isLoading:h}=zt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:k,error:M}=await Z.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(M)throw M;return k}}),f={total:(d==null?void 0:d.length)||0,sent:(d==null?void 0:d.filter(k=>k.status==="sent").length)||0,converted:(d==null?void 0:d.filter(k=>k.status==="converted").length)||0,conversionRate:d!=null&&d.length?Math.round(d.filter(k=>k.status==="converted").length/d.length*100):0},g=Wt({mutationFn:async k=>{const{data:M,error:S}=await Z.functions.invoke("send-prospect-email",{body:{emails:k}});if(S)throw S;return M},onSuccess:k=>{t.invalidateQueries({queryKey:["prospect-emails"]}),be.success(`${k.sent} email${k.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:k=>{be.error("Failed to send: "+k.message)}}),v=Wt({mutationFn:async()=>{var E,D;const{data:{user:k}}=await Z.auth.getUser();if(!(k!=null&&k.email))throw new Error("Could not get your email");const{data:M,error:S}=await Z.functions.invoke("send-prospect-email",{body:{emails:[{email:k.email,first_name:(D=(E=k.user_metadata)==null?void 0:E.name)==null?void 0:D.split(" ")[0]}],test_mode:!0}});if(S)throw S;return M},onSuccess:()=>{be.success("Test email sent to your inbox!")},onError:k=>{be.error("Failed to send test: "+k.message)}}),_=()=>{if(!s.trim()){be.error("Please enter an email address");return}if(d==null?void 0:d.find(M=>M.email.toLowerCase()===s.trim().toLowerCase())){be.error("This email has already been prospected");return}g.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},j=k=>{var E;const M=(E=k.target.files)==null?void 0:E[0];if(!M)return;const S=new FileReader;S.onload=D=>{var W,G;const B=((W=D.target)==null?void 0:W.result).split(` `).filter(J=>J.trim()),$=[],V=(G=B[0])!=null&&G.toLowerCase().includes("email")?1:0;for(let J=V;Jde.trim().replace(/"/g,"")),ie=ne[0],ee=ne[1];ie&&ie.includes("@")&&$.push({email:ie,first_name:ee||void 0})}l($),be.success(`${$.length} entries loaded from CSV`)},S.readAsText(M),i.current&&(i.current.value="")},w=()=>{if(o.length===0){be.error("No entries to send");return}const k=new Set((d==null?void 0:d.map(S=>S.email.toLowerCase()))||[]),M=o.filter(S=>!k.has(S.email.toLowerCase()));if(M.length===0){be.error("All emails have already been prospected");return}M.lengthv.mutate(),disabled:v.isPending,className:"gap-2 ml-4 shrink-0",children:[v.isPending?e.jsx(Us,{className:"h-3 w-3 animate-spin"}):e.jsx(zr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx($e,{children:e.jsxs(Qa,{defaultValue:"single",children:[e.jsxs(Ga,{className:"mb-4",children:[e.jsxs(Fs,{value:"single",children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(Fs,{value:"bulk",children:[e.jsx(ji,{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(je,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(Be,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:k=>r(k.target.value),onKeyDown:k=>k.key==="Enter"&&_()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(je,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(Be,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:k=>a(k.target.value),onKeyDown:k=>k.key==="Enter"&&_()})]}),e.jsxs(Y,{onClick:_,disabled:g.isPending,className:"gap-2",children:[g.isPending?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(Wa,{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:j,className:"hidden"}),e.jsxs(Y,{variant:"outline",onClick:()=>{var k;return(k=i.current)==null?void 0:k.click()},className:"gap-2",children:[e.jsx(Yn,{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(ct,{variant:"secondary",className:"gap-1",children:[e.jsx(br,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Xr,{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((k,M)=>e.jsxs("div",{className:"text-muted-foreground",children:[k.email,k.first_name?` — ${k.first_name}`:""]},M)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(Y,{onClick:w,disabled:g.isPending,className:"gap-2",children:[g.isPending?e.jsx(Us,{className:"h-4 w-4 animate-spin"}):e.jsx(Wa,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{children:[e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(zr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(Tr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx($e,{children:h?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((k,M)=>e.jsx(ys,{className:"h-12 w-full"},M))}):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(k=>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:k.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:k.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:Bs(new Date(k.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:k.status==="converted"?e.jsxs(ct,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(oi,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(ct,{variant:"secondary",className:"gap-1",children:[e.jsx(ca,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:k.converted_at?Bs(new Date(k.converted_at),"MMM d, yyyy"):"—"})]},k.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(hm,{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 $le(t){const s=vs(),{toast:r}=Sa(),n=zt({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:d,error:h}=await Z.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(h)throw h;return d},enabled:!!t}),a=zt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const{data:d,error:h}=await Z.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(h)throw h;return d},enabled:!!t}),o=Wt({mutationFn:async d=>{const{data:{user:h}}=await Z.auth.getUser();if(!h)throw new Error("Not authenticated");const f={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:h.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 Z.from("recruit_prospects").insert(f).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=Wt({mutationFn:async({id:d,...h})=>{const{data:f,error:g}=await Z.from("recruit_prospects").update({...h,updated_at:new Date().toISOString()}).eq("id",d).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),i=Wt({mutationFn:async d=>{const{error:h}=await Z.from("recruit_prospects").delete().eq("id",d);if(h)throw h},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 jcs(t){const s=vs(),{toast:r}=Sa(),n=zt({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await Z.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Wt({mutationFn:async o=>{const{data:{user:l}}=await Z.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:d}=await Z.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 rPe=(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 aYe({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=T.useState(rPe(n,r)),d=f=>g=>i(v=>({...v,[f]:g.target.value})),h=f=>{f.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(rPe(n,r)),s(!1)};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:h,className:"space-y-4",children:[e.jsxs(Qa,{defaultValue:"basic",className:"w-full",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-4",children:[e.jsx(Fs,{value:"basic",children:"Basic Info"}),e.jsx(Fs,{value:"production",children:"Production"}),e.jsx(Fs,{value:"social",children:"Social & Web"}),e.jsx(Fs,{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(je,{children:"First Name *"}),e.jsx(Be,{required:!0,value:l.first_name,onChange:d("first_name")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Last Name"}),e.jsx(Be,{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(je,{children:"Email"}),e.jsx(Be,{type:"email",value:l.email,onChange:d("email")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Phone"}),e.jsx(Be,{value:l.phone,onChange:d("phone")})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Current Brokerage"}),e.jsx(Be,{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(je,{children:"License #"}),e.jsx(Be,{value:l.license_number,onChange:d("license_number")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Experience (years)"}),e.jsx(Be,{type:"number",min:"0",value:l.experience_years,onChange:d("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Address"}),e.jsx(Be,{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(je,{children:"City"}),e.jsx(Be,{value:l.city,onChange:d("city")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"State"}),e.jsx(Be,{value:l.state,onChange:d("state")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Zip"}),e.jsx(Be,{value:l.zip_code,onChange:d("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Pipeline Stage"}),e.jsxs(er,{value:l.stage_id,onValueChange:f=>i(g=>({...g,stage_id:f})),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:r.map(f=>e.jsx(Et,{value:f.id,children:f.name},f.id))})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Referred By"}),e.jsx(Be,{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(je,{children:"Annual Production Volume"}),e.jsx(Be,{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(je,{children:"Last Year Volume"}),e.jsx(Be,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:d("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Last Year Transactions"}),e.jsx(Be,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:d("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Avg Sale Price"}),e.jsx(Be,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:d("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Specialties / Niche"}),e.jsx(Be,{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(je,{children:"LinkedIn URL"}),e.jsx(Be,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:d("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Website URL"}),e.jsx(Be,{type:"url",placeholder:"https://...",value:l.website_url,onChange:d("website_url")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Instagram Handle"}),e.jsx(Be,{placeholder:"@handle",value:l.instagram_handle,onChange:d("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Facebook URL"}),e.jsx(Be,{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(je,{children:"Birthday"}),e.jsx(Be,{type:"date",value:l.birthday,onChange:d("birthday")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Spouse / Partner Name"}),e.jsx(Be,{value:l.spouse_name,onChange:d("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Interests / Hobbies"}),e.jsx(Be,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:d("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Notes"}),e.jsx(Rr,{value:l.notes,onChange:d("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const Nye=[{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 kcs(t){return zt({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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 Ncs(t){return zt({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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 Scs(){const t=vs(),{toast:s}=Sa();return Wt({mutationFn:async r=>{const{data:{user:n}}=await Z.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await Z.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 iYe(){const t=vs();return Wt({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await Z.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 oYe(t){return zt({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await Z.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 Ccs(){const t=vs(),{toast:s}=Sa();return Wt({mutationFn:async r=>{const{data:{user:n}}=await Z.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await Z.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 Mcs(){const t=vs();return Wt({mutationFn:async s=>{const{error:r}=await Z.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function Tcs({prospectId:t,prospectName:s,brokerageId:r}){var W;const{data:n=[],isLoading:a}=Ncs(t),{data:o=[]}=oYe(r),l=Scs(),i=TN(),d=iYe(),[h,f]=T.useState("idle"),[g,v]=T.useState(0),[_,j]=T.useState(0),[w,k]=T.useState(""),[M,S]=T.useState(""),[E,D]=T.useState(!1),L=((W=o.find(G=>G.id===w))==null?void 0:W.script_text)||"",B=()=>{f("idle"),v(0),j(0),k(""),S("")},$=T.useCallback(async(G,J)=>{f("uploading");try{const ne=`Recruiting: ${s}`,{videoId:ie,libraryId:ee}=await sL(ne),{uploadUrl:de,apiKey:oe}=await rL(ie),ue=new XMLHttpRequest;ue.upload.onprogress=Ae=>{Ae.lengthComputable&&v(Ae.loaded/Ae.total*100)},await new Promise((Ae,Ee)=>{ue.onload=()=>ue.status>=200&&ue.status<300?Ae():Ee(new Error("Upload failed")),ue.onerror=()=>Ee(new Error("Upload failed")),ue.open("PUT",de),ue.setRequestHeader("AccessKey",oe),ue.send(G)}),f("processing");let ce=0;const ge=Date.now(),Te=9e4,ve=`https://iframe.mediadelivery.net/embed/${ee}/${ie}`;for(;ce<4&&(await new Promise(Ee=>setTimeout(Ee,3e3)),!(Date.now()-ge>Te));){const Ae=await X5(ie);if(ce=Ae.status,j(Ae.encodeProgress||0),ce===5||ce===6)throw new Error("Video processing failed")}const ye=await X5(ie),Se=(ye.storageSize||G.size)/(1024*1024),Ke=await i.mutateAsync({bunny_video_id:ie,playback_url:ye.directPlayUrl||ve,thumbnail_url:ye.thumbnailUrl,preview_url:ye.previewUrl||null,duration_seconds:ye.length||J,file_size_mb:Se,title:ne,status:ce>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ke.id,brokerage_id:r,message:M||void 0}),f("done"),be.success("Video recorded and linked to prospect!"),setTimeout(()=>{D(!1),B()},1500)}catch(ne){be.error(ne.message||"Failed to upload video"),f("record")}},[t,s,r,M,i,l]),V=G=>{G&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${G}`),be.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(Wn,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(js,{open:E,onOpenChange:G=>{!G&&(h==="uploading"||h==="processing")||(D(G),G||B())},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>f("script"),children:[e.jsx(ar,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(_s,{className:"max-w-2xl",children:[e.jsx(Ls,{children:e.jsxs(Ps,{children:["Record Video for ",s]})}),h==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(er,{value:w,onValueChange:k,children:[e.jsx(Qs,{className:"mt-1",children:e.jsx(tr,{placeholder:"No script — speak freely"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"none",children:"No script"}),o.map(G=>{var J;return e.jsx(Et,{value:G.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[G.title,e.jsx(ct,{variant:"outline",className:"text-[9px] ml-1",children:(J=Nye.find(ne=>ne.value===G.category))==null?void 0:J.label})]})},G.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(je,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Rr,{value:M,onChange:G=>S(G.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(Y,{onClick:()=>f("record"),className:"w-full",children:[e.jsx(Wn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),h==="record"&&e.jsx(zle,{maxDurationSeconds:60,onRecordingComplete:$,teleprompterContent:L||void 0}),h==="uploading"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Uploading video…"}),e.jsx(rl,{value:g,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(g),"%"]})]}),h==="processing"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Processing video…"}),e.jsx(rl,{value:_,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(_),"%"]})]}),h==="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(Kl,{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(G=>{var J,ne;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:(J=G.video)!=null&&J.thumbnail_url?e.jsx("img",{src:G.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(Wn,{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:((ne=G.video)==null?void 0:ne.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[G.view_count>0?e.jsxs(ct,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(wi,{className:"h-2.5 w-2.5 mr-0.5"}),G.view_count]}):G.sent_at?e.jsxs(ct,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Wa,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(ct,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(ca,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Bs(new Date(G.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>V(G.share_token),children:e.jsx(Di,{className:"h-3 w-3"})}),!G.sent_at&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:G.id,sent_via:"email"}),children:e.jsx(Wa,{className:"h-3 w-3"})})]})]},G.id)})})]})}const nPe=[{value:"call",label:"Phone Call",icon:Ha},{value:"email",label:"Email",icon:zr},{value:"text",label:"Text Message",icon:Eo},{value:"meeting",label:"Meeting",icon:xn},{value:"note",label:"Note",icon:Yn}];function Am({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 P8({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(bn,{className:"h-3 w-3 opacity-50"})]}):null}function Ml({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:t}),e.jsx(Be,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function lYe({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:d}=jcs((t==null?void 0:t.id)||null),[h,f]=T.useState({type:"note",title:"",description:""}),[g,v]=T.useState(!1),[_,j]=T.useState(!1),[w,k]=T.useState({});if(!t)return null;const M=()=>{var J,ne;k({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:((J=t.experience_years)==null?void 0:J.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:((ne=t.last_year_transactions)==null?void 0:ne.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||""}),j(!0)},S=()=>{const J={id:t.id};for(const[ne,ie]of Object.entries(w))ne==="experience_years"||ne==="last_year_transactions"?J[ne]=ie?parseInt(ie):null:J[ne]=ie||null;o(J),j(!1)},E=()=>j(!1),D=J=>ne=>k(ie=>({...ie,[J]:ne})),L=()=>{h.title.trim()&&(d.mutate({prospect_id:t.id,activity_type:h.type,title:h.title,description:h.description||null}),f({type:"note",title:"",description:""}),v(!1))},B=s.find(J=>J.id===t.stage_id),$=t.address||t.city||t.state,V=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,W=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,G=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(z6,{open:n,onOpenChange:J=>{J||j(!1),a(J)},children:e.jsx(q3,{className:"w-full sm:max-w-lg p-0",children:e.jsx(po,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(B6,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs($6,{className:"text-xl",children:[t.first_name," ",t.last_name]}),B&&e.jsx(ct,{variant:"outline",style:{borderColor:B.color,color:B.color},className:"mt-1",children:B.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:E,children:e.jsx(Xr,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"default",size:"icon",onClick:S,children:e.jsx(um,{className:"h-4 w-4"})})]}):e.jsx(Y,{variant:"ghost",size:"icon",onClick:M,title:"Edit prospect",children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Delete prospect?"}),e.jsx(cc,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{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(zr,{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(Ha,{className:"h-3.5 w-3.5"})," ",t.phone]}),$&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Gi,{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(je,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(er,{value:t.stage_id||"",onValueChange:J=>o({id:t.id,stage_id:J}),children:[e.jsx(Qs,{className:"mt-1",children:e.jsx(tr,{})}),e.jsx(Js,{children:s.map(J=>e.jsx(Et,{value:J.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:J.color}}),J.name]})},J.id))})]})]}),e.jsxs(Qa,{defaultValue:"details",className:"w-full",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(Fs,{value:"details",className:"text-xs",children:"Details"}),e.jsx(Fs,{value:"production",className:"text-xs",children:"Production"}),e.jsx(Fs,{value:"social",className:"text-xs",children:"Social"}),e.jsx(Fs,{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(Ml,{label:"First Name",value:w.first_name,onChange:D("first_name")}),e.jsx(Ml,{label:"Last Name",value:w.last_name,onChange:D("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ml,{label:"Email",value:w.email,onChange:D("email"),type:"email"}),e.jsx(Ml,{label:"Phone",value:w.phone,onChange:D("phone")})]}),e.jsx(Ml,{label:"Current Brokerage",value:w.current_brokerage,onChange:D("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ml,{label:"License #",value:w.license_number,onChange:D("license_number")}),e.jsx(Ml,{label:"Experience (years)",value:w.experience_years,onChange:D("experience_years"),type:"number"})]}),e.jsx(Ml,{label:"Address",value:w.address,onChange:D("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Ml,{label:"City",value:w.city,onChange:D("city")}),e.jsx(Ml,{label:"State",value:w.state,onChange:D("state")}),e.jsx(Ml,{label:"Zip",value:w.zip_code,onChange:D("zip_code")})]}),e.jsx(Ml,{label:"Source",value:w.source,onChange:D("source")}),e.jsx(Ml,{label:"Referred By",value:w.referred_by,onChange:D("referred_by")}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:"Notes"}),e.jsx(Rr,{value:w.notes,onChange:J=>k(ne=>({...ne,notes:J.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(Zs,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Ml,{label:"Annual Production",value:w.annual_production,onChange:D("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ml,{label:"Last Year Volume",value:w.last_year_volume,onChange:D("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Ml,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:D("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Ml,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:D("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Ml,{label:"Specialties / Niche",value:w.specialties,onChange:D("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(Zs,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Ml,{label:"LinkedIn URL",value:w.linkedin_url,onChange:D("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Ml,{label:"Website URL",value:w.website_url,onChange:D("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Ml,{label:"Instagram Handle",value:w.instagram_handle,onChange:D("instagram_handle"),placeholder:"@handle"}),e.jsx(Ml,{label:"Facebook URL",value:w.facebook_url,onChange:D("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(Zs,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(Ml,{label:"Birthday",value:w.birthday,onChange:D("birthday"),type:"date"}),e.jsx(Ml,{label:"Spouse / Partner",value:w.spouse_name,onChange:D("spouse_name")}),e.jsx(Ml,{label:"Interests / Hobbies",value:w.interests,onChange:D("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(Am,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Am,{label:"License #",value:t.license_number}),e.jsx(Am,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Am,{label:"Referred By",value:t.referred_by}),e.jsx(Am,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(je,{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:V?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Am,{label:"Annual Production",value:t.annual_production}),e.jsx(Am,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Am,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Am,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Am,{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:W?e.jsxs("div",{className:"space-y-2",children:[e.jsx(P8,{label:"LinkedIn",url:t.linkedin_url,icon:cm}),e.jsx(P8,{label:"Website",url:t.website_url,icon:pg}),t.instagram_handle&&e.jsx(P8,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:vu}),e.jsx(P8,{label:"Facebook",url:t.facebook_url,icon:Qd})]}):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:G?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Am,{label:"Birthday",value:t.birthday?Bs(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:oo}),e.jsx(Am,{label:"Spouse / Partner",value:t.spouse_name,icon:Ti}),e.jsx("div",{className:"col-span-2",children:e.jsx(Am,{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(Tcs,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(ud,{}),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(Y,{size:"sm",variant:"outline",onClick:()=>v(!g),children:[e.jsx(ar,{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(er,{value:h.type,onValueChange:J=>f(ne=>({...ne,type:J})),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:nPe.map(J=>e.jsx(Et,{value:J.value,children:J.label},J.value))})]}),e.jsx(Be,{placeholder:"Subject / Title",value:h.title,onChange:J=>f(ne=>({...ne,title:J.target.value}))}),e.jsx(Rr,{placeholder:"Details (optional)",value:h.description,onChange:J=>f(ne=>({...ne,description:J.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"Cancel"}),e.jsx(Y,{size:"sm",onClick:L,disabled:!h.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(J=>{const ne=nPe.find(ee=>ee.value===J.activity_type),ie=(ne==null?void 0:ne.icon)||Yn;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(ie,{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:J.title}),J.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:J.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Bs(new Date(J.created_at),"MMM d, yyyy h:mm a")})]})]},J.id)})]})]})]})})})})}const aPe=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes"];function cYe({open:t,onOpenChange:s,brokerageId:r,stages:n}){var G;const{toast:a}=Sa(),o=vs(),l=T.useRef(null),[i,d]=T.useState([]),[h,f]=T.useState([]),[g,v]=T.useState({}),[_,j]=T.useState(((G=n[0])==null?void 0:G.id)||""),[w,k]=T.useState(!1),[M,S]=T.useState("upload"),[E,D]=T.useState(0),L=()=>{d([]),f([]),v({}),S("upload"),D(0)},B=J=>{var ee;const ne=(ee=J.target.files)==null?void 0:ee[0];if(!ne)return;const ie=new FileReader;ie.onload=de=>{var ve;const ue=((ve=de.target)==null?void 0:ve.result).split(/\r?\n/).filter(ye=>ye.trim());if(ue.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const ce=$(ue[0]);f(ce);const ge={};ce.forEach((ye,Se)=>{const Ke=ye.toLowerCase().replace(/[^a-z]/g,"_").replace(/_+/g,"_"),Ae=aPe.find(Ee=>Ke.includes(Ee)||Ee.includes(Ke)||Ee==="first_name"&&(Ke.includes("first")||Ke==="name")||Ee==="last_name"&&Ke.includes("last")||Ee==="current_brokerage"&&(Ke.includes("brokerage")||Ke.includes("company"))||Ee==="license_number"&&Ke.includes("license")||Ee==="experience_years"&&(Ke.includes("experience")||Ke.includes("years"))||Ee==="annual_production"&&(Ke.includes("production")||Ke.includes("volume")));Ae&&(ge[String(Se)]=Ae)}),v(ge);const Te=ue.slice(1).map(ye=>{const Se=$(ye),Ke={};return ce.forEach((Ae,Ee)=>{Ke[String(Ee)]=Se[Ee]||""}),Ke});d(Te),S("map")},ie.readAsText(ne)},$=J=>{const ne=[];let ie="",ee=!1;for(const de of J)de==='"'?ee=!ee:de===","&&!ee?(ne.push(ie.trim()),ie=""):ie+=de;return ne.push(ie.trim()),ne},V=async()=>{k(!0);try{const{data:{user:J}}=await Z.auth.getUser();if(!J)throw new Error("Not authenticated");const ne=i.map(ee=>{const de={brokerage_id:r,created_by:J.id,stage_id:_,source:"csv_import",first_name:"Unknown"};return Object.entries(g).forEach(([oe,ue])=>{var ge;const ce=(ge=ee[oe])==null?void 0:ge.trim();ce&&(ue==="experience_years"?de[ue]=parseInt(ce)||null:de[ue]=ce)}),de});let ie=0;for(let ee=0;ee{const J=`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`,ne=new Blob([J],{type:"text/csv"}),ie=URL.createObjectURL(ne),ee=document.createElement("a");ee.href=ie,ee.download="recruit-prospects-template.csv",ee.click(),URL.revokeObjectURL(ie)};return e.jsx(js,{open:t,onOpenChange:J=>{J||L(),s(J)},children:e.jsxs(_s,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Import Prospects from CSV"})}),M==="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(Qy,{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:B}),e.jsxs(Y,{onClick:()=>{var J;return(J=l.current)==null?void 0:J.click()},children:[e.jsx(ji,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(Y,{variant:"link",className:"text-xs",onClick:W,children:"Download CSV template"})]}),M==="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(er,{value:_,onValueChange:j,children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{})}),e.jsx(Js,{children:n.map(J=>e.jsx(Et,{value:J.id,children:J.name},J.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"w-[140px]",children:"CSV Column"}),e.jsx(Ct,{className:"w-[160px]",children:"Map To"}),e.jsx(Ct,{children:"Preview"})]})}),e.jsx(Bn,{children:h.map((J,ne)=>{var ie;return e.jsxs(ws,{children:[e.jsx(ot,{className:"font-medium text-xs",children:J}),e.jsx(ot,{children:e.jsxs(er,{value:g[String(ne)]||"skip",onValueChange:ee=>v(de=>({...de,[String(ne)]:ee==="skip"?"":ee})),children:[e.jsx(Qs,{className:"h-8 text-xs",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"skip",children:"— Skip —"}),aPe.map(ee=>e.jsx(Et,{value:ee,children:ee.replace(/_/g," ")},ee))]})]})}),e.jsx(ot,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((ie=i[0])==null?void 0:ie[String(ne)])||"—"})]},ne)})})]})}),!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(Y,{variant:"outline",onClick:()=>{L()},children:"Back"}),e.jsx(Y,{onClick:V,disabled:w||!Object.values(g).includes("first_name"),children:w?"Importing...":`Import ${i.length} Prospects`})]})]}),M==="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(ma,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[E," prospects imported successfully!"]}),e.jsx(Y,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function Acs({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=$le(t),[i,d]=T.useState(!1),[h,f]=T.useState(),[g,v]=T.useState(null),[_,j]=T.useState(!1),[w,k]=T.useState(!1),[M,S]=T.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 E=W=>r.filter(G=>G.stage_id===W),D=(W,G)=>{S(G),W.dataTransfer.effectAllowed="move"},L=W=>{W.preventDefault(),W.dataTransfer.dropEffect="move"},B=(W,G)=>{W.preventDefault(),M&&(o.mutate({id:M,stage_id:G}),S(null))},$=W=>{f(W),d(!0)},V=W=>{v(W),j(!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(Y,{variant:"outline",onClick:()=>k(!0),children:[e.jsx(ji,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(Y,{onClick:()=>{f(void 0),d(!0)},children:[e.jsx(ar,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(po,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(W=>{const G=E(W.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:L,onDrop:J=>B(J,W.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:W.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:W.name}),e.jsx(ct,{variant:"secondary",className:"text-xs h-5 px-1.5",children:G.length})]}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>$(W.id),children:e.jsx(ar,{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:G.map(J=>e.jsx(Oe,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:W.color},draggable:!0,onDragStart:ne=>D(ne,J.id),onClick:()=>V(J),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(lm,{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(Wo,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[J.first_name," ",J.last_name]})]}),J.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Ya,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:J.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[J.email&&e.jsx(zr,{className:"h-3 w-3 text-muted-foreground"}),J.phone&&e.jsx(Ha,{className:"h-3 w-3 text-muted-foreground"}),J.experience_years!=null&&e.jsxs(ct,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[J.experience_years,"yr"]})]})]})]})},J.id))})]},W.id)})}),e.jsx(Zie,{orientation:"horizontal"})]}),e.jsx(aYe,{open:i,onOpenChange:d,stages:s,defaultStageId:h,onSubmit:W=>a.mutate(W),isSubmitting:a.isPending}),e.jsx(lYe,{prospect:g,stages:s,brokerageId:t,open:_,onOpenChange:j,onUpdate:W=>{o.mutate(W),v(G=>G?{...G,...W}:null)},onDelete:W=>l.mutate(W)}),e.jsx(cYe,{open:w,onOpenChange:k,brokerageId:t,stages:s})]})}function Ecs({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=$le(t),[i,d]=T.useState(!1),[h,f]=T.useState(null),[g,v]=T.useState(!1),[_,j]=T.useState(!1),[w,k]=T.useState(""),[M,S]=T.useState("all"),[E,D]=T.useState(null),[L,B]=T.useState("asc"),$=J=>{E===J?B(ne=>ne==="asc"?"desc":"asc"):(D(J),B("asc"))},V=({column:J})=>E!==J?e.jsx(Hp,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):L==="asc"?e.jsx(Wm,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(jx,{className:"h-3.5 w-3.5 ml-1 text-primary"}),W=J=>s.find(ne=>ne.id===J),G=T.useMemo(()=>{let J=r.filter(ne=>{var de,oe;const ie=!w||`${ne.first_name} ${ne.last_name}`.toLowerCase().includes(w.toLowerCase())||((de=ne.email)==null?void 0:de.toLowerCase().includes(w.toLowerCase()))||((oe=ne.current_brokerage)==null?void 0:oe.toLowerCase().includes(w.toLowerCase())),ee=M==="all"||ne.stage_id===M;return ie&&ee});return E&&(J=[...J].sort((ne,ie)=>{var ue,ce;let ee=null,de=null;switch(E){case"name":ee=`${ne.first_name} ${ne.last_name||""}`.toLowerCase(),de=`${ie.first_name} ${ie.last_name||""}`.toLowerCase();break;case"stage":ee=((ue=W(ne.stage_id))==null?void 0:ue.sort_order)??999,de=((ce=W(ie.stage_id))==null?void 0:ce.sort_order)??999;break;case"brokerage":ee=(ne.current_brokerage||"").toLowerCase(),de=(ie.current_brokerage||"").toLowerCase();break;case"experience":ee=ne.experience_years??-1,de=ie.experience_years??-1;break;case"production":ee=(ne.annual_production||"").toLowerCase(),de=(ie.annual_production||"").toLowerCase();break;case"source":ee=(ne.source||"").toLowerCase(),de=(ie.source||"").toLowerCase();break;default:return 0}if(ee===de)return 0;if(ee==null)return 1;if(de==null)return-1;const oe=eek(J.target.value),className:"pl-8"})]}),e.jsxs(er,{value:M,onValueChange:S,children:[e.jsx(Qs,{className:"w-[180px]",children:e.jsx(tr,{placeholder:"All stages"})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"all",children:"All stages"}),s.map(J=>e.jsx(Et,{value:J.id,children:J.name},J.id))]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Y,{variant:"outline",onClick:()=>j(!0),children:[e.jsx(ji,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(Y,{onClick:()=>d(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(ws,{children:[e.jsx(Ct,{className:"cursor-pointer select-none",onClick:()=>$("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(V,{column:"name"})]})}),e.jsx(Ct,{className:"cursor-pointer select-none",onClick:()=>$("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(V,{column:"stage"})]})}),e.jsx(Ct,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>$("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(V,{column:"brokerage"})]})}),e.jsx(Ct,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(Ct,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(V,{column:"experience"})]})}),e.jsx(Ct,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(V,{column:"production"})]})}),e.jsx(Ct,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("source"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Source ",e.jsx(V,{column:"source"})]})}),e.jsx(Ct,{className:"w-[50px]"})]})}),e.jsx(Bn,{children:G.length===0?e.jsx(ws,{children:e.jsx(ot,{colSpan:8,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):G.map(J=>{const ne=W(J.stage_id);return e.jsxs(ws,{className:"cursor-pointer",onClick:()=>{f(J),v(!0)},children:[e.jsxs(ot,{className:"font-medium",children:[J.first_name," ",J.last_name]}),e.jsx(ot,{children:ne?e.jsxs(ct,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:ne.color,color:ne.color,backgroundColor:`${ne.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:ne.color}}),ne.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(ot,{className:"hidden md:table-cell",children:J.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Ya,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:J.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ot,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[J.email&&e.jsx(zr,{className:"h-3.5 w-3.5 text-muted-foreground"}),J.phone&&e.jsx(Ha,{className:"h-3.5 w-3.5 text-muted-foreground"}),!J.email&&!J.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(ot,{className:"hidden lg:table-cell",children:J.experience_years!=null?`${J.experience_years} yr`:"—"}),e.jsx(ot,{className:"hidden lg:table-cell",children:J.annual_production||"—"}),e.jsx(ot,{className:"hidden lg:table-cell",children:J.source?e.jsx(ct,{variant:"secondary",className:"text-xs",children:J.source}):"—"}),e.jsx(ot,{children:e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:ie=>{ie.stopPropagation(),l.mutate(J.id)},children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})})]},J.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[G.length," of ",r.length," prospects"]}),e.jsx(aYe,{open:i,onOpenChange:d,stages:s,onSubmit:J=>a.mutate(J),isSubmitting:a.isPending}),e.jsx(lYe,{prospect:h,stages:s,brokerageId:t,open:g,onOpenChange:v,onUpdate:J=>{o.mutate(J),f(ne=>ne?{...ne,...J}:null)},onDelete:J=>l.mutate(J)}),e.jsx(cYe,{open:_,onOpenChange:j,brokerageId:t,stages:s})]})}function Ics({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=$le(t),a=T.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(M=>M.name==="Signed"),i=s.find(M=>M.name==="Onboarded"),d=r.filter(M=>M.stage_id===(l==null?void 0:l.id)||M.stage_id===(i==null?void 0:i.id)).length,h=o>0?(d/o*100).toFixed(1):"0",f=new Date,g=o>0?Math.round(r.reduce((M,S)=>M+bg(f,new Date(S.created_at)),0)/o):0,v=s.map(M=>({...M,count:r.filter(S=>S.stage_id===M.id).length})),_={};r.forEach(M=>{const S=M.source||"unknown";_[S]=(_[S]||0)+1});const j=Object.entries(_).sort((M,S)=>S[1]-M[1]),w=new Date;w.setDate(w.getDate()-30);const k=r.filter(M=>new Date(M.created_at)>=w).length;return{total:o,signed:d,conversionRate:h,avgDays:g,byStage:v,bySrc:j,recentCount:k}},[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(Oe,{children:e.jsx($e,{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(br,{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(Oe,{children:e.jsx($e,{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(Jd,{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(Oe,{children:e.jsx($e,{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(ca,{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(Oe,{children:e.jsx($e,{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(hm,{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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx($e,{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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Lead Sources"})}),e.jsxs($e,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ct,{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 iPe=[{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 Pcs({brokerageId:t}){const{toast:s}=Sa(),[r,n]=T.useState(null),[a,o]=T.useState(null),l=(d,h)=>{navigator.clipboard.writeText(d),n(h),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(iPe.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(zr,{className:"h-4 w-4"})," ",d]}),iPe.filter(h=>h.category===d).map(h=>e.jsxs(Oe,{className:`cursor-pointer transition-all ${a===h.id?"ring-2 ring-primary/20":"hover:shadow-sm"}`,onClick:()=>o(a===h.id?null:h.id),children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{className:"text-sm",children:h.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",h.subject]})]}),e.jsx(ct,{variant:"secondary",className:"text-[10px]",children:h.category})]})}),a===h.id&&e.jsxs($e,{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:h.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:h.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Y,{size:"sm",variant:"outline",onClick:f=>{f.stopPropagation(),l(h.subject,h.id+"-subject")},children:[r===h.id+"-subject"?e.jsx(ma,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Di,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(Y,{size:"sm",onClick:f=>{f.stopPropagation(),l(h.body,h.id+"-body")},children:[r===h.id+"-body"?e.jsx(ma,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Di,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},h.id))]},d))]})}const oPe={call:Ha,email:zr,text:Eo,meeting:xn,note:Yn};function Lcs({brokerageId:t}){const{data:s,isLoading:r}=zt({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await Z.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 Z.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:h}=await Z.from("profiles").select("id, name, email").in("id",d),f=Object.fromEntries((h||[]).map(_=>[_.id,_])),g=jse(new Date,30);return{recruiters:d.map(_=>{var S,E;const j=(l||[]).filter(D=>D.created_by===_),w=j.filter(D=>new Date(D.created_at)>=g),k={};w.forEach(D=>{k[D.activity_type]=(k[D.activity_type]||0)+1});const M=n.filter(D=>D.created_by===_).length;return{id:_,name:((S=f[_])==null?void 0:S.name)||"Unknown",email:((E=f[_])==null?void 0:E.email)||"",totalActivities:j.length,recentActivities:w.length,byType:k,prospectsCreated:M}}).sort((_,j)=>j.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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx($e,{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(Wo,{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=oPe[o]||Yn;return e.jsxs(ct,{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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Recent Activity"})}),e.jsx($e,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=oPe[n.activity_type]||Yn;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:Bs(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 Dcs({brokerageId:t}){const{toast:s}=Sa(),r=vs(),[n,a]=T.useState(!1),[o,l]=T.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:d}=zt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:k,error:M}=await Z.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(M)throw M;return k}}),h=[...new Set(i.map(k=>k.referred_by))],{data:f=[]}=zt({queryKey:["referral-profiles",h],queryFn:async()=>{if(!h.length)return[];const{data:k}=await Z.from("profiles").select("id, name, email").in("id",h);return k||[]},enabled:h.length>0}),g=Object.fromEntries(f.map(k=>[k.id,k])),v=Wt({mutationFn:async k=>{const{data:{user:M}}=await Z.auth.getUser();if(!M)throw new Error("Not authenticated");const{error:S}=await Z.from("recruit_referrals").insert({brokerage_id:t,referred_by:M.id,referee_first_name:k.first_name,referee_last_name:k.last_name||null,referee_email:k.email||null,referee_phone:k.phone||null,referee_current_brokerage:k.current_brokerage||null,notes:k.notes||null});if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:k=>s({title:"Error",description:k.message,variant:"destructive"})}),_=Wt({mutationFn:async({id:k,status:M,incentive_status:S})=>{const E={updated_at:new Date().toISOString()};M&&(E.status=M),S&&(E.incentive_status=S);const{error:D}=await Z.from("recruit_referrals").update(E).eq("id",k);if(D)throw D},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),j=k=>k==="approved"||k==="signed"?e.jsx(ma,{className:"h-3 w-3"}):k==="rejected"?e.jsx(Cc,{className:"h-3 w-3"}):e.jsx(ca,{className:"h-3 w-3"}),w=k=>k==="approved"||k==="signed"||k==="paid"?"bg-green-500/10 text-green-600 border-green-200":k==="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(Y,{onClick:()=>a(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Zc,{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(k=>{var M;return e.jsx(Oe,{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:[k.referee_first_name," ",k.referee_last_name]}),e.jsxs(ct,{variant:"outline",className:w(k.status),children:[j(k.status)," ",k.status]}),k.incentive_status&&e.jsxs(ct,{variant:"outline",className:w(k.incentive_status),children:[e.jsx(oo,{className:"h-3 w-3 mr-1"})," ",k.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[k.referee_email&&e.jsx("p",{children:k.referee_email}),k.referee_phone&&e.jsx("p",{children:k.referee_phone}),k.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",k.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((M=g[k.referred_by])==null?void 0:M.name)||"Unknown"," • ",Bs(new Date(k.created_at),"MMM d, yyyy")]})]}),k.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:k.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(er,{value:k.status,onValueChange:S=>_.mutate({id:k.id,status:S}),children:[e.jsx(Qs,{className:"h-7 text-xs w-[110px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"pending",children:"Pending"}),e.jsx(Et,{value:"contacted",children:"Contacted"}),e.jsx(Et,{value:"approved",children:"Approved"}),e.jsx(Et,{value:"signed",children:"Signed"}),e.jsx(Et,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(er,{value:k.incentive_status||"pending",onValueChange:S=>_.mutate({id:k.id,incentive_status:S}),children:[e.jsx(Qs,{className:"h-7 text-xs w-[100px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"pending",children:"Unpaid"}),e.jsx(Et,{value:"paid",children:"Paid"}),e.jsx(Et,{value:"n/a",children:"N/A"})]})]})]})]})},k.id)})}),e.jsx(js,{open:n,onOpenChange:a,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:k=>{k.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(je,{children:"First Name *"}),e.jsx(Be,{required:!0,value:o.first_name,onChange:k=>l(M=>({...M,first_name:k.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Last Name"}),e.jsx(Be,{value:o.last_name,onChange:k=>l(M=>({...M,last_name:k.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Email"}),e.jsx(Be,{type:"email",value:o.email,onChange:k=>l(M=>({...M,email:k.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Phone"}),e.jsx(Be,{value:o.phone,onChange:k=>l(M=>({...M,phone:k.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Current Brokerage"}),e.jsx(Be,{value:o.current_brokerage,onChange:k=>l(M=>({...M,current_brokerage:k.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Notes"}),e.jsx(Rr,{value:o.notes,onChange:k=>l(M=>({...M,notes:k.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:v.isPending,children:"Submit"})]})]})]})})]})}function Ocs({brokerageId:t}){const{toast:s}=Sa(),r=vs(),[n,a]=T.useState(!1),{data:o}=zt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:v,error:_}=await Z.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(_)throw _;return v}}),{data:l=[]}=zt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:v,error:_}=await Z.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(_)throw _;return v}}),i=Wt({mutationFn:async v=>{const{error:_}=await Z.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=Wt({mutationFn:async({id:v,status:_})=>{const{error:j}=await Z.from("recruit_interest_submissions").update({status:_}).eq("id",v);if(j)throw j},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-interest-submissions",t]})}),h=`${window.location.origin}/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,f=()=>{navigator.clipboard.writeText(h),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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Public Interest Form"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(je,{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(ln,{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:h}),e.jsx(Y,{size:"sm",variant:"outline",onClick:f,children:n?e.jsx(ma,{className:"h-3.5 w-3.5"}):e.jsx(Di,{className:"h-3.5 w-3.5"})}),e.jsx(Y,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:e.jsx(bn,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx($e,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Zc,{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(ct,{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(zr,{className:"h-3 w-3"}),v.email]}),v.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ha,{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:Bs(new Date(v.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(er,{value:v.status,onValueChange:_=>d.mutate({id:v.id,status:_}),children:[e.jsx(Qs,{className:"h-7 text-xs w-[110px]",children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"new",children:"New"}),e.jsx(Et,{value:"contacted",children:"Contacted"}),e.jsx(Et,{value:"converted",children:"Converted"}),e.jsx(Et,{value:"dismissed",children:"Dismissed"})]})]})]},v.id))})})]})]})}function Rcs({brokerageId:t}){const{toast:s}=Sa(),r=vs(),[n,a]=T.useState(!1),[o,l]=T.useState({prospect_id:"",title:"",description:"",due_date:Bs(Ul(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=T.useState("pending"),{data:h=[]}=zt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:L,error:B}=await Z.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(B)throw B;return L}}),{data:f=[],isLoading:g}=zt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const L=h.map(V=>V.id);if(!L.length)return[];const{data:B,error:$}=await Z.from("recruit_follow_ups").select("*").in("prospect_id",L).order("due_date");if($)throw $;return B},enabled:h.length>0}),v=Object.fromEntries(h.map(L=>[L.id,L])),_=Wt({mutationFn:async L=>{const{data:{user:B}}=await Z.auth.getUser();if(!B)throw new Error("Not authenticated");const{error:$}=await Z.from("recruit_follow_ups").insert({prospect_id:L.prospect_id,assigned_to:B.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:Bs(Ul(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),j=Wt({mutationFn:async({id:L,completed:B})=>{const{error:$}=await Z.from("recruit_follow_ups").update({completed_at:B?new Date().toISOString():null}).eq("id",L);if($)throw $},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),w=f.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),k=w.filter(L=>!L.completed_at&&Ix(new Date(L.due_date))&&!Sd(new Date(L.due_date))),M=w.filter(L=>!L.completed_at&&Sd(new Date(L.due_date))),S=w.filter(L=>!L.completed_at&&!Ix(new Date(L.due_date))&&!Sd(new Date(L.due_date))),E=w.filter(L=>!!L.completed_at),D=L=>{const B=v[L.prospect_id],$=!L.completed_at&&Ix(new Date(L.due_date))&&!Sd(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Do,{checked:!!L.completed_at,onCheckedChange:V=>j.mutate({id:L.id,completed:V}),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:[B&&e.jsxs(ct,{variant:"secondary",className:"text-[10px]",children:[B.first_name," ",B.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(xn,{className:"h-3 w-3"}),Bs(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(ct,{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(Y,{size:"sm",variant:i===L?"default":"outline",onClick:()=>d(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&k.length+M.length+S.length>0&&`(${k.length+M.length+S.length})`]},L))}),e.jsxs(Y,{size:"sm",onClick:()=>a(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&k.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 (",k.length,")"]}),k.map(D)]}),i!=="completed"&&M.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(ca,{className:"h-3.5 w-3.5"})," Today (",M.length,")"]}),M.map(D)]}),i!=="completed"&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(xn,{className:"h-3.5 w-3.5"})," Upcoming (",S.length,")"]}),S.map(D)]}),i!=="pending"&&E.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(ma,{className:"h-3.5 w-3.5"})," Completed (",E.length,")"]}),E.map(D)]}),w.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(js,{open:n,onOpenChange:a,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:L=>{L.preventDefault(),_.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(je,{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(B=>({...B,prospect_id:L.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),h.map(L=>e.jsxs("option",{value:L.id,children:[L.first_name," ",L.last_name]},L.id))]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Task *"}),e.jsx(Be,{required:!0,value:o.title,onChange:L=>l(B=>({...B,title:L.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Details"}),e.jsx(Rr,{value:o.description,onChange:L=>l(B=>({...B,description:L.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Due Date *"}),e.jsx(Be,{type:"datetime-local",required:!0,value:o.due_date,onChange:L=>l(B=>({...B,due_date:L.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:_.isPending,children:"Schedule"})]})]})]})})]})}const Fcs=[{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 zcs({brokerageId:t}){const{toast:s}=Sa(),r=vs(),[n,a]=T.useState(null),{data:o,isLoading:l}=zt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:k,error:M}=await Z.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(M)throw M;return k}}),[i,d]=T.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:Fcs,testimonials:[],gallery_images:[]});T.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 h=Wt({mutationFn:async()=>{const k={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:M}=await Z.from("recruit_landing_page_settings").update(k).eq("id",i.id);if(M)throw M}else{const{error:M}=await Z.from("recruit_landing_page_settings").insert(k);if(M)throw M}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:k=>s({title:"Error",description:k.message,variant:"destructive"})}),f=async(k,M)=>{const S=k.name.split(".").pop(),E=`${t}/${M}-${Date.now()}.${S}`,{error:D}=await Z.storage.from("recruit-landing").upload(E,k);if(D)throw D;const{data:{publicUrl:L}}=Z.storage.from("recruit-landing").getPublicUrl(E);return L},g=async(k,M)=>{var E;const S=(E=k.target.files)==null?void 0:E[0];if(S){a(M);try{const D=await f(S,M);d(L=>({...L,[M]:D})),s({title:"Image uploaded!"})}catch(D){s({title:"Upload failed",description:D.message,variant:"destructive"})}finally{a(null)}}},v=async k=>{var S;const M=(S=k.target.files)==null?void 0:S[0];if(M){a("gallery");try{const E=await f(M,"gallery");d(D=>({...D,gallery_images:[...D.gallery_images,E]})),s({title:"Gallery image added!"})}catch(E){s({title:"Upload failed",description:E.message,variant:"destructive"})}finally{a(null)}}},_=async(k,M)=>{var E;const S=(E=k.target.files)==null?void 0:E[0];if(S){a(`testimonial-${M}`);try{const D=await f(S,`testimonial-${M}`);d(L=>{const B=[...L.testimonials];return B[M]={...B[M],photo_url:D},{...L,testimonials:B}})}catch(D){s({title:"Upload failed",description:D.message,variant:"destructive"})}finally{a(null)}}},{data:j}=zt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:k,error:M}=await Z.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(M)throw M;return k}}),w=`${window.location.origin}/join-brokerage/${(j==null?void 0:j.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:[(j==null?void 0:j.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Live page:"}),e.jsx("code",{className:"text-xs flex-1 truncate",children:w}),e.jsx(Y,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(bn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Branding"})}),e.jsx($e,{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(je,{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(Y,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(ji,{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:k=>g(k,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{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:k=>d(M=>({...M,primary_color:k.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Be,{value:i.primary_color,onChange:k=>d(M=>({...M,primary_color:k.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(je,{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:k=>d(M=>({...M,accent_color:k.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Be,{value:i.accent_color,onChange:k=>d(M=>({...M,accent_color:k.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Hero Section"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Headline"}),e.jsx(Be,{value:i.hero_headline,onChange:k=>d(M=>({...M,hero_headline:k.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Subtext"}),e.jsx(Rr,{value:i.hero_subtext,onChange:k=>d(M=>({...M,hero_subtext:k.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(je,{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(Y,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(ji,{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:k=>g(k,"hero_image_url")})]}),i.hero_image_url&&e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>d(k=>({...k,hero_image_url:null})),children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsx(Gt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>d(k=>({...k,benefits:[...k.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(ar,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs($e,{className:"space-y-3",children:[i.benefits.map((k,M)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(lm,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(Be,{value:k.icon,onChange:S=>{const E=[...i.benefits];E[M]={...k,icon:S.target.value},d(D=>({...D,benefits:E}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Be,{value:k.title,onChange:S=>{const E=[...i.benefits];E[M]={...k,title:S.target.value},d(D=>({...D,benefits:E}))},placeholder:"Benefit title"}),e.jsx(Be,{value:k.description,onChange:S=>{const E=[...i.benefits];E[M]={...k,description:S.target.value},d(D=>({...D,benefits:E}))},placeholder:"Short description"})]}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>d(S=>({...S,benefits:S.benefits.filter((E,D)=>D!==M)})),children:e.jsx(Ir,{className:"h-3.5 w-3.5 text-destructive"})})]},M)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsx(Gt,{className:"text-base",children:"Testimonials"}),e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>d(k=>({...k,testimonials:[...k.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(ar,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs($e,{className:"space-y-3",children:[i.testimonials.map((k,M)=>{var S;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[k.photo_url?e.jsx("img",{src:k.photo_url,alt:k.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((S=k.name)==null?void 0:S[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${M}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:E=>_(E,M)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Be,{value:k.name,onChange:E=>{const D=[...i.testimonials];D[M]={...k,name:E.target.value},d(L=>({...L,testimonials:D}))},placeholder:"Name"}),e.jsx(Be,{value:k.role,onChange:E=>{const D=[...i.testimonials];D[M]={...k,role:E.target.value},d(L=>({...L,testimonials:D}))},placeholder:"Role / Title"})]}),e.jsx(Rr,{value:k.quote,onChange:E=>{const D=[...i.testimonials];D[M]={...k,quote:E.target.value},d(L=>({...L,testimonials:D}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>d(E=>({...E,testimonials:E.testimonials.filter((D,L)=>L!==M)})),children:e.jsx(Ir,{className:"h-3.5 w-3.5 text-destructive"})})]},M)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsx(Gt,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Y,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(fl,{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($e,{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((k,M)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:k,alt:`Gallery ${M+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(Y,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(S=>({...S,gallery_images:S.gallery_images.filter((E,D)=>D!==M)})),children:e.jsx(Ir,{className:"h-3 w-3"})})]},M))}):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(Y,{onClick:()=>h.mutate(),disabled:h.isPending,size:"lg",children:[e.jsx(um,{className:"h-4 w-4 mr-2"}),h.isPending?"Saving...":"Save Landing Page"]})})]})}function Bcs(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function $cs({video:t}){return t.cta_clicked_at?e.jsx(ct,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(ct,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(wi,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(ct,{variant:"secondary",children:[e.jsx(Wa,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(ct,{variant:"outline",children:[e.jsx(ca,{className:"h-3 w-3 mr-1"}),"Draft"]})}function Ucs({brokerageId:t}){const{data:s=[],isLoading:r}=kcs(t),{data:n=[]}=oYe(t),a=Ccs(),o=Mcs(),l=iYe(),[i,d]=T.useState(""),[h,f]=T.useState(!1),[g,v]=T.useState({title:"",script_text:"",category:"general"}),_=s.filter(S=>{var D,L,B,$;return i?`${((D=S.prospect)==null?void 0:D.first_name)||""} ${((L=S.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||(($=(B=S.video)==null?void 0:B.title)==null?void 0:$.toLowerCase().includes(i.toLowerCase())):!0}),j={total:s.length,sent:s.filter(S=>S.sent_at).length,viewed:s.filter(S=>S.view_count>0).length,ctaClicked:s.filter(S=>S.cta_clicked_at).length},w=T.useCallback(S=>{if(!S)return;const E=`${window.location.origin}/recruit-video/${S}`;navigator.clipboard.writeText(E),be.success("Share link copied")},[]),k=T.useCallback((S,E)=>{l.mutate({id:S,sent_via:E})},[l]),M=()=>{!g.title.trim()||!g.script_text.trim()||a.mutate({brokerage_id:t,...g},{onSuccess:()=>{v({title:"",script_text:"",category:"general"}),f(!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:j.total,icon:Wn,color:"text-primary"},{label:"Sent",value:j.sent,icon:Wa,color:"text-blue-500"},{label:"Viewed",value:j.viewed,icon:wi,color:"text-amber-500"},{label:"CTA Clicked",value:j.ctaClicked,icon:oi,color:"text-emerald-500"}].map(S=>e.jsx(Oe,{children:e.jsxs($e,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${S.color}`,children:e.jsx(S.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})]})},S.label))}),e.jsxs(Qa,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(Ga,{children:[e.jsxs(Fs,{value:"videos",children:[e.jsx(Wn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(Fs,{value:"scripts",children:[e.jsx(Yn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(Fs,{value:"analytics",children:[e.jsx(Sc,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(Zs,{value:"videos",children:e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Gt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name or title...",value:i,onChange:S=>d(S.target.value),className:"pl-9"})]})]})}),e.jsx($e,{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(Wn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No video outreach yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Record a personalized video from any prospect's profile card"})]}):e.jsx("div",{className:"space-y-3",children:_.map(S=>{var E,D,L,B,$,V;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:[(E=S.video)!=null&&E.thumbnail_url?e.jsx("img",{src:S.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Wn,{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:Bcs(((D=S.video)==null?void 0:D.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(L=S.prospect)==null?void 0:L.first_name," ",(B=S.prospect)==null?void 0:B.last_name]}),e.jsx($cs,{video:S})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:(($=S.video)==null?void 0:$.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[Bs(new Date(S.created_at),"MMM d, yyyy"),((V=S.prospect)==null?void 0:V.current_brokerage)&&` · ${S.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(S.share_token),title:"Copy share link",children:e.jsx(Di,{className:"h-4 w-4"})}),!S.sent_at&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>k(S.id,"email"),title:"Mark as sent",children:e.jsx(Wa,{className:"h-4 w-4"})}),S.share_token&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${S.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(bn,{className:"h-4 w-4"})})]})]},S.id)})})})]})}),e.jsx(Zs,{value:"scripts",children:e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Gt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(js,{open:h,onOpenChange:f,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{size:"sm",children:[e.jsx(ar,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Title"}),e.jsx(Be,{value:g.title,onChange:S=>v(E=>({...E,title:S.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Category"}),e.jsxs(er,{value:g.category,onValueChange:S=>v(E=>({...E,category:S})),children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:Nye.map(S=>e.jsx(Et,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Script"}),e.jsx(Rr,{value:g.script_text,onChange:S=>v(E=>({...E,script_text:S.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(Y,{onClick:M,disabled:!g.title.trim()||!g.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx($e,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Yn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(S=>{var D;const E=((D=Nye.find(L=>L.value===S.category))==null?void 0:D.label)||S.category;return e.jsx(Oe,{className:"relative group",children:e.jsxs($e,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(ct,{variant:"outline",className:"text-[10px] mb-2",children:E}),e.jsx("h4",{className:"font-medium text-sm",children:S.title})]}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(S.id),children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:S.script_text}),S.is_global&&e.jsx(ct,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},S.id)})})})]})}),e.jsx(Zs,{value:"analytics",children:e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs($e,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:j.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:j.sent,pct:j.total?Math.round(j.sent/j.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:j.viewed,pct:j.sent?Math.round(j.viewed/j.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:j.ctaClicked,pct:j.viewed?Math.round(j.ctaClicked/j.viewed*100):0,color:"bg-emerald-500"}].map(S=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:S.label}),e.jsxs("span",{className:"font-medium",children:[S.count," (",S.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${S.color} rounded-full transition-all`,style:{width:`${S.pct}%`}})})]},S.label))}),s.filter(S=>S.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(S=>S.view_count>0).sort((S,E)=>E.view_count-S.view_count).slice(0,5).map(S=>{var E,D;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:[(E=S.prospect)==null?void 0:E.first_name," ",(D=S.prospect)==null?void 0:D.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(wi,{className:"h-3.5 w-3.5"})," ",S.view_count]}),S.cta_clicked_at&&e.jsx(oi,{className:"h-4 w-4 text-emerald-500"})]})]},S.id)})})]})]})]})})]})]})}function qcs({brokerageId:t}){const{toast:s}=Sa(),r=vs(),{stages:n,prospects:a}=$le(t),[o,l]=T.useState(!1),[i,d]=T.useState({title:"",target_count:"10",target_stage_id:"",period_start:Bs(new Date,"yyyy-MM-dd"),period_end:Bs(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:h=[],isLoading:f}=zt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:j,error:w}=await Z.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(w)throw w;return j}}),g=Wt({mutationFn:async j=>{const{data:{user:w}}=await Z.auth.getUser();if(!w)throw new Error("Not authenticated");const{error:k}=await Z.from("recruit_goals").insert({brokerage_id:t,title:j.title,target_count:parseInt(j.target_count),target_stage_id:j.target_stage_id||null,period_start:j.period_start,period_end:j.period_end,created_by:w.id});if(k)throw k},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),v=Wt({mutationFn:async j=>{const{error:w}=await Z.from("recruit_goals").delete().eq("id",j);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),_=j=>{const w=n.find(M=>M.id===j.target_stage_id);return{count:a.filter(M=>Ire(new Date(M.created_at),{start:new Date(j.period_start),end:new Date(j.period_end)})?j.target_stage_id?M.stage_id===j.target_stage_id:!0:!1).length,stage:w}};return f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[h.length," goal",h.length!==1?"s":""]}),e.jsxs(Y,{size:"sm",onClick:()=>l(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),h.length===0?e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(hm,{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:h.map(j=>{const{count:w,stage:k}=_(j),M=Math.min(100,w/j.target_count*100),S=Ire(new Date,{start:new Date(j.period_start),end:new Date(j.period_end)});return e.jsxs(Oe,{className:S?"":"opacity-60",children:[e.jsx(Ht,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Gt,{className:"text-sm",children:j.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[Bs(new Date(j.period_start),"MMM d")," – ",Bs(new Date(j.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[S?e.jsx(ct,{className:"text-[10px]",children:"Active"}):e.jsx(ct,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>v.mutate(j.id),children:e.jsx(Ir,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs($e,{className:"space-y-2",children:[k&&e.jsxs(ct,{variant:"outline",className:"text-[10px]",style:{borderColor:k.color,color:k.color},children:["Stage: ",k.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:w}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",j.target_count]})]}),e.jsx(rl,{value:M,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[M.toFixed(0),"% complete"]})]})]},j.id)})}),e.jsx(js,{open:o,onOpenChange:l,children:e.jsxs(_s,{children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),g.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Goal Title *"}),e.jsx(Be,{required:!0,value:i.title,onChange:j=>d(w=>({...w,title:j.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Target Count *"}),e.jsx(Be,{type:"number",min:"1",required:!0,value:i.target_count,onChange:j=>d(w=>({...w,target_count:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{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:j=>d(w=>({...w,target_stage_id:j.target.value})),children:[e.jsx("option",{value:"",children:"All stages (total prospects)"}),n.map(j=>e.jsx("option",{value:j.id,children:j.name},j.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(je,{children:"Start Date"}),e.jsx(Be,{type:"date",required:!0,value:i.period_start,onChange:j=>d(w=>({...w,period_start:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{children:"End Date"}),e.jsx(Be,{type:"date",required:!0,value:i.period_end,onChange:j=>d(w=>({...w,period_end:j.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Y,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(Y,{type:"submit",disabled:g.isPending,children:"Create Goal"})]})]})]})})]})}function Vcs(){var i;const[t,s]=T.useState(""),[r,n]=T.useState("board"),{data:a=[],isLoading:o}=zt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:d,error:h}=await Z.from("brokerages").select("id, name").order("name");if(h)throw h;return d}}),l=t||((i=a[0])==null?void 0:i.id)||"";return o?e.jsx(Vs,{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(Vs,{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(er,{value:l,onValueChange:s,children:[e.jsxs(Qs,{className:"w-[280px]",children:[e.jsx(Ya,{className:"mr-2 h-4 w-4"}),e.jsx(tr,{placeholder:"Select brokerage"})]}),e.jsx(Js,{children:a.map(d=>e.jsx(Et,{value:d.id,children:d.name},d.id))})]})]}),l?e.jsxs(Qa,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(Ga,{className:"flex-wrap h-auto gap-1",children:[e.jsx(Fs,{value:"pipeline",children:"Pipeline"}),e.jsxs(Fs,{value:"video-outreach",children:[e.jsx(Wn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(Fs,{value:"follow-ups",children:"Follow-ups"}),e.jsx(Fs,{value:"referrals",children:"Referrals"}),e.jsx(Fs,{value:"interest",children:"Interest Form"}),e.jsx(Fs,{value:"landing-page",children:"Landing Page"}),e.jsx(Fs,{value:"goals",children:"Goals"}),e.jsx(Fs,{value:"metrics",children:"Metrics"}),e.jsx(Fs,{value:"templates",children:"Email Templates"}),e.jsx(Fs,{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(Y,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(Qm,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(Y,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(WE,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(Acs,{brokerageId:l}):e.jsx(Ecs,{brokerageId:l})]}),e.jsx(Zs,{value:"video-outreach",children:e.jsx(Ucs,{brokerageId:l})}),e.jsx(Zs,{value:"follow-ups",children:e.jsx(Rcs,{brokerageId:l})}),e.jsx(Zs,{value:"referrals",children:e.jsx(Dcs,{brokerageId:l})}),e.jsx(Zs,{value:"interest",children:e.jsx(Ocs,{brokerageId:l})}),e.jsx(Zs,{value:"landing-page",children:e.jsx(zcs,{brokerageId:l})}),e.jsx(Zs,{value:"goals",children:e.jsx(qcs,{brokerageId:l})}),e.jsx(Zs,{value:"metrics",children:e.jsx(Ics,{brokerageId:l})}),e.jsx(Zs,{value:"templates",children:e.jsx(Pcs,{brokerageId:l})}),e.jsx(Zs,{value:"activity",children:e.jsx(Lcs,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ya,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function Hcs(){const{slug:t}=wl(),{toast:s}=Sa(),[r,n]=T.useState(!1),[a,o]=T.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:d}=zt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:E,error:D}=await Z.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(D)throw D;return E},enabled:!!t}),{data:h}=zt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:E,error:D}=await Z.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(D&&D.code!=="PGRST116")throw D;return E},enabled:!!(l!=null&&l.id)}),f=Wt({mutationFn:async()=>{const{error:E}=await Z.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(E)throw E},onSuccess:()=>n(!0),onError:E=>s({title:"Error",description:E.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(Ya,{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=h,v=(g==null?void 0:g.primary_color)||"#406E71",_=(g==null?void 0:g.accent_color)||"#2a4c64",j=(g==null?void 0:g.benefits)||[],w=(g==null?void 0:g.testimonials)||[],k=(g==null?void 0:g.gallery_images)||[],M=(g==null?void 0:g.hero_headline)||`Join ${l.name}`,S=(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(ma,{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:M}),e.jsx("p",{className:"text-lg md:text-xl opacity-90 mb-10 max-w-2xl mx-auto leading-relaxed",children:S}),e.jsxs("a",{href:"#apply",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-lg font-semibold shadow-lg transition-all hover:scale-105",style:{backgroundColor:"white",color:v},children:["Apply Now ",e.jsx(Gc,{className:"h-5 w-5"})]})]})]}),j.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:j.map((E,D)=>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:E.icon}),e.jsx("h3",{className:"text-xl font-bold mb-2",style:{color:_},children:E.title}),e.jsx("p",{className:"text-gray-600",children:E.description})]},D))})]})}),k.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(br,{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:k.map((E,D)=>e.jsx("img",{src:E,alt:`Team ${D+1}`,className:"w-full h-48 md:h-56 object-cover rounded-xl shadow-md hover:shadow-xl transition-shadow"},D))})]})}),w.length>0&&e.jsx("section",{className:"py-20 px-6 bg-white",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx(U4,{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:w.map((E,D)=>{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:['"',E.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-3",children:[E.photo_url?e.jsx("img",{src:E.photo_url,alt:E.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=E.name)==null?void 0:L[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",style:{color:_},children:E.name}),E.role&&e.jsx("p",{className:"text-xs text-gray-500",children:E.role})]})]})]},D)})})]})}),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:E=>{E.preventDefault(),f.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(je,{className:"text-gray-700",children:"First Name *"}),e.jsx(Be,{required:!0,value:a.first_name,onChange:E=>o(D=>({...D,first_name:E.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-gray-700",children:"Last Name"}),e.jsx(Be,{value:a.last_name,onChange:E=>o(D=>({...D,last_name:E.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-gray-700",children:"Email *"}),e.jsx(Be,{type:"email",required:!0,value:a.email,onChange:E=>o(D=>({...D,email:E.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-gray-700",children:"Phone"}),e.jsx(Be,{value:a.phone,onChange:E=>o(D=>({...D,phone:E.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-gray-700",children:"Current Brokerage"}),e.jsx(Be,{value:a.current_brokerage,onChange:E=>o(D=>({...D,current_brokerage:E.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{className:"text-gray-700",children:"License #"}),e.jsx(Be,{value:a.license_number,onChange:E=>o(D=>({...D,license_number:E.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-gray-700",children:"Years of Experience"}),e.jsx(Be,{type:"number",min:"0",value:a.experience_years,onChange:E=>o(D=>({...D,experience_years:E.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-gray-700",children:"Annual Production"}),e.jsx(Be,{placeholder:"e.g. $5M, 20 transactions",value:a.annual_production,onChange:E=>o(D=>({...D,annual_production:E.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-gray-700",children:"Why are you interested?"}),e.jsx(Rr,{value:a.why_interested,onChange:E=>o(D=>({...D,why_interested:E.target.value})),rows:3,placeholder:"Tell us what you're looking for..."})]}),e.jsx(Y,{type:"submit",className:"w-full h-12 text-base font-semibold rounded-xl",style:{backgroundColor:v},disabled:f.isPending,children:f.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 Wcs(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 Gcs(){var v,_,j,w;const{shareToken:t}=wl(),s=T.useRef(!1),{data:r,isLoading:n,error:a}=zt({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:k,error:M}=await Z.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(M)throw M;const{data:S}=await Z.from("profiles").select("name, avatar_url, title").eq("id",(L=k.video)==null?void 0:L.owner_user_id).single(),{data:E}=await Z.from("brokerages").select("name").eq("id",k.brokerage_id).single(),{data:D}=await Z.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",k.brokerage_id).maybeSingle();return{rv:k,profile:S,brokerage:E,settings:D}},enabled:!!t});if(T.useEffect(()=>{var k;!((k=r==null?void 0:r.rv)!=null&&k.id)||s.current||(s.current=!0,Z.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,h=(d==null?void 0:d.primary_color)||"#3b82f6",f=((_=o.prospect)==null?void 0:_.first_name)||"there",g=(j=o.video)!=null&&j.playback_url?Wcs(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(Ih,{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:h},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 ",f,", ",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:h},children:((w=l==null?void 0:l.name)==null?void 0:w.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(Y,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:h},onClick:()=>{Z.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(xn,{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 Kcs(){const t=Yr(),s=vs(),{isAdmin:r}=Ys(),[n,a]=T.useState(!1),[o,l]=T.useState(null),[i,d]=T.useState(null),{data:h,isLoading:f}=zt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:L},error:B}=await Z.auth.getUser();if(B)throw B;if(!L)return[];const{data:$,error:V}=await Z.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(V)throw V;return $}}),g=Wt({mutationFn:async L=>{const{data:{user:B},error:$}=await Z.auth.getUser();if($)throw $;if(!B)throw new Error("Not authenticated");const{error:V}=await Z.from("social_accounts").delete().eq("id",L).eq("user_id",B.id);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),be.success("Account disconnected successfully")},onError:()=>{be.error("Failed to disconnect account")}}),v=async()=>{a(!0);try{const{data:L,error:B}=await Z.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(B)throw B;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),be.error("Failed to start connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:L,error:B}=await Z.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(B)throw B;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),be.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},j=async()=>{a(!0);try{const{data:L,error:B}=await Z.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(B)throw B;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),be.error("Failed to start Google connection. Please try again."),a(!1)}},w=(h==null?void 0:h.filter(L=>L.platform==="facebook"))||[],k=(h==null?void 0:h.filter(L=>L.platform==="instagram"))||[],M=(h==null?void 0:h.filter(L=>L.platform==="linkedin"))||[],S=(h==null?void 0:h.filter(L=>L.platform==="google_business"))||[],E=((h==null?void 0:h.length)||0)>0,D=async(L,B)=>{l(L),d(null);try{const{data:$,error:V}=await Z.functions.invoke("meta-api-test",{body:{testType:"all",accountId:L}});if(V)throw V;d($.results||[]),be.success($.summary||"API tests completed")}catch($){console.error("Meta API test error:",$),be.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Vs,{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(ct,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Sn,{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(Y,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(bi,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Oe,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs($e,{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(ca,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(ct,{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:[E&&e.jsx(Oe,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs($e,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(yi,{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(Oe,{children:[e.jsx(Ht,{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(Qd,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-lg",children:"Facebook"}),e.jsx(Tr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs($e,{className:"space-y-4",children:[f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(el,{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(_a,{src:L.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Qd,{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(ct,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect Facebook?"}),e.jsx(cc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{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(Y,{onClick:v,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(el,{className:"h-4 w-4 animate-spin"}):e.jsx(ar,{className:"h-4 w-4"}),w.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{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(vu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-lg",children:"Instagram"}),e.jsx(Tr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs($e,{className:"space-y-4",children:[f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(el,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):k.length>0?e.jsx("div",{className:"space-y-3",children:k.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(fn,{className:"h-10 w-10",children:[e.jsx(_a,{src:L.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(vu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(ct,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect Instagram?"}),e.jsx(cc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{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(Y,{onClick:v,disabled:n,className:"w-full gap-2",variant:k.length>0?"outline":"default",children:[n?e.jsx(el,{className:"h-4 w-4 animate-spin"}):e.jsx(ar,{className:"h-4 w-4"}),k.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(Oe,{children:[e.jsx(Ht,{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(cm,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-lg",children:"LinkedIn"}),e.jsx(Tr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs($e,{className:"space-y-4",children:[f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(el,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):M.length>0?e.jsx("div",{className:"space-y-3",children:M.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(_a,{src:L.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(cm,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(ct,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect LinkedIn?"}),e.jsx(cc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{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(Y,{onClick:_,disabled:n,className:"w-full gap-2",variant:M.length>0?"outline":"default",children:[n?e.jsx(el,{className:"h-4 w-4 animate-spin"}):e.jsx(ar,{className:"h-4 w-4"}),M.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(Oe,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(ct,{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(ct,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Ht,{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(Gi,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-lg",children:"Google Business"}),e.jsx(Tr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs($e,{className:"space-y-4",children:[f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(el,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(fn,{className:"h-10 w-10",children:[e.jsx(_a,{src:L.profile_picture_url||""}),e.jsx(gn,{children:e.jsx(Gi,{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(ct,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Ec,{children:[e.jsx(sm,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})}),e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Disconnect Google Business?"}),e.jsx(cc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{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(Y,{onClick:r?j:void 0,disabled:!r||n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(el,{className:"h-4 w-4 animate-spin"}):e.jsx(ar,{className:"h-4 w-4"}),S.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(w.length>0||k.length>0)&&e.jsxs(Oe,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Ht,{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(wk,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(Tr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',e.jsx("strong",{children:"public_profile"}),", ",e.jsx("strong",{children:"pages_show_list"}),", ",e.jsx("strong",{children:"pages_read_engagement"}),", ",e.jsx("strong",{children:"instagram_basic"}),", ",e.jsx("strong",{children:"pages_manage_posts"}),", and ",e.jsx("strong",{children:"instagram_content_publish"}),"."]}),e.jsxs("div",{className:"space-y-3",children:[w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Qd,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:L.page_name||"Facebook Page"})]}),e.jsx(Y,{size:"sm",variant:"outline",onClick:()=>D(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(wk,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),k.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(vu,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",L.platform_username||"Instagram"]})]}),e.jsx(Y,{size:"sm",variant:"outline",onClick:()=>D(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(wk,{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,B)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[L.status==="success"?e.jsx(oi,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(Us,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(Cc,{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})]})]},B))})]}),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(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-lg",children:"How it works"})}),e.jsx($e,{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 Zcs(){const[t]=Oc(),s=Yr(),[r,n]=T.useState("loading"),[a,o]=T.useState("Processing your connection...");return T.useEffect(()=>{(async()=>{var g;const i=t.get("code"),d=t.get("error"),h=t.get("error_description"),f=t.get("state");if(d){n("error"),o(h||"Authorization was denied"),be.error("Connection failed: "+(h||d));return}if(!i){n("error"),o("No authorization code received"),be.error("No authorization code received");return}try{const{data:v,error:_}=await Z.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:f,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)!`),be.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"),be.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(Oe,{className:"w-full max-w-md",children:[e.jsxs(Ht,{className:"text-center",children:[r==="loading"&&e.jsx(Us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(yi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Cc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Gt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(Tr,{children:a})]}),e.jsx($e,{className:"flex justify-center",children:r!=="loading"&&e.jsx(Y,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function Ycs(){const[t]=Oc(),s=Yr(),[r,n]=T.useState("loading"),[a,o]=T.useState("Connecting your Google Business Profile...");return T.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),h=t.get("error_description"),f=t.get("state");if(d){n("error"),o(h||"Authorization was denied"),be.error("Connection failed: "+(h||d));return}if(!i){n("error"),o("No authorization code received"),be.error("No authorization code received");return}try{const{data:g,error:v}=await Z.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:f}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Successfully connected Google Business Profile!"),be.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"),be.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(Oe,{className:"w-full max-w-md",children:[e.jsxs(Ht,{className:"text-center",children:[r==="loading"&&e.jsx(Us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(yi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Cc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Gt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(Tr,{children:a})]}),e.jsx($e,{className:"flex justify-center",children:r!=="loading"&&e.jsx(Y,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function Xcs(){const[t]=Oc(),s=Yr(),[r,n]=T.useState("loading"),[a,o]=T.useState("Connecting your LinkedIn account...");return T.useEffect(()=>{(async()=>{var g;const i=t.get("code"),d=t.get("state"),h=t.get("error"),f=t.get("error_description");if(h){console.error("LinkedIn OAuth error:",h,f),n("error"),o(f||"Failed to connect LinkedIn account"),be.error(f||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),be.error("No authorization code received");return}try{const{data:v,error:_}=await Z.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`),be.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"),be.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(Oe,{className:"w-full max-w-md",children:[e.jsxs(Ht,{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(Us,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(yi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(Cc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Gt,{className:"flex items-center justify-center gap-2",children:[e.jsx(cm,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(Tr,{children:a})]}),e.jsx($e,{className:"flex justify-center",children:e.jsx(Y,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function Qcs(){const t=Yr(),[s,r]=T.useState(null),{data:n,isLoading:a}=sYe(s||void 0,!0),{data:o,isLoading:l}=iwe(!0),{cartItems:i}=ioe(),d=i.reduce((f,g)=>f+g.quantity,0),h=f=>{t(`/marketplace/${f.id}`)};return a||l?e.jsx(Vs,{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(f=>e.jsx(ys,{className:"h-10 w-24 flex-shrink-0"},f))}),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(f=>e.jsx(ys,{className:"h-72 w-full"},f))})]})}):e.jsx(Vs,{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(Y,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(Jh,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&e.jsx(ct,{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(Y,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(f=>e.jsx(Y,{variant:s===f.id?"default":"outline",size:"sm",onClick:()=>r(f.id),children:f.name},f.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(f=>{var g;return e.jsxs(Oe,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>h(f),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[f.images&&f.images.length>0?e.jsx("img",{src:((g=f.images.find(v=>v.is_primary))==null?void 0:g.image_url)||f.images[0].image_url,alt:f.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(mc,{className:"h-12 w-12 text-muted-foreground"})}),f.category&&e.jsx(ct,{className:"absolute top-2 left-2",variant:"secondary",children:f.category.name})]}),e.jsxs($e,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:f.name}),f.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:f.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(f.base_price).toFixed(2)]}),f.variants&&f.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[f.variants.length," options"]})]})]})]},f.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(mc,{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 dYe=T.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));dYe.displayName="Breadcrumb";const uYe=T.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:$t("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));uYe.displayName="BreadcrumbList";const Ose=T.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:$t("inline-flex items-center gap-1.5",t),...s}));Ose.displayName="BreadcrumbItem";const Sye=T.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?K0e:"a";return e.jsx(a,{ref:n,className:$t("transition-colors hover:text-foreground",s),...r})});Sye.displayName="BreadcrumbLink";const hYe=T.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:$t("font-normal text-foreground",t),...s}));hYe.displayName="BreadcrumbPage";const Cye=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:$t("[&>svg]:size-3.5",s),...r,children:t??e.jsx(Ri,{})});Cye.displayName="BreadcrumbSeparator";function Jcs(){var ie,ee;const{productId:t}=wl(),s=Yr(),{data:r,isLoading:n}=Ils(t||""),{addToCart:a,cartItems:o}=ioe(),[l,i]=T.useState(null),[d,h]=T.useState(1),[f,g]=T.useState(0),[v,_]=T.useState(null),[j,w]=T.useState(!1),[k,M]=T.useState(!1),S=(ie=r==null?void 0:r.variants)==null?void 0:ie.find(de=>de.id===l),E=((ee=r==null?void 0:r.variants)==null?void 0:ee.filter(de=>de.is_active))||[],D=Number((r==null?void 0:r.base_price)||0),L=S?Number(S.price_adjustment):0,B=D+L,$=Number((r==null?void 0:r.shipping_fee)||0),V=o.reduce((de,oe)=>de+oe.quantity,0),W=async de=>{if(!de.target.files||de.target.files.length===0)return;w(!0);const oe=de.target.files[0],ue=oe.name.split(".").pop(),ce=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ue}`;try{const{error:ge}=await Z.storage.from("marketplace").upload(ce,oe);if(ge)throw ge;const{data:{publicUrl:Te}}=Z.storage.from("marketplace").getPublicUrl(ce);_(Te),be.success("Artwork uploaded successfully")}catch(ge){be.error("Failed to upload artwork: "+ge.message)}finally{w(!1)}},G=()=>{if(r){if(E.length>0&&!l){be.error("Please select an option");return}a(r,S||void 0,d,v||void 0),M(!0),be.success("Added to cart!"),setTimeout(()=>M(!1),2e3)}},J=()=>{r!=null&&r.images&&g(de=>(de+1)%r.images.length)},ne=()=>{r!=null&&r.images&&g(de=>(de-1+r.images.length)%r.images.length)};return n?e.jsx(Vs,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(ys,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"h-8 w-3/4"}),e.jsx(ys,{className:"h-6 w-1/4"}),e.jsx(ys,{className:"h-24 w-full"}),e.jsx(ys,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Vs,{title:r.name,children:[e.jsx(dYe,{className:"mb-6",children:e.jsxs(uYe,{children:[e.jsx(Ose,{children:e.jsx(Sye,{asChild:!0,children:e.jsx(bo,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(Cye,{}),e.jsx(Ose,{children:e.jsx(Sye,{asChild:!0,children:e.jsx(bo,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(Cye,{}),e.jsx(Ose,{children:e.jsx(hYe,{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[f].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(Y,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:ne,children:e.jsx(hc,{className:"h-6 w-6"})}),e.jsx(Y,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:J,children:e.jsx(Ri,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(mc,{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,oe)=>e.jsx("button",{onClick:()=>g(oe),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${oe===f?"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(Oe,{children:e.jsxs($e,{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(ct,{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:["$",B.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})}),E.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:E.map(de=>e.jsxs(Y,{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(je,{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(Y,{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:W,className:"hidden",id:"artwork-upload",disabled:j}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(ji,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:j?"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(je,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{variant:"outline",size:"icon",onClick:()=>h(de=>Math.max(1,de-1)),children:"-"}),e.jsx(Be,{type:"number",value:d,onChange:de=>h(Math.max(1,parseInt(de.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(Y,{variant:"outline",size:"icon",onClick:()=>h(de=>de+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(Y,{size:"lg",className:"flex-1",onClick:G,disabled:k,children:k?e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(Jh,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(Y,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(Jh,{className:"h-5 w-5"}),V>0&&e.jsx(ct,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:V})]})]}),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(Vs,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(mc,{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(Y,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function eds(){const t=Yr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=ioe(),[h,f]=T.useState(!1),[g,v]=T.useState(""),_=async()=>{if(s.length===0){be.error("Your cart is empty");return}f(!0);try{const{data:j,error:w}=await Z.functions.invoke("marketplace-checkout",{body:{items:s.map(k=>{var M;return{product_id:k.product.id,variant_id:((M=k.variant)==null?void 0:M.id)||null,quantity:k.quantity,artwork_url:k.artworkUrl||null}}),notes:g.trim()||null}});if(w)throw w;if(j!=null&&j.url)d(),window.open(j.url,"_blank");else throw new Error("No checkout URL received")}catch(j){be.error("Checkout failed: "+j.message)}finally{f(!1)}};return s.length===0?e.jsx(Vs,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Mx,{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(Y,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Vs,{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(j=>{var w,k;return e.jsx(Oe,{children:e.jsx($e,{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:j.product.images&&j.product.images.length>0?e.jsx("img",{src:((w=j.product.images.find(M=>M.is_primary))==null?void 0:w.image_url)||j.product.images[0].image_url,alt:j.product.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Mx,{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:j.product.name}),j.variant&&e.jsx("p",{className:"text-sm text-muted-foreground",children:j.variant.name}),e.jsxs("p",{className:"font-medium mt-1",children:["$",a(j).toFixed(2),Number(j.product.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(j.product.shipping_fee).toFixed(2)," shipping"]})]}),j.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(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var M;return r(j.product.id,(M=j.variant)==null?void 0:M.id)},children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Y,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var M;return n(j.product.id,(M=j.variant)==null?void 0:M.id,j.quantity-1)},disabled:j.quantity<=1,children:e.jsx(T1,{className:"h-3 w-3"})}),e.jsx(Be,{type:"number",value:j.quantity,onChange:M=>{var S;return n(j.product.id,(S=j.variant)==null?void 0:S.id,parseInt(M.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(Y,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var M;return n(j.product.id,(M=j.variant)==null?void 0:M.id,j.quantity+1)},children:e.jsx(ar,{className:"h-3 w-3"})})]})]})]})})},`${j.product.id}-${((k=j.variant)==null?void 0:k.id)||"base"}`)}),e.jsx(Y,{variant:"ghost",className:"text-destructive",onClick:d,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Oe,{className:"sticky top-4",children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Order Summary"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((j,w)=>j+w.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(ud,{}),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(ud,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Rr,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:g,onChange:j=>v(j.target.value),rows:3,className:"resize-none"})]}),e.jsx(Y,{className:"w-full",size:"lg",onClick:_,disabled:h,children:h?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(qi,{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 tds(){const t=Yr(),{data:s,isLoading:r}=qls();return r?e.jsx(Vs,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(ys,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Vs,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(mc,{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(Y,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Vs,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(Oe,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs($e,{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:Bs(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(ct,{className:awe[n.status],children:u5[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(Y,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(bn,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(Ri,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const lPe=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function sds({currentStatus:t,statusHistory:s}){const r=lPe.indexOf(t);return e.jsx("div",{className:"space-y-3",children:lPe.map((n,a)=>{const o=s==null?void 0:s.find(h=>h.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(oi,{className:"h-4 w-4"}):i?e.jsx(ca,{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:u5[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Bs(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function rds(){var M;const{orderId:t}=wl(),s=Yr(),{data:r,isLoading:n,refetch:a}=Vls(t||""),o=Gls(),l=Kls(),[i,d]=T.useState(!1),[h,f]=T.useState(null),[g,v]=T.useState(""),[_,j]=T.useState(null),w=async S=>{j(S);try{await o.mutateAsync({orderId:t,itemId:S}),be.success("Proof approved!"),a()}catch{be.error("Failed to approve proof")}finally{j(null)}},k=async()=>{if(h){j(h);try{await l.mutateAsync({orderId:t,itemId:h,reason:g}),be.success("Revision requested"),d(!1),v(""),f(null),a()}catch{be.error("Failed to request revision")}finally{j(null)}}};return n?e.jsx(Vs,{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(ys,{className:"h-64 w-full"}),e.jsx(ys,{className:"h-48 w-full"})]}),e.jsx(ys,{className:"h-96 w-full"})]})}):r?e.jsxs(Vs,{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(Oe,{children:[e.jsxs(Ht,{className:"flex flex-row items-center justify-between",children:[e.jsx(Gt,{children:"Order Status"}),e.jsx(ct,{className:awe[r.status],children:u5[r.status]})]}),e.jsx($e,{children:e.jsx(sds,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Items"})}),e.jsx($e,{className:"space-y-4",children:(M=r.items)==null?void 0:M.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",S.quantity," × $",Number(S.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(S.unit_price)*S.quantity).toFixed(2)]})]}),S.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(S1,{className:"h-4 w-4"}),"View Artwork",e.jsx(bn,{className:"h-3 w-3"})]})]}),S.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(S1,{className:"h-4 w-4"}),"View Proof",e.jsx(bn,{className:"h-3 w-3"})]}),S.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(Y,{size:"sm",onClick:()=>w(S.id),disabled:_===S.id,children:[_===S.id?e.jsx(Us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ed,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>{f(S.id),d(!0)},disabled:_===S.id,children:[e.jsx(GE,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),S.proof_status==="approved"&&e.jsxs(ct,{className:"bg-green-100 text-green-800",children:[e.jsx(oi,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),S.proof_status==="rejected"&&S.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(ct,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.proof_notes})]})]})]},S.id))})]}),r.shipping_name&&e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsxs(Gt,{className:"flex items-center gap-2",children:[e.jsx(ZE,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs($e,{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(Y,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(bn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Oe,{className:"sticky top-4",children:[e.jsx(Ht,{children:e.jsx(Gt,{children:"Order Summary"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",Bs(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(ud,{}),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(ud,{}),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(ud,{}),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(js,{open:i,onOpenChange:d,children:e.jsxs(_s,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Request Changes"}),e.jsx(en,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Rr,{placeholder:"Describe the changes needed...",value:g,onChange:S=>v(S.target.value),rows:4}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(Y,{onClick:k,disabled:!g.trim()||_!==null,children:[_?e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Vs,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(mc,{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(Y,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function nds(){const t=Yr(),[s]=Oc();return s.get("session_id"),T.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Vs,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Oe,{children:e.jsxs($e,{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(oi,{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(mc,{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(Y,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx(qi,{className:"h-4 w-4 ml-2"})]}),e.jsx(Y,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function ads(){const{user:t}=Ys(),[s,r]=T.useState("store"),[n,a]=T.useState(null),[o,l]=T.useState(null),[i,d]=T.useState(!1),[h,f]=T.useState(5),[g,v]=T.useState(""),[_,j]=T.useState(!1),[w,k]=T.useState(!1),[M,S]=T.useState(""),[E,D]=T.useState(null),[L,B]=T.useState(!1),{hasSubmittedReview:$,submitReview:V,markPostedToGoogle:W}=j9e(),{data:G}=nYe(),{data:J,isLoading:ne}=rYe(),{data:ie,isLoading:ee}=tcs(n),{data:de,isLoading:oe}=scs(t==null?void 0:t.id),{data:ue=0}=ncs(t==null?void 0:t.id),ce=acs(),ge=new Set((de==null?void 0:de.map(Ee=>Ee.item_id))||[]),Te=async()=>{if(o)try{await ce.mutateAsync(o.id),be.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Ee){be.error(Ee.message||"Failed to purchase item")}},ve=async()=>{if(!g.trim()){be.error("Please write a review");return}j(!0);const Ee=await V(h,g);j(!1),Ee.success?(be.success("Thank you for your review! You earned 25 points!"),S(g),k(!0),v(""),f(5)):be.error(Ee.error||"Failed to submit review")},ye=()=>{navigator.clipboard.writeText(M),be.success("Review copied to clipboard!")},Se=()=>{W(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ke=()=>{k(!1),d(!1),S("")};return ne||ee||oe?e.jsx(Vs,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ys,{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(Ee=>e.jsx(ys,{className:"h-64"},Ee))})]})}):e.jsxs(Vs,{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(Oe,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx($e,{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(qn,{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:ue.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(vo,{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(Ym,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(Dk,{open:L,onOpenChange:B,children:e.jsxs(Oe,{className:"border-primary/20",children:[e.jsx(Ok,{asChild:!0,children:e.jsx(Ht,{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(vo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Gt,{className:"text-base",children:"How to Earn Points"}),e.jsx(Tr,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(kx,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Gc,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(Rk,{children:e.jsx($e,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[G==null?void 0:G.filter(Ee=>Ee.is_active).map(Ee=>{const He=Ue=>{switch(Ue){case"event_attendance":return e.jsx(xn,{className:"h-5 w-5"});case"leave_review":return e.jsx(qn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Zn,{className:"h-5 w-5"});case"first_contact":return e.jsx(br,{className:"h-5 w-5"});case"first_video":return e.jsx(Wn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(Eo,{className:"h-5 w-5"});default:return e.jsx(oo,{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:He(Ee.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Ee.action_name}),Ee.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ee.description})]}),e.jsxs(ct,{variant:"secondary",className:"font-bold shrink-0",children:["+",Ee.points]})]},Ee.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(Ym,{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(ct,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!$&&e.jsx(Oe,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx($e,{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(Eo,{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(Y,{onClick:()=>d(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(qn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(Qa,{value:s,onValueChange:r,children:[e.jsxs(Ga,{children:[e.jsxs(Fs,{value:"store",className:"flex items-center gap-2",children:[e.jsx(Mx,{className:"h-4 w-4"}),"Store"]}),e.jsxs(Fs,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(mc,{className:"h-4 w-4"}),"My Rewards",de&&de.length>0&&e.jsx(ct,{variant:"secondary",className:"ml-1",children:de.length})]})]}),e.jsxs(Zs,{value:"store",className:"mt-6",children:[J&&J.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(Y,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),J.map(Ee=>e.jsxs(Y,{variant:n===Ee.id?"default":"outline",size:"sm",onClick:()=>a(Ee.id),children:[Ee.icon&&`${Ee.icon} `,Ee.name]},Ee.id))]}),!ie||ie.length===0?e.jsx(Oe,{children:e.jsx($e,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(oo,{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:ie.map(Ee=>{const He=ge.has(Ee.id),Ue=Ee.max_quantity!==null&&Ee.current_quantity===0,De=ue>=Ee.points_cost;return e.jsxs(Oe,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${He?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>D(Ee),children:[Ee.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Ee.preview_image_url,alt:Ee.name,className:"w-full h-full object-cover"}),He&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(ct,{className:"bg-green-500 text-white",children:[e.jsx(oi,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Ue&&!He&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(ct,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(oo,{className:"h-12 w-12 text-muted-foreground/50"}),He&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(ct,{className:"bg-green-500 text-white",children:[e.jsx(oi,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Ht,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Gt,{className:"text-lg",children:Ee.name}),e.jsxs(ct,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(qn,{className:"h-3 w-3 mr-1"}),Ee.points_cost]})]}),Ee.category&&e.jsxs(ct,{variant:"outline",className:"w-fit",children:[Ee.category.icon&&`${Ee.category.icon} `,Ee.category.name]})]}),e.jsxs($e,{children:[e.jsx(Tr,{className:"mb-4 line-clamp-2",children:Ee.description||"No description available"}),Ee.max_quantity!==null&&!He&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Ee.current_quantity," of ",Ee.max_quantity," remaining"]}),He?e.jsx(Y,{className:"w-full",onClick:Ge=>{Ge.stopPropagation(),Ee.file_url&&kme(Ee.file_url,Ee.name)},disabled:!Ee.file_url,children:Ee.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(Y,{className:"w-full",onClick:Ge=>{Ge.stopPropagation(),l(Ee)},disabled:Ue||!De,children:Ue?"Sold Out":De?e.jsxs(e.Fragment,{children:[e.jsx(Mx,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Ee.points_cost-ue} more pts`})]})]},Ee.id)})})]}),e.jsx(Zs,{value:"my-rewards",className:"mt-6",children:!de||de.length===0?e.jsx(Oe,{children:e.jsx($e,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(mc,{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(Ee=>{var He,Ue,De,Ge,wt;return e.jsxs(Oe,{className:"overflow-hidden",children:[(He=Ee.item)!=null&&He.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Ee.item.preview_image_url,alt:((Ue=Ee.item)==null?void 0:Ue.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(oo,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Ht,{className:"pb-2",children:[e.jsx(Gt,{className:"text-lg",children:((De=Ee.item)==null?void 0:De.name)||"Unknown Item"}),e.jsxs(Tr,{className:"text-xs",children:["Purchased for ",Ee.points_spent," points • ",new Date(Ee.purchased_at).toLocaleDateString()]})]}),e.jsx($e,{children:e.jsx(Y,{className:"w-full",onClick:()=>{var Ie,st;(Ie=Ee.item)!=null&&Ie.file_url&&kme(Ee.item.file_url,(st=Ee.item)==null?void 0:st.name)},disabled:!((Ge=Ee.item)!=null&&Ge.file_url),children:((wt=Ee.item)==null?void 0:wt.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Ee.id)})})})]})]}),e.jsx(Ec,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(ac,{children:[e.jsxs(ic,{children:[e.jsx(lc,{children:"Confirm Purchase"}),e.jsxs(cc,{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:[ue," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[ue-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(oc,{children:[e.jsx(dc,{children:"Cancel"}),e.jsx(Hl,{onClick:Te,disabled:ce.isPending,children:ce.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(js,{open:i,onOpenChange:Ee=>{!Ee&&w?Ke():d(Ee)},children:e.jsx(_s,{children:w?e.jsxs(e.Fragment,{children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[e.jsx(oi,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(en,{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:['"',M,'"']})]}),e.jsxs(Y,{variant:"outline",className:"w-full",onClick:ye,children:[e.jsx(Di,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(Hn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(Y,{variant:"outline",onClick:Ke,children:"Maybe Later"}),e.jsxs(Y,{onClick:Se,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Leave a Review"}),e.jsx(en,{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(Ee=>e.jsx("button",{type:"button",onClick:()=>f(Ee),className:"focus:outline-none",children:e.jsx(qn,{className:`h-8 w-8 transition-colors ${h>=Ee?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Ee))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Rr,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:g,onChange:Ee=>v(Ee.target.value),rows:4})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(Y,{onClick:ve,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(js,{open:!!E,onOpenChange:()=>D(null),children:e.jsxs(_s,{className:"max-w-lg",children:[e.jsxs(Ls,{children:[e.jsxs(Ps,{className:"flex items-center gap-2",children:[E==null?void 0:E.name,e.jsxs(ct,{variant:"secondary",className:"font-bold",children:[e.jsx(qn,{className:"h-3 w-3 mr-1"}),E==null?void 0:E.points_cost]})]}),(E==null?void 0:E.category)&&e.jsxs(ct,{variant:"outline",className:"w-fit",children:[E.category.icon&&`${E.category.icon} `,E.category.name]})]}),(E==null?void 0:E.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:E.preview_image_url,alt:E.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(E==null?void 0:E.description)||"No description available"}),(E==null?void 0:E.max_quantity)!==null&&!ge.has((E==null?void 0:E.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[E==null?void 0:E.current_quantity," of ",E==null?void 0:E.max_quantity," remaining"]})]}),e.jsx(Hn,{children:E&&ge.has(E.id)?e.jsx(Y,{className:"w-full",onClick:()=>{E.file_url&&kme(E.file_url,E.name)},disabled:!E.file_url,children:E.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Access"]})}):E&&e.jsx(Y,{className:"w-full",onClick:()=>{D(null),l(E)},disabled:E.max_quantity!==null&&E.current_quantity===0||ue{const{user:t}=Ys(),s=vs(),r=zt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:h,error:f}=await Z.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(f)throw f;return h||[]},enabled:!!t}),n=zt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:h,error:f}=await Z.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(f)throw f;return h||[]},enabled:!!t}),a=Wt({mutationFn:async h=>{const{data:f,error:g}=await Z.from("smart_presentations").insert({owner_user_id:t.id,...h}).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Wt({mutationFn:async({id:h,...f})=>{const{data:g,error:v}=await Z.from("smart_presentations").update(f).eq("id",h).select().single();if(v)throw v;return g},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Wt({mutationFn:async h=>{const{data:f,error:g}=await Z.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",h).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),be.success("Presentation published!")}}),i=Wt({mutationFn:async h=>{const{error:f}=await Z.from("smart_presentations").update({status:"archived"}).eq("id",h);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),be.success("Presentation archived")}}),d=Wt({mutationFn:async h=>{const{error:f}=await Z.from("smart_presentation_templates").insert({owner_user_id:t.id,name:h.title+" Template",description:"Created from "+h.title,template_type:"custom",icon:"📄",sections:h.sections,cta_config:{type:h.cta_type,label:h.cta_label},is_system:!1});if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),be.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}},ids=[{value:"positive",label:"Love it",icon:Ed,color:"bg-emerald-100 text-emerald-700 border-emerald-300"},{value:"suggestion",label:"Suggestion",icon:t0,color:"bg-amber-100 text-amber-700 border-amber-300"},{value:"issue",label:"Issue",icon:Lu,color:"bg-red-100 text-red-700 border-red-300"}],ods=({feature:t,children:s})=>{const{user:r}=Ys(),[n,a]=T.useState(!1),[o,l]=T.useState(null),[i,d]=T.useState(""),[h,f]=T.useState(!1),g=async()=>{var v;if(!o||!i.trim()){be.error("Please select a type and add your feedback");return}f(!0);try{const{error:_}=await Z.functions.invoke("send-beta-feedback",{body:{feature:t,sentiment:o,message:i.trim(),userName:((v=r==null?void 0:r.user_metadata)==null?void 0:v.name)||(r==null?void 0:r.email)||"Unknown",userEmail:(r==null?void 0:r.email)||"unknown"}});if(_)throw _;be.success("Thank you for your feedback!"),a(!1),l(null),d("")}catch(_){console.error("Feedback error:",_),be.error("Failed to send feedback. Please try again.")}finally{f(!1)}};return e.jsxs(js,{open:n,onOpenChange:a,children:[e.jsx(Fi,{asChild:!0,children:s||e.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5 text-xs border-amber-200 bg-amber-50 text-amber-700 hover:bg-amber-100 hover:text-amber-800 dark:bg-amber-900/20 dark:border-amber-800 dark:text-amber-400 dark:hover:bg-amber-900/30 transition-colors",children:[e.jsx(PE,{className:"h-3.5 w-3.5"}),"Feedback"]})}),e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Share Your Feedback"}),e.jsx(en,{children:"This feature is in beta — your thoughts help us make it better!"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsx("div",{className:"flex gap-2",children:ids.map(v=>{const _=v.icon;return e.jsxs("button",{type:"button",onClick:()=>l(v.value),className:$t("flex-1 flex flex-col items-center gap-1.5 rounded-lg border-2 p-3 text-xs font-medium transition-all",o===v.value?v.color:"border-border bg-background text-muted-foreground hover:bg-accent"),children:[e.jsx(_,{className:"h-5 w-5"}),v.label]},v.value)})}),e.jsx(Rr,{placeholder:"Tell us what you think...",value:i,onChange:v=>d(v.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(Y,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(Y,{onClick:g,disabled:h||!o||!i.trim(),children:h?"Sending...":"Send Feedback"})]})]})]})]})},lds=()=>{const t=Yr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=mYe(),o=i=>i.status==="draft"?e.jsx(ct,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(ct,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(ct,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(ct,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const d=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(d),be.success("Link copied!")};return e.jsx(Vs,{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.jsxs("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(E1e,{}),e.jsx(ods,{feature:"Smart Presentations"})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create personalized, video-first presentations for your clients"})]}),e.jsxs(Y,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(ys,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Oe,{children:e.jsxs($e,{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(Gp,{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(Y,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Oe,{className:"hover:shadow-sm transition-shadow",children:e.jsx($e,{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(Yn,{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 ",Bs(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wi,{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(Y,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(Di,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(Hu,{children:[e.jsx(Wu,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(hx,{className:"h-4 w-4"})})}),e.jsxs(ju,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Va,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(bn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Va,{onClick:()=>a.mutate(i),children:[e.jsx(Yn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Va,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(N4,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},cPe={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."}]},cds=[{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 dds(t){const s=cPe[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(cPe))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return cds}function uds({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=T.useState(!1),[o,l]=T.useState("script"),[i,d]=T.useState(0),[h,f]=T.useState(0),{canRecord:g}=PHe(),v=TN(),[_,j]=T.useState(""),[w,k]=T.useState(!1),[M,S]=T.useState(!0),[E,D]=T.useState(!1),[L,B]=T.useState(null),$=dds(t),V=()=>{l("script"),d(0),f(0),j(""),k(!1),S(!0),D(!1),B(null)},W=ee=>{!ee&&(o==="uploading"||o==="processing")||(a(ee),ee||V())},G=ee=>{B(ee),j($[ee].text),k(!1)},J=()=>{l("record"),S(_.trim().length>0)},ne=()=>{j(""),S(!1),l("record")},ie=T.useCallback(async(ee,de)=>{l("uploading");try{const oe=t||"Presentation Video",{videoId:ue,uploadUrl:ce,libraryId:ge}=await sL(oe),{apiKey:Te}=await rL(ue),ve=new XMLHttpRequest;ve.upload.onprogress=Ee=>{Ee.lengthComputable&&d(Ee.loaded/Ee.total*100)},await new Promise((Ee,He)=>{ve.onload=()=>ve.status>=200&&ve.status<300?Ee():He(new Error("Upload failed")),ve.onerror=()=>He(new Error("Upload failed")),ve.open("PUT",ce),ve.setRequestHeader("AccessKey",Te),ve.send(ee)}),l("processing");let ye=0;const Se=Date.now(),Ke=9e4;let Ae=null;for(;ye<4;){if(await new Promise(He=>setTimeout(He,3e3)),Date.now()-Se>Ke){const He=ee.size/1048576,Ue=`https://iframe.mediadelivery.net/embed/${ge}/${ue}?responsive=true`;await v.mutateAsync({bunny_video_id:ue,playback_url:Ue,file_size_mb:He,title:oe,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Ue),be.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Ee=await X5(ue);if(ye=Ee.status,f(Ee.encodeProgress||0),ye===4)Ae={playbackUrl:Ee.directPlayUrl,thumbnailUrl:Ee.thumbnailUrl,previewUrl:Ee.previewUrl||null,duration:Ee.length||de,fileSizeMb:(Ee.storageSize||ee.size)/(1024*1024)};else if(ye===5||ye===6)throw new Error("Video processing failed")}if(!Ae)throw new Error("No video data");await v.mutateAsync({bunny_video_id:ue,contact_id:s||void 0,playback_url:Ae.playbackUrl,thumbnail_url:Ae.thumbnailUrl,preview_url:Ae.previewUrl,duration_seconds:Ae.duration,file_size_mb:Ae.fileSizeMb,title:oe,status:"ready",touch_type:"presentation"}),r(Ae.playbackUrl),be.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(oe){console.error("Recording upload error:",oe),be.error("Failed to process video. Please try again."),l("record")}},[t,s,r,v]);return e.jsxs(js,{open:n,onOpenChange:W,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(Wn,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(_s,{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(Ls,{children:e.jsxs(Ps,{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((ee,de)=>e.jsxs("button",{onClick:()=>G(de),className:$t("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(Yn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:ee.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:ee.text})]},de))})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!w&&e.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Xa,{className:"h-3 w-3"}),"Edit"]})]}),w?e.jsx(Rr,{value:_,onChange:ee=>j(ee.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(Rr,{value:_,onChange:ee=>{j(ee.target.value),B(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(Y,{variant:"ghost",size:"sm",onClick:ne,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(Y,{onClick:J,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(Lu,{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(Y,{variant:"ghost",size:"sm",onClick:()=>S(!M),className:"h-7 text-xs gap-1",children:[M?e.jsx(Wp,{className:"h-3 w-3"}):e.jsx(wi,{className:"h-3 w-3"}),M?"Hide Script":"Show Script"]})]}),e.jsx(zle,{maxDurationSeconds:60,onRecordingComplete:ie,onRecordingStateChange:D,onError:ee=>be.error(ee),teleprompterContent:_.trim()?e.jsx(LZe,{text:_,isVisible:M,onToggleVisibility:()=>S(!M),isRecording:E,startCountdown:!1}):void 0}),e.jsx(Y,{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(Us,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(rl,{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(Us,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(rl,{value:h,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Processing... ",Math.round(h),"%"]}),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(yi,{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 hds({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=T.useState(!1),[o,l]=T.useState(null),[i,d]=T.useState("idle"),[h,f]=T.useState(0),g=T.useRef(null),v=TN(),{data:_}=Boe(),j=(_==null?void 0:_.total_storage_mb)||0,k=((_==null?void 0:_.max_storage_mb)||1024)-j,M=()=>{l(null),d("idle"),f(0)},S=$=>{!$&&i!=="idle"&&i!=="done"||(a($),$||M())},E=$=>{var G;const V=(G=$.target.files)==null?void 0:G[0];if(!V)return;if(!V.type.startsWith("video/")){be.error("Please select a video file");return}const W=V.size/(1024*1024);if(W>500){be.error("Video file must be less than 500MB");return}if(W>k){be.error(`Not enough storage. You have ${k.toFixed(1)} MB remaining.`);return}l(V)},D=T.useCallback(async()=>{if(o){d("creating"),f(0);try{const $=t||o.name,{data:V,error:W}=await Z.functions.invoke("bunny-upload",{body:{action:"create",title:$,isAgentVideo:!0}});if(W)throw new Error(W.message);const{videoId:G,libraryId:J}=V;d("uploading");const{data:ne,error:ie}=await Z.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:G,isAgentVideo:!0}});if(ie)throw new Error(ie.message);await new Promise((oe,ue)=>{const ce=new XMLHttpRequest;ce.upload.addEventListener("progress",ge=>{ge.lengthComputable&&f(Math.round(ge.loaded/ge.total*100))}),ce.addEventListener("load",()=>ce.status>=200&&ce.status<300?oe():ue(new Error(`Upload failed (${ce.status})`))),ce.addEventListener("error",()=>ue(new Error("Upload failed"))),ce.open("PUT",ne.uploadUrl),ce.setRequestHeader("AccessKey",ne.apiKey),ce.send(o)}),d("processing");const ee=o.size/(1024*1024),de=`https://iframe.mediadelivery.net/embed/${J}/${G}`;await v.mutateAsync({bunny_video_id:G,playback_url:de,file_size_mb:ee,title:$,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(de),d("done"),be.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch($){console.error("Upload error:",$),be.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... ${h}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},B=i!=="idle"&&i!=="done";return e.jsxs(js,{open:n,onOpenChange:S,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(ji,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsx(Ls,{children:e.jsxs(Ps,{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(Wn,{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"]})]}),!B&&e.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Xr,{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(ji,{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:E,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(Us,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(rl,{value:i==="uploading"?h:i==="processing"?100:10})]})]}),e.jsxs(Hn,{children:[e.jsx(Y,{variant:"outline",onClick:()=>S(!1),disabled:B,children:"Cancel"}),e.jsx(Y,{onClick:D,disabled:!o||B,children:B?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ji,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const dPe=[{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"}],uPe=()=>{const t=Yr(),{id:s}=wl(),{user:r}=Ys(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=mYe(),{isGmailConnected:d,gmailEmail:h}=MN(),[f,g]=T.useState(!1),[v,_]=T.useState("client"),[j,w]=T.useState(!1),[k,M]=T.useState(""),[S,E]=T.useState([]),[D,L]=T.useState(!1),[B,$]=T.useState(null),[V,W]=T.useState(!1),[G,J]=T.useState(""),[ne,ie]=T.useState(""),[ee,de]=T.useState(""),[oe,ue]=T.useState("buyer"),[ce,ge]=T.useState(""),[Te,ve]=T.useState(null),[ye,Se]=T.useState(""),[Ke,Ae]=T.useState([]),[Ee,He]=T.useState("schedule_call"),[Ue,De]=T.useState("Schedule a Call"),[Ge,wt]=T.useState(""),[Ie,st]=T.useState(""),[he,We]=T.useState(null),[et,Ye]=T.useState(s||null),[ke,at]=T.useState(null),[Fe,it]=T.useState(!1),dt=async(yt,bs)=>{if(!r)return;const gr=5*1024*1024;if(yt.size>gr){be.error("Image must be under 5MB");return}if(!yt.type.startsWith("image/")){be.error("Please upload an image file");return}We(bs);try{const Br=yt.name.split(".").pop()||"jpg",na=`${r.id}/${Date.now()}.${Br}`,{error:za}=await Z.storage.from("listing-photos").upload(na,yt);if(za)throw za;const{data:{publicUrl:go}}=Z.storage.from("listing-photos").getPublicUrl(na);Lt(bs,{image_url:go}),be.success("Image uploaded")}catch{be.error("Failed to upload image")}finally{We(null)}};T.useEffect(()=>{s&&tt(s)},[s]);const tt=async yt=>{const{data:bs,error:gr}=await Z.from("smart_presentations").select("*").eq("id",yt).single();if(gr||!bs)return;const Br=bs;if(w(!0),Se(Br.title),J(Br.client_name||""),ge(Br.property_address||""),Ae(Br.sections||[]),He(Br.cta_type||"schedule_call"),De(Br.cta_label||"Schedule a Call"),wt(Br.cta_url||""),st(Br.heading||""),at(Br.share_token),it(Br.status==="published"),Ye(Br.id),_("builder"),Br.contact_id){const{data:na}=await Z.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Br.contact_id).maybeSingle();na&&($(na),ie(na.email||""),de(na.phone||""))}};T.useEffect(()=>{if(!r||k.length<1){E([]);return}const yt=setTimeout(async()=>{L(!0);const{data:bs}=await Z.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${k}%,last_name.ilike.%${k}%,email.ilike.%${k}%`).limit(10);E(bs||[]),L(!1)},300);return()=>clearTimeout(yt)},[k,r]);const ut=yt=>{$(yt),J(`${yt.first_name} ${yt.last_name||""}`.trim()),ie(yt.email||""),de(yt.phone||""),W(!1)},xt=async()=>{if(!G.trim()){be.error("Client name is required");return}const yt=G.trim().split(" "),bs=yt[0],gr=yt.slice(1).join(" ")||null,{data:Br,error:na}=await Z.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:bs,last_name:gr,email:ne||null,phone:ee||null,lead_source:"Smart Presentation"}).select().single();if(na){be.error("Failed to create client");return}$(Br),be.success("Client created & saved to Agent OS"),_("template")},_t=yt=>{ve(yt);const bs=(yt.sections||[]).map(gr=>({...gr,is_visible:!0,video_url:"",text:""}));if(Ae(bs),Se(yt.name+(G?` for ${G}`:"")),yt.cta_config){const gr=yt.cta_config;He(gr.type||"schedule_call"),De(gr.label||"Schedule a Call")}_("builder")},qe=()=>{Ae([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),Se(G?`Presentation for ${G}`:"New Presentation"),_("builder")},Lt=(yt,bs)=>{Ae(gr=>gr.map((Br,na)=>na===yt?{...Br,...bs}:Br))},Rt=yt=>{Lt(yt,{is_visible:!Ke[yt].is_visible})},Kt=()=>{Ae(yt=>[...yt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Xt=yt=>{Ae(bs=>bs.filter((gr,Br)=>Br!==yt))},ss=async()=>{if(!ye.trim()){be.error("Title is required");return}try{if(et){const yt=await l.mutateAsync({id:et,title:ye,sections:Ke,client_name:G,property_address:ce||null,cta_type:Ee,cta_label:Ue,cta_url:Ge||null,heading:Ie||null});be.success("Saved")}else{const yt=await o.mutateAsync({title:ye,contact_id:(B==null?void 0:B.id)||void 0,client_name:G,property_address:ce||void 0,template_id:(Te==null?void 0:Te.id)||void 0,sections:Ke,cta_type:Ee,cta_label:Ue,cta_url:Ge||void 0,heading:Ie||void 0});Ye(yt.id),at(yt.share_token),be.success("Presentation created!")}}catch(yt){console.error("Failed to save presentation:",yt);const bs=(yt==null?void 0:yt.message)||(yt==null?void 0:yt.toString())||"Unknown error";be.error(`Failed to save: ${bs}`)}},fs=async()=>{try{await ss();const yt=et;if(yt){const bs=await i.mutateAsync(yt);at(bs.share_token),it(!0),_("share")}}catch(yt){console.error("Failed to publish presentation:",yt),be.error(`Failed to publish: ${(yt==null?void 0:yt.message)||"Unknown error"}`)}},fr=ke?`https://presentations.relevelup.com/${ke}`:"";return e.jsx(Vs,{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(Y,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(bi,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:j?"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"]})]})]}),!j&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((yt,bs)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:$t("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",v===yt?"bg-primary text-primary-foreground":bs<["client","template","builder","share"].indexOf(v)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:bs<["client","template","builder","share"].indexOf(v)?e.jsx(ma,{className:"h-4 w-4"}):bs+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:yt}),bs<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},yt))}),v==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{$(null),J(""),ie(""),de(""),W(!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(Wa,{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(qi,{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(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx(On,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs($e,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search by name or email...",value:k,onChange:yt=>M(yt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[D&&e.jsx(ys,{className:"h-12 w-full"}),S.map(yt=>e.jsxs("button",{onClick:()=>ut(yt),className:$t("w-full text-left p-3 rounded-lg border transition-colors",(B==null?void 0:B.id)===yt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[yt.first_name," ",yt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:yt.email||yt.phone||"No contact info"})]},yt.id)),!k&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),k&&S.length===0&&!D&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),B&&e.jsxs(Y,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",B.first_name,e.jsx(qi,{className:"h-4 w-4"})]})]})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{className:"pb-3",children:e.jsxs(Gt,{className:"text-base flex items-center gap-2",children:[e.jsx(Zc,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs($e,{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(je,{className:"text-xs",children:"Name *"}),e.jsx(Be,{value:G,onChange:yt=>{J(yt.target.value),W(!0),$(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:"Email"}),e.jsx(Be,{value:ne,onChange:yt=>ie(yt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:"Phone"}),e.jsx(Be,{value:ee,onChange:yt=>de(yt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:"Client Type"}),e.jsxs(er,{value:oe,onValueChange:ue,children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsxs(Js,{children:[e.jsx(Et,{value:"buyer",children:"Buyer"}),e.jsx(Et,{value:"seller",children:"Seller"}),e.jsx(Et,{value:"recruit",children:"Recruit"}),e.jsx(Et,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:"Property Address"}),e.jsx(Be,{value:ce,onChange:yt=>ge(yt.target.value),placeholder:"Optional"})]})]}),V&&G&&e.jsxs(Y,{onClick:xt,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(qi,{className:"h-4 w-4"})]})]})]})]})]}),v==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Qa,{defaultValue:"system",children:[e.jsxs(Ga,{children:[e.jsx(Fs,{value:"mine",children:"My Core Templates"}),e.jsx(Fs,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(Fs,{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(yt=>e.jsx(ys,{className:"h-32"},yt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(yt=>!yt.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(yt=>!yt.is_system).map(yt=>e.jsx(hPe,{template:yt,onSelect:_t},yt.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(yt=>yt.is_system).map(yt=>e.jsx(hPe,{template:yt,onSelect:_t},yt.id))})}),e.jsx(Zs,{value:"blank",className:"mt-4",children:e.jsx(Oe,{children:e.jsxs($e,{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(Y,{onClick:qe,children:"Start from Scratch"})]})})})]}),e.jsxs(Y,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[e.jsx(bi,{className:"h-4 w-4"}),"Back"]})]}),v==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Oe,{children:e.jsxs($e,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Presentation Title"}),e.jsx(Be,{value:ye,onChange:yt=>Se(yt.target.value)})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Page Heading"}),e.jsx(Be,{value:Ie,onChange:yt=>st(yt.target.value),placeholder:G?`Welcome, ${G}!`:"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(je,{children:"Client Name"}),e.jsx(Be,{value:G,onChange:yt=>J(yt.target.value)})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Property Address"}),e.jsx(Be,{value:ce,onChange:yt=>ge(yt.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(Y,{variant:"outline",size:"sm",onClick:Kt,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Ke.map((yt,bs)=>e.jsx(Oe,{className:$t(!yt.is_visible&&"opacity-50"),children:e.jsx($e,{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(lm,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:yt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Be,{value:yt.title,onChange:gr=>Lt(bs,{title:gr.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(Y,{variant:"ghost",size:"icon",onClick:()=>Rt(bs),children:yt.is_visible?e.jsx(wi,{className:"h-4 w-4"}):e.jsx(Wp,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>Xt(bs),className:"text-destructive hover:text-destructive",children:e.jsx(Ir,{className:"h-4 w-4"})})]})]}),e.jsx(Be,{value:yt.description||"",onChange:gr=>Lt(bs,{description:gr.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(je,{className:"text-xs",children:"Video URL"}),e.jsx(Be,{value:yt.video_url||"",onChange:gr=>Lt(bs,{video_url:gr.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(uds,{sectionTitle:yt.title,contactId:B==null?void 0:B.id,onVideoReady:gr=>Lt(bs,{video_url:gr})}),e.jsx(hds,{sectionTitle:yt.title,contactId:B==null?void 0:B.id,onVideoReady:gr=>Lt(bs,{video_url:gr})}),e.jsx(mds,{userId:r==null?void 0:r.id,onSelect:gr=>Lt(bs,{video_url:gr})})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),yt.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:yt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(Y,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Lt(bs,{image_url:""}),children:e.jsx(Xr,{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===bs?e.jsx(Us,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(M1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:he===bs?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:he===bs,onChange:gr=>{var na;const Br=(na=gr.target.files)==null?void 0:na[0];Br&&dt(Br,bs),gr.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-xs",children:"Text (optional)"}),e.jsx(Ig,{content:yt.text||"",onChange:gr=>Lt(bs,{text:gr}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},bs))})]}),e.jsxs(Oe,{children:[e.jsx(Ht,{children:e.jsx(Gt,{className:"text-base",children:"Call to Action"})}),e.jsxs($e,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(je,{children:"CTA Type"}),e.jsxs(er,{value:Ee,onValueChange:yt=>{He(yt);const bs=dPe.find(gr=>gr.value===yt);bs&&De(bs.label)},children:[e.jsx(Qs,{children:e.jsx(tr,{})}),e.jsx(Js,{children:dPe.map(yt=>e.jsx(Et,{value:yt.value,children:yt.label},yt.value))})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Button Label"}),e.jsx(Be,{value:Ue,onChange:yt=>De(yt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(je,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(Be,{value:Ge,onChange:yt=>wt(yt.target.value),placeholder:"https://calendly.com/..."}),!Ge&&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:[!j&&e.jsxs(Y,{variant:"outline",onClick:()=>_("template"),className:"gap-2",children:[e.jsx(bi,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(Y,{variant:"outline",onClick:ss,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(Y,{onClick:fs,disabled:i.isPending,className:"gap-2",children:[e.jsx(Wa,{className:"h-4 w-4"}),Fe?"Update & Reshare":"Publish & Share"]})]})]})]}),v==="share"&&ke&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Oe,{children:e.jsxs($e,{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(ma,{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 ",G||"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(Be,{value:fr,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(Y,{onClick:()=>{navigator.clipboard.writeText(fr),be.success("Link copied!")},children:e.jsx(Di,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(Y,{variant:"outline",className:"gap-2",onClick:()=>{const yt=`Hi ${G||""}! I put together something for you — check it out: ${fr}`;navigator.clipboard.writeText(yt),be.success("Message copied!")},children:[e.jsx(Eo,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(Y,{variant:"outline",className:"gap-2",onClick:()=>{d?g(!0):window.open(`mailto:${ne||""}?subject=${encodeURIComponent(ye)}&body=${encodeURIComponent(`Hi ${(B==null?void 0:B.first_name)||(G==null?void 0:G.split(" ")[0])||""}, I put together a personalized presentation for you: ${fr} Looking forward to connecting!`)}`)},children:[e.jsx(zr,{className:"h-4 w-4"}),"Send Email"]})]}),d&&e.jsx(Roe,{open:f,onOpenChange:g,contact:B?{id:B.id,first_name:B.first_name,last_name:B.last_name,email:ne||B.email||""}:ne?{id:"",first_name:(G==null?void 0:G.split(" ")[0])||"",last_name:(G==null?void 0:G.split(" ").slice(1).join(" "))||"",email:ne}:void 0,defaultSubject:ye,defaultBody:`Hi ${(B==null?void 0:B.first_name)||(G==null?void 0:G.split(" ")[0])||""}, I put together a personalized presentation for you: ${fr} Looking forward to connecting!`,gmailEmail:h})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(Y,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(bi,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(Y,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},hPe=({template:t,onSelect:s})=>e.jsx(Oe,{className:"hover:shadow-sm transition-shadow",children:e.jsxs($e,{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(ct,{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(Y,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),mds=({userId:t,onSelect:s})=>{const[r,n]=T.useState(!1),[a,o]=T.useState([]),[l,i]=T.useState(!1),[d,h]=T.useState("");T.useEffect(()=>{!r||!t||(i(!0),Z.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:g})=>{o(g||[]),i(!1)}))},[r,t]);const f=a.filter(g=>!d||(g.title||g.recipient_name||"").toLowerCase().includes(d.toLowerCase()));return e.jsxs(js,{open:r,onOpenChange:n,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",children:[e.jsx(Wd,{className:"h-3.5 w-3.5"}),"Library"]})}),e.jsxs(_s,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Select from Video Library"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a video from your Agent OS library"})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search videos...",value:d,onChange:g=>h(g.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-16 w-full"}),e.jsx(ys,{className:"h-16 w-full"})]}):f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:a.length===0?"No videos in your library yet":"No videos match your search"}):f.map(g=>e.jsxs("button",{onClick:()=>{s(g.playback_url||""),n(!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:g.thumbnail_url?e.jsx("img",{src:g.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:v=>{const _=v.currentTarget.parentElement;if(_){v.currentTarget.remove();const j=document.createElement("span");j.innerHTML="🎬",j.className="text-lg",_.appendChild(j)}}}):e.jsx(Wn,{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:g.title||g.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.duration_seconds?`${Math.round(g.duration_seconds)}s`:"",g.created_at?` · ${new Date(g.created_at).toLocaleDateString()}`:""]})]})]},g.id))})]})]})},pds=()=>{var w;const{shareToken:t}=wl(),[s,r]=T.useState(null),[n,a]=T.useState(!0),[o,l]=T.useState(0),[i,d]=T.useState(!1);T.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),T.useEffect(()=>{t&&h()},[t]);const h=async()=>{const{data:k,error:M}=await Z.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(M||!k){d(!0),a(!1);return}const{data:S}=await Z.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",k.owner_user_id).single();let E;if(S!=null&&S.brokerage_id){const{data:L}=await Z.from("brokerages").select("name").eq("id",S.brokerage_id).single();E=(L==null?void 0:L.name)||void 0}let D=null;if(k.contact_id){const{data:L}=await Z.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",k.contact_id).single();D=L}r({...k,owner_name:S==null?void 0:S.name,owner_email:S==null?void 0:S.email,owner_phone:S==null?void 0:S.phone,owner_avatar:S==null?void 0:S.avatar_url,owner_title:(S==null?void 0:S.title)||void 0,brokerage_name:E,contact_name:D?[D.first_name,D.last_name].filter(Boolean).join(" "):void 0,contact_email:(D==null?void 0:D.email)||void 0,contact_phone:(D==null?void 0:D.phone)||void 0}),a(!1);try{await Z.rpc("log_presentation_view",{p_presentation_id:k.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},f=async()=>{if(s){try{await Z.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(ys,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ys,{className:"h-64 w-full"}),e.jsx(ys,{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(k=>k.is_visible!==!1),v=g[o],_=k=>{const M=k.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(M)return`https://www.youtube.com/embed/${M[1]}?rel=0`;if(k.includes("iframe.mediadelivery.net/play/")){const D=k.replace("/play/","/embed/"),L=D.includes("?")?"&":"?";return`${D}${L}responsive=true`}if(k.includes("iframe.mediadelivery.net")){if(k.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=k.includes("?")?"&":"?";return`${k}${L}responsive=true`}return""}const S=k.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const E=k.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return E?`https://iframe.mediadelivery.net/embed/${E[1]}/${E[2]}?responsive=true`:k},j=!!((w=s.cta_url)!=null&&w.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[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((k,M)=>e.jsx("button",{onClick:()=>l(M),className:$t("w-full text-left p-4 rounded-xl border transition-all",o===M?"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(M+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:k.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:k.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:k.description})]})]})},M))})]}),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?"}),j?e.jsxs(Y,{size:"lg",onClick:f,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(bn,{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(I7e,{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 fds({open:t,onOpenChange:s,openHouse:r}){const n=P7e(),{user:a}=Ys(),o=T.useRef(null),[l,i]=T.useState(r.auto_forward_to_card??!1),[d,h]=T.useState(r.disclosure_pdf_url??""),[f,g]=T.useState(!1),[v,_]=T.useState(!1),j=async M=>{var B;const S=(B=M.target.files)==null?void 0:B[0];if(!S||!a)return;if(S.size>20*1024*1024){pn({title:"File must be under 20MB",variant:"destructive"});return}if(S.type!=="application/pdf"){pn({title:"Only PDF files are accepted",variant:"destructive"});return}g(!0);const E=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:D}=await Z.storage.from("open-house-photos").upload(E,S,{upsert:!0});if(D){pn({title:"Upload failed",description:D.message,variant:"destructive"}),g(!1);return}const{data:L}=Z.storage.from("open-house-photos").getPublicUrl(E);h(L.publicUrl),g(!1),pn({title:"PDF uploaded!"})},w=()=>{h(""),o.current&&(o.current.value="")},k=async()=>{_(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:d||null}),pn({title:"Settings saved!"}),s(!1)}catch{pn({title:"Failed to save",variant:"destructive"})}finally{_(!1)}};return e.jsx(js,{open:t,onOpenChange:s,children:e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Guest Book Settings"}),e.jsx(en,{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(je,{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(ln,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{className:"text-sm font-medium",children:"Seller's Disclosures (PDF)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visitors can view or download this on the thank you screen after check-in"}),e.jsx("input",{ref:o,type:"file",accept:"application/pdf",onChange:j,className:"hidden"}),d?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(Yn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:w,children:e.jsx(Xr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var M;return(M=o.current)==null?void 0:M.click()},disabled:f,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:f?e.jsx(Us,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ji,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(Y,{onClick:k,disabled:v,className:"w-full",children:v?"Saving...":"Save Settings"})]})]})})}const Mye="guestbook.relevelup.com";function gds(){const{data:t,isLoading:s}=gxt(),r=yxt(),n=P7e(),a=vxt(),[o,l]=T.useState(!1),[i,d]=T.useState(null),{user:h}=Ys(),[f,g]=T.useState(null),[v,_]=T.useState(null),[j,w]=T.useState(!1),k=T.useRef(null),[M,S]=T.useState({property_address:"",city:"",state:"",zip:"",event_date:Bs(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below."}),E=$=>{var W;const V=(W=$.target.files)==null?void 0:W[0];if(V){if(V.size>5*1024*1024){pn({title:"Photo must be under 5MB",variant:"destructive"});return}g(V),_(URL.createObjectURL(V))}},D=()=>{g(null),_(null),k.current&&(k.current.value="")},L=async()=>{if(!M.property_address){pn({title:"Address is required",variant:"destructive"});return}let $;if(f&&h){w(!0);const V=f.name.split(".").pop(),W=`${h.id}/${Date.now()}.${V}`,{error:G}=await Z.storage.from("open-house-photos").upload(W,f,{upsert:!0});if(G){pn({title:"Photo upload failed",description:G.message,variant:"destructive"}),w(!1);return}const{data:J}=Z.storage.from("open-house-photos").getPublicUrl(W);$=J.publicUrl,w(!1)}await r.mutateAsync({...M,photo_url:$}),l(!1),S({property_address:"",city:"",state:"",zip:"",event_date:Bs(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below."}),D()},B=$=>{navigator.clipboard.writeText(`https://${Mye}/${$}`),pn({title:"Link copied!"})};return e.jsxs(Vs,{title:"Guest Book",children:[e.jsx(Ih,{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(js,{open:o,onOpenChange:l,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"Create Open House"}),e.jsx(en,{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.jsxs("div",{children:[e.jsx(je,{children:"Property Address *"}),e.jsx(Be,{value:M.property_address,onChange:$=>S(V=>({...V,property_address:$.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{children:"City"}),e.jsx(Be,{value:M.city,onChange:$=>S(V=>({...V,city:$.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(je,{children:"State"}),e.jsx(Be,{value:M.state,onChange:$=>S(V=>({...V,state:$.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(je,{children:"ZIP"}),e.jsx(Be,{value:M.zip,onChange:$=>S(V=>({...V,zip:$.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(je,{children:"Date"}),e.jsx(Be,{type:"date",value:M.event_date,onChange:$=>S(V=>({...V,event_date:$.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Start Time"}),e.jsx(Be,{type:"time",value:M.start_time,onChange:$=>S(V=>({...V,start_time:$.target.value}))})]}),e.jsxs("div",{children:[e.jsx(je,{children:"End Time"}),e.jsx(Be,{type:"time",value:M.end_time,onChange:$=>S(V=>({...V,end_time:$.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Welcome Message"}),e.jsx(Rr,{value:M.agent_greeting,onChange:$=>S(V=>({...V,agent_greeting:$.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(je,{children:"Property Photo"}),e.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:E,className:"hidden"}),v?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:v,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:D,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Xr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var $;return($=k.current)==null?void 0:$.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(M1,{className:"h-6 w-6"}),e.jsx("span",{className:"text-sm",children:"Add a property photo"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(Y,{onClick:L,disabled:r.isPending||j,className:"w-full",children:j?"Uploading photo...":r.isPending?"Creating...":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map($=>e.jsx(Oe,{className:"animate-pulse",children:e.jsxs(Ht,{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"})]})},$))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map($=>e.jsx(xds,{openHouse:$,isExpanded:i===$.id,onToggle:()=>d(i===$.id?null:$.id),onCopyLink:()=>B($.slug||""),onToggleActive:()=>n.mutate({id:$.id,is_active:!$.is_active}),onDelete:()=>a.mutate($.id)},$.id))}):e.jsx(Oe,{className:"border-dashed",children:e.jsxs($e,{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(Ak,{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(Y,{onClick:()=>l(!0),children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function xds({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=xxt(s?t.id:void 0),[i,d]=T.useState(!1),[h,f]=T.useState(!1),[g,v]=T.useState(!1),_=T.useRef(null),j=`https://${Mye}/${t.slug}`,w=D=>{if(!D)return"";const[L,B]=D.split(":"),$=parseInt(L),V=$>=12?"PM":"AM";return`${$>12?$-12:$||12}:${B} ${V}`},k=()=>{if(!(l!=null&&l.length))return;const D=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],L=l.map(G=>[G.first_name,G.last_name||"",G.email||"",G.phone||"",G.visitor_intent||"",G.wants_market_updates?"Yes":"No",(G.message||"").replace(/"/g,'""'),Bs(new Date(G.created_at),"MM/dd/yyyy h:mm a")]),B=[D,...L].map(G=>G.map(J=>`"${J}"`).join(",")).join(` `),$=new Blob([B],{type:"text/csv"}),V=URL.createObjectURL($),W=document.createElement("a");W.href=V,W.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,W.click(),URL.revokeObjectURL(V)},M=T.useCallback(()=>{if(!_.current)return;const D=_.current.querySelector("svg");if(!D)return;const L=new XMLSerializer().serializeToString(D),B=document.createElement("canvas");B.width=1024,B.height=1024;const $=B.getContext("2d"),V=new Image;V.onload=()=>{$==null||$.drawImage(V,0,0,1024,1024);const W=document.createElement("a");W.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,W.href=B.toDataURL("image/png"),W.click()},V.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L)))},[t.property_address]),S=T.useCallback(()=>{if(!_.current)return;const D=_.current.querySelector("svg");if(!D)return;const L=new XMLSerializer().serializeToString(D),B="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L))),$=Bs(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),V=t.start_time?`${w(t.start_time)}${t.end_time?" – "+w(t.end_time):""}`:"",W=[t.city,t.state].filter(Boolean).join(", "),G=t.agent_greeting||"Welcome! Please sign in below.",J=window.open("","_blank");J&&(J.document.write(` Open House – ${t.property_address}
Open House
${t.property_address}
${W?`
${W}${t.zip?" "+t.zip:""}
`:""}
Date
${$}
${V?`
Time
${V}
`:""}
${G}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),J.document.close(),setTimeout(()=>{J.focus(),J.print()},500))},[t,j]),E=async()=>{v(!0);try{const{error:D}=await Z.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(D)throw D;pn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(D){pn({title:"Failed to send",description:D.message,variant:"destructive"})}finally{v(!1)}};return e.jsxs(Oe,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Ht,{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",children:[e.jsx(Gt,{className:"text-base truncate",children:t.property_address}),e.jsx(ct,{variant:t.is_active?"default":"secondary",className:"shrink-0",children:t.is_active?"Active":"Inactive"})]}),e.jsxs(Tr,{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(Gi,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),Bs(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(ca,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` - ${w(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(br,{className:"h-3 w-3"}),t.visitor_count," visitors"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(Y,{variant:"ghost",size:"icon",onClick:n,title:"Copy link",children:e.jsx(Di,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>d(!0),title:"QR Code",children:e.jsx(Ak,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>f(!0),title:"Settings",children:e.jsx(Ic,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:()=>window.open(j,"_blank"),title:"Preview",children:e.jsx(bn,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:a,title:t.is_active?"Deactivate":"Activate",children:t.is_active?e.jsx(Wp,{className:"h-4 w-4"}):e.jsx(wi,{className:"h-4 w-4"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:o,title:"Delete",children:e.jsx(Ir,{className:"h-4 w-4 text-destructive"})}),e.jsx(Y,{variant:"ghost",size:"icon",onClick:r,children:s?e.jsx(kx,{className:"h-4 w-4"}):e.jsx(Gc,{className:"h-4 w-4"})})]})]})}),s&&e.jsxs($e,{className:"pt-0",children:[e.jsx(ud,{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://",Mye,"/",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(Y,{variant:"outline",size:"sm",onClick:k,className:"h-7 text-xs gap-1",children:[e.jsx(Vi,{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(D=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[D.first_name,D.last_name?` ${D.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[D.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:D.email}),D.phone&&e.jsx("div",{className:"text-xs",children:D.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:D.visitor_intent&&e.jsx(ct,{variant:"outline",className:"text-xs capitalize",children:D.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:Bs(new Date(D.created_at),"h:mm a")})]},D.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!"})]}),e.jsx(js,{open:i,onOpenChange:d,children:e.jsxs(_s,{className:"sm:max-w-sm",children:[e.jsxs(Ls,{children:[e.jsx(Ps,{children:"QR Code"}),e.jsx(en,{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(nwe,{value:j,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:j}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(Y,{variant:"outline",className:"flex-1",onClick:M,children:[e.jsx(Vi,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(Y,{variant:"outline",className:"flex-1",onClick:S,children:[e.jsx(zE,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(Y,{variant:"default",className:"w-full",onClick:E,disabled:g,children:[e.jsx(zr,{className:"h-4 w-4 mr-2"}),g?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(fds,{open:h,onOpenChange:f,openHouse:t})]})}const yds=u_({first_name:Uo().trim().min(1,"First name is required").max(50),last_name:Uo().trim().max(50).optional(),email:Uo().trim().email("Please enter a valid email").max(255).optional().or(q5("")),phone:Uo().trim().max(20).optional().or(q5(""))}),vds=[{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 _ds(){var D;const{slug:t}=wl(),{data:s,isLoading:r,error:n}=L7e(t),a=D7e(),[o,l]=T.useState("welcome"),[i,d]=T.useState({first_name:"",last_name:"",email:"",phone:""}),[h,f]=T.useState(""),[g,v]=T.useState(!1),[_,j]=T.useState(""),w=L=>{if(!L)return"";const[B,$]=L.split(":"),V=parseInt(B),W=V>=12?"PM":"AM";return`${V>12?V-12:V||12}:${$} ${W}`},k=()=>{j("");const L=yds.safeParse(i);if(!L.success){j(L.error.issues[0].message);return}if(!i.email&&!i.phone){j("Please provide either an email or phone number");return}l("intent")},M=async L=>{f(L);try{await a.mutateAsync({open_house_id:s.id,first_name:i.first_name.trim(),last_name:i.last_name.trim()||void 0,email:i.email.trim()||void 0,phone:i.phone.trim()||void 0,visitor_intent:L,wants_market_updates:g}),l("done")}catch{j("Something went wrong. Please try again.")}};if(r)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(n||!s)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(Zn,{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 S=s.profiles,E=((D=S==null?void 0:S.name)==null?void 0:D.split(" ").map(L=>L[0]).join("").slice(0,2))||"?";return e.jsxs(e.Fragment,{children:[e.jsxs(Ih,{children:[e.jsxs("title",{children:["Open House | ",s.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the open house at ${s.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(_a,{src:(S==null?void 0:S.avatar_url)||"",alt:(S==null?void 0:S.name)||""}),e.jsx(gn,{className:"bg-white/10 text-white text-lg",children:E})]}),e.jsx("p",{className:"text-white/60 text-sm",children:S==null?void 0:S.name}),(S==null?void 0:S.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:S.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[s.photo_url&&e.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[e.jsx("img",{src:s.photo_url,alt:s.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:s.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[s.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gi,{className:"h-3 w-3"}),s.city,s.state?`, ${s.state}`:""," ",s.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),Bs(new Date(s.event_date+"T00:00:00"),"MMM d, yyyy")]}),s.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ca,{className:"h-3 w-3"}),w(s.start_time),s.end_time?` – ${w(s.end_time)}`:""]})]})]})]}),!s.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:e.jsx(Zn,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:s.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[s.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gi,{className:"h-3 w-3"}),s.city,s.state?`, ${s.state}`:""," ",s.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-3 w-3"}),Bs(new Date(s.event_date+"T00:00:00"),"MMM d, yyyy")]}),s.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ca,{className:"h-3 w-3"}),w(s.start_time),s.end_time?` – ${w(s.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[o==="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:s.agent_greeting||"Please sign in below."})]}),e.jsxs(Y,{onClick:()=>l("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(qi,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),o==="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:()=>l("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(bi,{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(je,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Be,{value:i.first_name,onChange:L=>d(B=>({...B,first_name:L.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Be,{value:i.last_name,onChange:L=>d(B=>({...B,last_name:L.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Be,{type:"email",value:i.email,onChange:L=>d(B=>({...B,email:L.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(je,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Be,{type:"tel",value:i.phone,onChange:L=>d(B=>({...B,phone:L.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:g,onChange:L=>v(L.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.jsx("p",{className:"text-destructive text-sm",children:_}),e.jsxs(Y,{onClick:k,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(qi,{className:"h-5 w-5 ml-2"})]})]}),o==="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:()=>l("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(bi,{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:vds.map(L=>e.jsxs("button",{onClick:()=>M(L.value),disabled:a.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:L.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:L.label})]},L.value))}),_&&e.jsx("p",{className:"text-destructive text-sm text-center",children:_})]}),o==="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(oi,{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, ",i.first_name,". Enjoy the open house!"]})]}),(S==null?void 0:S.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:S.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function bds(){const{slug:t}=wl();return t?e.jsx(uBe,{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 wds({contactId:t,onVideoReady:s}){const[r,n]=T.useState(!1),[a,o]=T.useState("record"),[l,i]=T.useState(0),[d,h]=T.useState(0),f=TN(),g=()=>{o("record"),i(0),h(0)},v=j=>{!j&&(a==="uploading"||a==="processing")||(n(j),j||g())},_=T.useCallback(async(j,w)=>{o("uploading");try{const k="Card Video",{videoId:M,libraryId:S}=await sL(k),{uploadUrl:E,apiKey:D}=await rL(M),L=new XMLHttpRequest;L.upload.onprogress=ne=>{ne.lengthComputable&&i(ne.loaded/ne.total*100)},await new Promise((ne,ie)=>{L.onload=()=>L.status>=200&&L.status<300?ne():ie(new Error("Upload failed")),L.onerror=()=>ie(new Error("Upload failed")),L.open("PUT",E),L.setRequestHeader("AccessKey",D),L.send(j)}),o("processing");let B=0;const $=Date.now(),V=9e4,W=`https://iframe.mediadelivery.net/embed/${S}/${M}`;for(;B<4;){if(await new Promise(ie=>setTimeout(ie,3e3)),Date.now()-$>V){const ie=j.size/1048576;await f.mutateAsync({bunny_video_id:M,playback_url:`https://iframe.mediadelivery.net/play/${S}/${M}`,file_size_mb:ie,title:k,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(W),be.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),g()},1500);return}const ne=await X5(M);if(B=ne.status,h(ne.encodeProgress||0),B===5||B===6)throw new Error("Video processing failed")}const G=await X5(M),J=(G.storageSize||j.size)/(1024*1024);await f.mutateAsync({bunny_video_id:M,contact_id:t||void 0,playback_url:G.directPlayUrl||W,thumbnail_url:G.thumbnailUrl,preview_url:G.previewUrl||null,duration_seconds:G.length||w,file_size_mb:J,title:k,status:"ready",touch_type:"video"}),s(W),be.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),g()},1500)}catch(k){console.error("Recording upload error:",k),be.error("Failed to process video. Please try again."),o("record")}},[t,s,f]);return e.jsxs(js,{open:r,onOpenChange:v,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(Wn,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(_s,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(zle,{maxDurationSeconds:60,onRecordingComplete:_,onError:j=>be.error(j)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(Us,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(rl,{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(Us,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(rl,{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(yi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}function pYe({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Ys(),l=TN(),i=T.useRef(null),d=T.useRef(null),[h,f]=T.useState(!1),[g,v]=T.useState(!1),[_,j]=T.useState(0),w=async M=>{if(o){f(!0);try{const S=M.name.split(".").pop()||"jpg",E=`${o.id}/card-${Date.now()}.${S}`,{error:D}=await Z.storage.from("listing-photos").upload(E,M);if(D)throw D;const{data:{publicUrl:L}}=Z.storage.from("listing-photos").getPublicUrl(E);r(L),be.success("Photo uploaded")}catch(S){be.error(S.message||"Failed to upload photo")}finally{f(!1)}}},k=async M=>{if(o){if(M.size>500*1024*1024){be.error("Video must be under 500MB");return}v(!0),j(0);try{const{videoId:S,libraryId:E}=await sL(`Card Video - ${Date.now()}`),{uploadUrl:D,apiKey:L}=await rL(S);await new Promise((V,W)=>{const G=new XMLHttpRequest;G.upload.addEventListener("progress",J=>{J.lengthComputable&&j(Math.round(J.loaded/J.total*100))}),G.addEventListener("load",()=>{G.status>=200&&G.status<300?V():W(new Error("Upload failed"))}),G.addEventListener("error",()=>W(new Error("Upload failed"))),G.open("PUT",D),G.setRequestHeader("AccessKey",L),G.send(M)});const B=`https://iframe.mediadelivery.net/embed/${E}/${S}`;n(B);const $=parseFloat((M.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${E}/${S}`,file_size_mb:$,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),be.success("Video uploaded & added to your library")}catch(S){be.error(S.message||"Failed to upload video")}finally{v(!1),j(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{children:"Media (optional)"}),e.jsxs(Qa,{defaultValue:"photo",className:"w-full",children:[e.jsxs(Ga,{className:"grid w-full grid-cols-2",children:[e.jsxs(Fs,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(fl,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(Fs,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(Wn,{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(Y,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(Xr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var M;return(M=i.current)==null?void 0:M.click()},disabled:h,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:h?e.jsx(Us,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(hg,{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:M=>{var E;const S=(E=M.target.files)==null?void 0:E[0];S&&w(S),M.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(Y,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(Xr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var M;return(M=d.current)==null?void 0:M.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(Us,{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(ji,{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(wds,{contactId:a,onVideoReady:M=>n(M)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:M=>{var E;const S=(E=M.target.files)==null?void 0:E[0];S&&k(S),M.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 fYe=T.createContext({});function jds(t){const s=T.useRef(null);return s.current===null&&(s.current=t()),s.current}const kds=typeof window<"u",Nds=kds?T.useLayoutEffect:T.useEffect,owe=T.createContext(null);function lwe(t,s){t.indexOf(s)===-1&&t.push(s)}function Uae(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const Vx=(t,s,r)=>r>s?s:r{};const j0={},gYe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function xYe(t){return typeof t=="object"&&t!==null}const yYe=t=>/^0[^.\s]+$/u.test(t);function vYe(t){let s;return()=>(s===void 0&&(s=t()),s)}const ef=t=>t,Sds=(t,s)=>r=>s(t(r)),hL=(...t)=>t.reduce(Sds),l6=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class dwe{constructor(){this.subscriptions=[]}add(s){return lwe(this.subscriptions,s),()=>Uae(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,qp=t=>t/1e3;function _Ye(t,s){return s?t*(1e3/s):0}const bYe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,Cds=1e-7,Mds=12;function Tds(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=bYe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>Cds&&++iTds(o,0,1,t,r);return o=>o===0||o===1?o:bYe(a(o),s,n)}const wYe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,jYe=t=>s=>1-t(1-s),kYe=mL(.33,1.53,.69,.99),uwe=jYe(kYe),NYe=wYe(uwe),SYe=t=>(t*=2)<1?.5*uwe(t):.5*(2-Math.pow(2,-10*(t-1))),hwe=t=>1-Math.sin(Math.acos(t)),CYe=jYe(hwe),MYe=wYe(hwe),Ads=mL(.42,0,1,1),Eds=mL(0,0,.58,1),TYe=mL(.42,0,.58,1),Ids=t=>Array.isArray(t)&&typeof t[0]!="number",AYe=t=>Array.isArray(t)&&typeof t[0]=="number",Pds={linear:ef,easeIn:Ads,easeInOut:TYe,easeOut:Eds,circIn:hwe,circInOut:MYe,circOut:CYe,backIn:uwe,backInOut:NYe,backOut:kYe,anticipate:SYe},Lds=t=>typeof t=="string",mPe=t=>{if(AYe(t)){cwe(t.length===4);const[s,r,n,a]=t;return mL(s,r,n,a)}else if(Lds(t))return Pds[t];return t},L8=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Dds(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(f){l.has(f)&&(h.schedule(f),t()),f(i)}const h={schedule:(f,g=!1,v=!1)=>{const j=v&&a?r:n;return g&&l.add(f),j.has(f)||j.add(f),f},cancel:f=>{n.delete(f),l.delete(f)},process:f=>{if(i=f,a){o=!0;return}a=!0,[r,n]=[n,r],r.forEach(d),r.clear(),a=!1,o&&(o=!1,h.process(f))}};return h}const Ods=40;function EYe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=L8.reduce((E,D)=>(E[D]=Dds(o),E),{}),{setup:i,read:d,resolveKeyframes:h,preUpdate:f,update:g,preRender:v,render:_,postRender:j}=l,w=()=>{const E=j0.useManualTiming?a.timestamp:performance.now();r=!1,j0.useManualTiming||(a.delta=n?1e3/60:Math.max(Math.min(E-a.timestamp,Ods),1)),a.timestamp=E,a.isProcessing=!0,i.process(a),d.process(a),h.process(a),f.process(a),g.process(a),v.process(a),_.process(a),j.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(w))},k=()=>{r=!0,n=!0,a.isProcessing||t(w)};return{schedule:L8.reduce((E,D)=>{const L=l[D];return E[D]=(B,$=!1,V=!1)=>(r||k(),L.schedule(B,$,V)),E},{}),cancel:E=>{for(let D=0;D(Rse===void 0&&bh.set(pu.isProcessing||j0.useManualTiming?pu.timestamp:performance.now()),Rse),set:t=>{Rse=t,queueMicrotask(Rds)}},IYe=t=>s=>typeof s=="string"&&s.startsWith(t),PYe=IYe("--"),Fds=IYe("var(--"),mwe=t=>Fds(t)?zds.test(t.split("/*")[0].trim()):!1,zds=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function pPe(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const hM={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},c6={...hM,transform:t=>Vx(0,1,t)},D8={...hM,default:1},CI=t=>Math.round(t*1e5)/1e5,pwe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Bds(t){return t==null}const $ds=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,fwe=(t,s)=>r=>!!(typeof r=="string"&&$ds.test(r)&&r.startsWith(t)||s&&!Bds(r)&&Object.prototype.hasOwnProperty.call(r,s)),LYe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(pwe);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},Uds=t=>Vx(0,255,t),Sme={...hM,transform:t=>Math.round(Uds(t))},rk={test:fwe("rgb","red"),parse:LYe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Sme.transform(t)+", "+Sme.transform(s)+", "+Sme.transform(r)+", "+CI(c6.transform(n))+")"};function qds(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 Tye={test:fwe("#"),parse:qds,transform:rk.transform},pL=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),Sv=pL("deg"),Ox=pL("%"),Gn=pL("px"),Vds=pL("vh"),Hds=pL("vw"),fPe={...Ox,parse:t=>Ox.parse(t)/100,transform:t=>Ox.transform(t*100)},u4={test:fwe("hsl","hue"),parse:LYe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+Ox.transform(CI(s))+", "+Ox.transform(CI(r))+", "+CI(c6.transform(n))+")"},ld={test:t=>rk.test(t)||Tye.test(t)||u4.test(t),parse:t=>rk.test(t)?rk.parse(t):u4.test(t)?u4.parse(t):Tye.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?rk.transform(t):u4.transform(t),getAnimatableNone:t=>{const s=ld.parse(t);return s.alpha=0,ld.transform(s)}},Wds=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Gds(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(pwe))==null?void 0:s.length)||0)+(((r=t.match(Wds))==null?void 0:r.length)||0)>0}const DYe="number",OYe="color",Kds="var",Zds="var(",gPe="${}",Yds=/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 w3(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(Yds,d=>(ld.test(d)?(n.color.push(o),a.push(OYe),r.push(ld.parse(d))):d.startsWith(Zds)?(n.var.push(o),a.push(Kds),r.push(d)):(n.number.push(o),a.push(DYe),r.push(parseFloat(d))),++o,gPe)).split(gPe);return{values:r,split:i,indexes:n,types:a}}function Xds(t){return w3(t).values}function RYe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:ld.test(t)?ld.getAnimatableNone(t):t,eus=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:Jds(t);function tus(t){const s=w3(t);return RYe(s)(s.values.map((n,a)=>eus(n,s.split[a])))}const xg={test:Gds,parse:Xds,createTransformer:Qds,getAnimatableNone:tus};function Cme(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 sus({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=Cme(d,i,t+1/3),o=Cme(d,i,t),l=Cme(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function qae(t,s){return r=>r>0?s:t}const rc=(t,s,r)=>t+(s-t)*r,Mme=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},rus=[Tye,rk,u4],nus=t=>rus.find(s=>s.test(t));function xPe(t){const s=nus(t);if(!s)return!1;let r=s.parse(t);return s===u4&&(r=sus(r)),r}const yPe=(t,s)=>{const r=xPe(t),n=xPe(s);if(!r||!n)return qae(t,s);const a={...r};return o=>(a.red=Mme(r.red,n.red,o),a.green=Mme(r.green,n.green,o),a.blue=Mme(r.blue,n.blue,o),a.alpha=rc(r.alpha,n.alpha,o),rk.transform(a))},Aye=new Set(["none","hidden"]);function aus(t,s){return Aye.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function ius(t,s){return r=>rc(t,s,r)}function gwe(t){return typeof t=="number"?ius:typeof t=="string"?mwe(t)?qae:ld.test(t)?yPe:cus:Array.isArray(t)?FYe:typeof t=="object"?ld.test(t)?yPe:ous:qae}function FYe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>gwe(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function lus(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=xg.createTransformer(s),n=w3(t),a=w3(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?Aye.has(t)&&!a.values.length||Aye.has(s)&&!n.values.length?aus(t,s):hL(FYe(lus(n,a),a.values),r):qae(t,s)};function zYe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?rc(t,s,r):gwe(t)(t,s)}const dus=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>yl.update(s,r),stop:()=>e_(s),now:()=>pu.isProcessing?pu.timestamp:bh.now()}},BYe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Vae?1/0:s}function uus(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(xwe(n),Vae);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:qp(a)}}const bc={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 Eye(t,s){return t*Math.sqrt(1-s*s)}const hus=12;function mus(t,s,r){let n=r;for(let a=1;a{const f=h*l,g=f*t,v=f-r,_=Eye(h,l),j=Math.exp(-g);return Tme-v/_*j},o=h=>{const g=h*l*t,v=g*r+r,_=Math.pow(l,2)*Math.pow(h,2)*t,j=Math.exp(-g),w=Eye(Math.pow(h,2),l);return(-a(h)+Tme>0?-1:1)*((v-_)*j)/w}):(a=h=>{const f=Math.exp(-h*t),g=(h-r)*t+1;return-Tme+f*g},o=h=>{const f=Math.exp(-h*t),g=(r-h)*(t*t);return f*g});const i=5/t,d=mus(a,o,i);if(t=np(t),isNaN(d))return{stiffness:bc.stiffness,damping:bc.damping,duration:t};{const h=Math.pow(d,2)*n;return{stiffness:h,damping:l*2*Math.sqrt(n*h),duration:t}}}const fus=["duration","bounce"],gus=["stiffness","damping","mass"];function vPe(t,s){return s.some(r=>t[r]!==void 0)}function xus(t){let s={velocity:bc.velocity,stiffness:bc.stiffness,damping:bc.damping,mass:bc.mass,isResolvedFromDuration:!1,...t};if(!vPe(t,gus)&&vPe(t,fus))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*Vx(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:bc.mass,stiffness:a,damping:o}}else{const r=pus({...t,velocity:0});s={...s,...r,mass:bc.mass},s.isResolvedFromDuration=!0}return s}function Hae(t=bc.visualDuration,s=bc.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:h,mass:f,duration:g,velocity:v,isResolvedFromDuration:_}=xus({...r,velocity:-qp(r.velocity||0)}),j=v||0,w=h/(2*Math.sqrt(d*f)),k=l-o,M=qp(Math.sqrt(d/f)),S=Math.abs(k)<5;n||(n=S?bc.restSpeed.granular:bc.restSpeed.default),a||(a=S?bc.restDelta.granular:bc.restDelta.default);let E,D,L,B,$,V;if(w<1)L=Eye(M,w),B=(j+w*M*k)/L,E=G=>{const J=Math.exp(-w*M*G);return l-J*(B*Math.sin(L*G)+k*Math.cos(L*G))},$=w*M*B+k*L,V=w*M*k-B*L,D=G=>Math.exp(-w*M*G)*($*Math.sin(L*G)+V*Math.cos(L*G));else if(w===1){E=J=>l-Math.exp(-M*J)*(k+(j+M*k)*J);const G=j+M*k;D=J=>Math.exp(-M*J)*(M*G*J-j)}else{const G=M*Math.sqrt(w*w-1);E=ee=>{const de=Math.exp(-w*M*ee),oe=Math.min(G*ee,300);return l-de*((j+w*M*k)*Math.sinh(oe)+G*k*Math.cosh(oe))/G};const J=(j+w*M*k)/G,ne=w*M*J-k*G,ie=w*M*k-J*G;D=ee=>{const de=Math.exp(-w*M*ee),oe=Math.min(G*ee,300);return de*(ne*Math.sinh(oe)+ie*Math.cosh(oe))}}const W={calculatedDuration:_&&g||null,velocity:G=>np(D(G)),next:G=>{if(!_&&w<1){const ne=Math.exp(-w*M*G),ie=Math.sin(L*G),ee=Math.cos(L*G),de=l-ne*(B*ie+k*ee),oe=np(ne*($*ie+V*ee));return i.done=Math.abs(oe)<=n&&Math.abs(l-de)<=a,i.value=i.done?l:de,i}const J=E(G);if(_)i.done=G>=g;else{const ne=np(D(G));i.done=Math.abs(ne)<=n&&Math.abs(l-J)<=a}return i.value=i.done?l:J,i},toString:()=>{const G=Math.min(xwe(W),Vae),J=BYe(ne=>W.next(G*ne).value,G,30);return G+"ms "+J},toTransition:()=>{}};return W}Hae.applyToOptions=t=>{const s=uus(t,100,Hae);return t.ease=s.ease,t.duration=np(s.duration),t.type="keyframes",t};const yus=5;function $Ye(t,s,r){const n=Math.max(s-yus,0);return _Ye(r-t(n),s-n)}function Iye({keyframes:t,velocity:s=0,power:r=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:d,restDelta:h=.5,restSpeed:f}){const g=t[0],v={done:!1,value:g},_=V=>i!==void 0&&Vd,j=V=>i===void 0?d:d===void 0||Math.abs(i-V)-w*Math.exp(-V/n),E=V=>M+S(V),D=V=>{const W=S(V),G=E(V);v.done=Math.abs(W)<=h,v.value=v.done?M:G};let L,B;const $=V=>{_(v.value)&&(L=V,B=Hae({keyframes:[v.value,j(v.value)],velocity:$Ye(E,V,v.value),damping:a,stiffness:o,restDelta:h,restSpeed:f}))};return $(0),{calculatedDuration:null,next:V=>{let W=!1;return!B&&L===void 0&&(W=!0,D(V),$(V)),L!==void 0&&V>=L?B.next(V-L):(!W&&D(V),v)}}}function vus(t,s,r){const n=[],a=r||j0.mix||zYe,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=vus(s,n,a),d=i.length,h=f=>{if(l&&f1)for(;gh(Vx(t[0],t[o-1],f)):h}function bus(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=l6(0,s,n);t.push(rc(r,1,a))}}function wus(t){const s=[0];return bus(s,t.length-1),s}function jus(t,s){return t.map(r=>r*s)}function kus(t,s){return t.map(()=>s||TYe).splice(0,t.length-1)}function MI({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=Ids(n)?n.map(mPe):mPe(n),o={done:!1,value:s[0]},l=jus(r&&r.length===s.length?r:wus(s),t),i=_us(l,s,{ease:Array.isArray(a)?a:kus(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const Nus=t=>t!==null;function ywe(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(Nus),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const Sus={decay:Iye,inertia:Iye,tween:MI,keyframes:MI,spring:Hae};function UYe(t){typeof t.type=="string"&&(t.type=Sus[t.type])}class vwe{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 Cus=t=>t/100;class _we extends vwe{constructor(s){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var n,a;const{motionValue:r}=this.options;r&&r.updatedAt!==bh.now()&&this.tick(bh.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;UYe(s);const{type:r=MI,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const d=r||MI;d!==MI&&typeof i[0]!="number"&&(this.mixKeyframes=hL(Cus,zYe(i[0],i[1])),i=[0,100]);const h=d({...s,keyframes:i});o==="mirror"&&(this.mirroredGenerator=d({...s,keyframes:[...i].reverse(),velocity:-l})),h.calculatedDuration===null&&(h.calculatedDuration=xwe(h));const{calculatedDuration:f}=h;this.calculatedDuration=f,this.resolvedDuration=f+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=h}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:h=0,keyframes:f,repeat:g,repeatType:v,repeatDelay:_,type:j,onUpdate:w,finalKeyframe:k}=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 M=this.currentTime-h*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?M<0:M>a;this.currentTime=Math.max(M,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let E=this.currentTime,D=n;if(g){const V=Math.min(this.currentTime,a)/i;let W=Math.floor(V),G=V%1;!G&&V>=1&&(G=1),G===1&&W--,W=Math.min(W,g+1),!!(W%2)&&(v==="reverse"?(G=1-G,_&&(G-=_/i)):v==="mirror"&&(D=l)),E=Vx(0,1,G)*i}const L=S?{done:!1,value:f[0]}:D.next(E);o&&!S&&(L.value=o(L.value));let{done:B}=L;!S&&d!==null&&(B=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&B);return $&&j!==Iye&&(L.value=ywe(f,this.options,k,this.speed)),w&&w(L.value),$&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return qp(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+qp(s)}get time(){return qp(this.currentTime)}set time(s){s=np(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 $Ye(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(bh.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=qp(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=dus,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(bh.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 Mus(t){for(let s=1;st*180/Math.PI,Pye=t=>{const s=nk(Math.atan2(t[1],t[0]));return Lye(s)},Tus={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Pye,rotateZ:Pye,skewX:t=>nk(Math.atan(t[1])),skewY:t=>nk(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Lye=t=>(t=t%360,t<0&&(t+=360),t),_Pe=Pye,bPe=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),wPe=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Aus={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:bPe,scaleY:wPe,scale:t=>(bPe(t)+wPe(t))/2,rotateX:t=>Lye(nk(Math.atan2(t[6],t[5]))),rotateY:t=>Lye(nk(Math.atan2(-t[2],t[0]))),rotateZ:_Pe,rotate:_Pe,skewX:t=>nk(Math.atan(t[4])),skewY:t=>nk(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Dye(t){return t.includes("scale")?1:0}function Oye(t,s){if(!t||t==="none")return Dye(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=Aus,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=Tus,a=i}if(!a)return Dye(s);const o=n[s],l=a[1].split(",").map(Ius);return typeof o=="function"?o(l):l[o]}const Eus=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return Oye(r,s)};function Ius(t){return parseFloat(t.trim())}const mM=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],pM=new Set(mM),jPe=t=>t===hM||t===Gn,Pus=new Set(["x","y","z"]),Lus=mM.filter(t=>!Pus.has(t));function Dus(t){const s=[];return Lus.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const p1={width:({x:t},{paddingLeft:s="0",paddingRight:r="0"})=>t.max-t.min-parseFloat(s)-parseFloat(r),height:({y:t},{paddingTop:s="0",paddingBottom:r="0"})=>t.max-t.min-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})=>Oye(s,"x"),y:(t,{transform:s})=>Oye(s,"y")};p1.translateX=p1.x;p1.translateY=p1.y;const Hk=new Set;let Rye=!1,Fye=!1,zye=!1;function qYe(){if(Fye){const t=Array.from(Hk).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=Dus(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)})}Fye=!1,Rye=!1,Hk.forEach(t=>t.complete(zye)),Hk.clear()}function VYe(){Hk.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Fye=!0)})}function Ous(){zye=!0,VYe(),qYe(),zye=!1}class bwe{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?(Hk.add(this),Rye||(Rye=!0,yl.read(VYe),yl.resolveKeyframes(qYe))):(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])}Mus(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),Hk.delete(this)}cancel(){this.state==="scheduled"&&(Hk.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Rus=t=>t.startsWith("--");function HYe(t,s,r){Rus(s)?t.style.setProperty(s,r):t.style[s]=r}const Fus={};function WYe(t,s){const r=vYe(t);return()=>Fus[s]??r()}const zus=WYe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),GYe=WYe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),oE=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,kPe={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:oE([0,.65,.55,1]),circOut:oE([.55,0,1,.45]),backIn:oE([.31,.01,.66,-.59]),backOut:oE([.33,1.53,.69,.99])};function KYe(t,s){if(t)return typeof t=="function"?GYe()?BYe(t,s):"ease-out":AYe(t)?oE(t):Array.isArray(t)?t.map(r=>KYe(r,s)||kPe.easeOut):kPe[t]}function Bus(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:d}={},h=void 0){const f={[s]:r};d&&(f.offset=d);const g=KYe(i,a);Array.isArray(g)&&(f.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 h&&(v.pseudoElement=h),t.animate(f,v)}function ZYe(t){return typeof t=="function"&&"applyToOptions"in t}function $us({type:t,...s}){return ZYe(t)&&GYe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class YYe extends vwe{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,cwe(typeof s.type!="string");const h=$us(s);this.animation=Bus(r,n,a,h,o),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const f=ywe(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(f),HYe(r,n,f),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 qp(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+qp(s)}get time(){return qp(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=np(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&&zus()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),ef):a(this)}}const XYe={anticipate:SYe,backInOut:NYe,circInOut:MYe};function Uus(t){return t in XYe}function qus(t){typeof t.ease=="string"&&Uus(t.ease)&&(t.ease=XYe[t.ease])}const Ame=10;class Vus extends YYe{constructor(s){qus(s),UYe(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 _we({...l,autoplay:!1}),d=Math.max(Ame,bh.now()-this.startTime),h=Vx(0,Ame,d-Ame),f=i.sample(d).value,{name:g}=this.options;o&&g&&HYe(o,g,f),r.setWithVelocity(i.sample(Math.max(0,d-h)).value,f,h),i.stop()}}const NPe=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(xg.test(t)||t==="0")&&!t.startsWith("url("));function Hus(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function Zus(t){var f;const{motionValue:s,name:r,repeatDelay:n,repeatType:a,damping:o,type:l}=t;if(!(((f=s==null?void 0:s.owner)==null?void 0:f.current)instanceof HTMLElement))return!1;const{onUpdate:d,transformTemplate:h}=s.owner.getProps();return Kus()&&r&&Gus.has(r)&&(r!=="transform"||!h)&&!d&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const Yus=40;class Xus extends vwe{constructor({autoplay:s=!0,delay:r=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:d,motionValue:h,element:f,...g}){var j;super(),this.stop=()=>{var w,k;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(k=this.keyframeResolver)==null||k.cancel()},this.createdAt=bh.now();const v={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:h,element:f,...g},_=(f==null?void 0:f.KeyframeResolver)||bwe;this.keyframeResolver=new _(i,(w,k,M)=>this.onKeyframesResolved(w,k,v,!M),d,h,f),(j=this.keyframeResolver)==null||j.scheduleResolve()}onKeyframesResolved(s,r,n,a){var k,M;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:h,onUpdate:f}=n;this.resolvedAt=bh.now(),Wus(s,o,l,i)||((j0.instantAnimations||!d)&&(f==null||f(ywe(s,n,r))),s[0]=s[s.length-1],Bye(n),n.repeat=0);const v={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>Yus?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},_=!h&&Zus(v),j=(M=(k=v.motionValue)==null?void 0:k.owner)==null?void 0:M.current,w=_?new Vus({...v,element:j}):new _we(v);w.finished.then(()=>{this.notifyFinished()}).catch(ef),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(),Ous()),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 QYe(t,s,r,n=0,a=1){const o=Array.from(t).sort((h,f)=>h.sortNodePosition(f)).indexOf(s),l=t.size,i=(l-1)*n;return typeof r=="function"?r(o,l):a===1?o*n:i-o*n}const Qus=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Jus(t){const s=Qus.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function JYe(t,s,r=1){const[n,a]=Jus(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return gYe(l)?parseFloat(l):l}return mwe(a)?JYe(a,s,r+1):a}const ehs={type:"spring",stiffness:500,damping:25,restSpeed:10},ths=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),shs={type:"keyframes",duration:.8},rhs={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},nhs=(t,{keyframes:s})=>s.length>2?shs:pM.has(t)?t.startsWith("scale")?ths(s[1]):ehs:rhs,ahs=t=>t!==null;function ihs(t,{repeat:s,repeatType:r="loop"},n){const a=t.filter(ahs),o=s&&r!=="loop"&&s%2===1?0:a.length-1;return a[o]}function eXe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function wwe(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?eXe(r,t):r}function ohs({when:t,delay:s,delayChildren:r,staggerChildren:n,staggerDirection:a,repeat:o,repeatType:l,repeatDelay:i,from:d,elapsed:h,...f}){return!!Object.keys(f).length}const jwe=(t,s,r,n={},a,o)=>l=>{const i=wwe(n,t)||{},d=i.delay||n.delay||0;let{elapsed:h=0}=n;h=h-np(d);const f={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-h,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};ohs(i)||Object.assign(f,nhs(t,f)),f.duration&&(f.duration=np(f.duration)),f.repeatDelay&&(f.repeatDelay=np(f.repeatDelay)),f.from!==void 0&&(f.keyframes[0]=f.from);let g=!1;if((f.type===!1||f.duration===0&&!f.repeatDelay)&&(Bye(f),f.delay===0&&(g=!0)),(j0.instantAnimations||j0.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(g=!0,Bye(f),f.delay=0),f.allowFlatten=!i.type&&!i.ease,g&&!o&&s.get()!==void 0){const v=ihs(f.keyframes,i);if(v!==void 0){yl.update(()=>{f.onUpdate(v),f.onComplete()});return}}return i.isSync?new _we(f):new Xus(f)};function SPe(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function kwe(t,s,r,n){if(typeof s=="function"){const[a,o]=SPe(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]=SPe(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function h5(t,s,r){const n=t.getProps();return kwe(n,s,r!==void 0?r:n.custom,t)}const tXe=new Set(["width","height","top","left","right","bottom",...mM]),CPe=30,lhs=t=>!isNaN(parseFloat(t));class chs{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=bh.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=bh.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=lhs(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 dwe);const n=this.events[s].add(r);return s==="change"?()=>{n(),yl.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=bh.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>CPe)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,CPe);return _Ye(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 j3(t,s){return new chs(t,s)}const $ye=t=>Array.isArray(t);function dhs(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,j3(r))}function uhs(t){return $ye(t)?t[t.length-1]||0:t}function hhs(t,s){const r=h5(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=uhs(o[l]);dhs(t,l,i)}}const Ru=t=>!!(t&&t.getVelocity);function mhs(t){return!!(Ru(t)&&t.add)}function Uye(t,s){const r=t.getValue("willChange");if(mhs(r))return r.add(s);if(!r&&j0.WillChange){const n=new j0.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function Nwe(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const phs="framerAppearId",sXe="data-"+Nwe(phs);function rXe(t){return t.props[sXe]}function fhs({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function nXe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const d=t.getDefaultTransition();o=o?eXe(o,d):d;const h=o==null?void 0:o.reduceMotion;n&&(o=n);const f=[],g=a&&t.animationState&&t.animationState.getState()[a];for(const v in i){const _=t.getValue(v,t.latestValues[v]??null),j=i[v];if(j===void 0||g&&fhs(g,v))continue;const w={delay:r,...wwe(o||{},v)},k=_.get();if(k!==void 0&&!_.isAnimating&&!Array.isArray(j)&&j===k&&!w.velocity)continue;let M=!1;if(window.MotionHandoffAnimation){const D=rXe(t);if(D){const L=window.MotionHandoffAnimation(D,v,yl);L!==null&&(w.startTime=L,M=!0)}}Uye(t,v);const S=h??t.shouldReduceMotion;_.start(jwe(v,_,j,S&&tXe.has(v)?{type:!1}:w,t,M));const E=_.animation;E&&f.push(E)}if(l){const v=()=>yl.update(()=>{l&&hhs(t,l)});f.length?Promise.all(f).then(v):v()}return f}function qye(t,s,r={}){var d;const n=h5(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(nXe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(h=0)=>{const{delayChildren:f=0,staggerChildren:g,staggerDirection:v}=a;return ghs(t,s,h,f,g,v,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[h,f]=i==="beforeChildren"?[o,l]:[l,o];return h().then(()=>f())}else return Promise.all([o(),l(r.delay)])}function ghs(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(qye(d,s,{...l,delay:r+(typeof n=="function"?0:n)+QYe(t.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",s)));return Promise.all(i)}function xhs(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>qye(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=qye(t,s,r);else{const a=typeof s=="function"?h5(t,s,r.custom):s;n=Promise.all(nXe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const yhs={test:t=>t==="auto",parse:t=>t},aXe=t=>s=>s.test(t),iXe=[hM,Gn,Ox,Sv,Hds,Vds,yhs],MPe=t=>iXe.find(aXe(t));function vhs(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||yYe(t):!0}const _hs=new Set(["brightness","contrast","saturate","opacity"]);function bhs(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(pwe)||[];if(!n)return t;const a=r.replace(n,"");let o=_hs.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const whs=/\b([a-z-]*)\(.*?\)/gu,Vye={...xg,getAnimatableNone:t=>{const s=t.match(whs);return s?s.map(bhs).join(" "):t}},Hye={...xg,getAnimatableNone:t=>{const s=xg.parse(t);return xg.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},TPe={...hM,transform:Math.round},jhs={rotate:Sv,rotateX:Sv,rotateY:Sv,rotateZ:Sv,scale:D8,scaleX:D8,scaleY:D8,scaleZ:D8,skew:Sv,skewX:Sv,skewY:Sv,distance:Gn,translateX:Gn,translateY:Gn,translateZ:Gn,x:Gn,y:Gn,z:Gn,perspective:Gn,transformPerspective:Gn,opacity:c6,originX:fPe,originY:fPe,originZ:Gn},Swe={borderWidth:Gn,borderTopWidth:Gn,borderRightWidth:Gn,borderBottomWidth:Gn,borderLeftWidth:Gn,borderRadius:Gn,borderTopLeftRadius:Gn,borderTopRightRadius:Gn,borderBottomRightRadius:Gn,borderBottomLeftRadius:Gn,width:Gn,maxWidth:Gn,height:Gn,maxHeight:Gn,top:Gn,right:Gn,bottom:Gn,left:Gn,inset:Gn,insetBlock:Gn,insetBlockStart:Gn,insetBlockEnd:Gn,insetInline:Gn,insetInlineStart:Gn,insetInlineEnd:Gn,padding:Gn,paddingTop:Gn,paddingRight:Gn,paddingBottom:Gn,paddingLeft:Gn,paddingBlock:Gn,paddingBlockStart:Gn,paddingBlockEnd:Gn,paddingInline:Gn,paddingInlineStart:Gn,paddingInlineEnd:Gn,margin:Gn,marginTop:Gn,marginRight:Gn,marginBottom:Gn,marginLeft:Gn,marginBlock:Gn,marginBlockStart:Gn,marginBlockEnd:Gn,marginInline:Gn,marginInlineStart:Gn,marginInlineEnd:Gn,fontSize:Gn,backgroundPositionX:Gn,backgroundPositionY:Gn,...jhs,zIndex:TPe,fillOpacity:c6,strokeOpacity:c6,numOctaves:TPe},khs={...Swe,color:ld,backgroundColor:ld,outlineColor:ld,fill:ld,stroke:ld,borderColor:ld,borderTopColor:ld,borderRightColor:ld,borderBottomColor:ld,borderLeftColor:ld,filter:Vye,WebkitFilter:Vye,mask:Hye,WebkitMask:Hye},oXe=t=>khs[t],Nhs=new Set([Vye,Hye]);function lXe(t,s){let r=oXe(t);return Nhs.has(r)||(r=xg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const Shs=new Set(["auto","none","0"]);function Chs(t,s,r){let n=0,a;for(;n{s.getValue(d).set(h)}),this.resolveNoneKeyframes()}}const Ths=new Set(["opacity","clipPath","filter","transform"]);function cXe(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 dXe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function Ahs(t){return xYe(t)&&"offsetHeight"in t}const{schedule:Cwe}=EYe(queueMicrotask,!1),Vf={x:!1,y:!1};function uXe(){return Vf.x||Vf.y}function Ehs(t){return t==="x"||t==="y"?Vf[t]?null:(Vf[t]=!0,()=>{Vf[t]=!1}):Vf.x||Vf.y?null:(Vf.x=Vf.y=!0,()=>{Vf.x=Vf.y=!1})}function hXe(t,s){const r=cXe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function Ihs(t){return!(t.pointerType==="touch"||uXe())}function Phs(t,s,r={}){const[n,a,o]=hXe(t,r);return n.forEach(l=>{let i=!1,d=!1,h;const f=()=>{l.removeEventListener("pointerleave",j)},g=k=>{h&&(h(k),h=void 0),f()},v=k=>{i=!1,window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),d&&(d=!1,g(k))},_=()=>{i=!0,window.addEventListener("pointerup",v,a),window.addEventListener("pointercancel",v,a)},j=k=>{if(k.pointerType!=="touch"){if(i){d=!0;return}g(k)}},w=k=>{if(!Ihs(k))return;d=!1;const M=s(l,k);typeof M=="function"&&(h=M,l.addEventListener("pointerleave",j,a))};l.addEventListener("pointerenter",w,a),l.addEventListener("pointerdown",_,a)}),o}const mXe=(t,s)=>s?t===s?!0:mXe(t,s.parentElement):!1,Mwe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Lhs=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Dhs(t){return Lhs.has(t.tagName)||t.isContentEditable===!0}const Ohs=new Set(["INPUT","SELECT","TEXTAREA"]);function Rhs(t){return Ohs.has(t.tagName)||t.isContentEditable===!0}const Fse=new WeakSet;function APe(t){return s=>{s.key==="Enter"&&t(s)}}function Eme(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const Fhs=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=APe(()=>{if(Fse.has(r))return;Eme(r,"down");const a=APe(()=>{Eme(r,"up")}),o=()=>Eme(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 EPe(t){return Mwe(t)&&!uXe()}const IPe=new WeakSet;function zhs(t,s,r={}){const[n,a,o]=hXe(t,r),l=i=>{const d=i.currentTarget;if(!EPe(i)||IPe.has(i))return;Fse.add(d),r.stopPropagation&&IPe.add(i);const h=s(d,i),f=(_,j)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",v),Fse.has(d)&&Fse.delete(d),EPe(_)&&typeof h=="function"&&h(_,{success:j})},g=_=>{f(_,d===window||d===document||r.useGlobalTarget||mXe(d,_.target))},v=_=>{f(_,!1)};window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",v,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),Ahs(i)&&(i.addEventListener("focus",h=>Fhs(h,a)),!Dhs(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function Twe(t){return xYe(t)&&"ownerSVGElement"in t}const zse=new WeakMap;let Cv;const pXe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:Twe(n)&&"getBBox"in n?n.getBBox()[s]:n[r],Bhs=pXe("inline","width","offsetWidth"),$hs=pXe("block","height","offsetHeight");function Uhs({target:t,borderBoxSize:s}){var r;(r=zse.get(t))==null||r.forEach(n=>{n(t,{get width(){return Bhs(t,s)},get height(){return $hs(t,s)}})})}function qhs(t){t.forEach(Uhs)}function Vhs(){typeof ResizeObserver>"u"||(Cv=new ResizeObserver(qhs))}function Hhs(t,s){Cv||Vhs();const r=cXe(t);return r.forEach(n=>{let a=zse.get(n);a||(a=new Set,zse.set(n,a)),a.add(s),Cv==null||Cv.observe(n)}),()=>{r.forEach(n=>{const a=zse.get(n);a==null||a.delete(s),a!=null&&a.size||Cv==null||Cv.unobserve(n)})}}const Bse=new Set;let h4;function Whs(){h4=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Bse.forEach(s=>s(t))},window.addEventListener("resize",h4)}function Ghs(t){return Bse.add(t),h4||Whs(),()=>{Bse.delete(t),!Bse.size&&typeof h4=="function"&&(window.removeEventListener("resize",h4),h4=void 0)}}function PPe(t,s){return typeof t=="function"?Ghs(t):Hhs(t,s)}function Khs(t){return Twe(t)&&t.tagName==="svg"}const Zhs=[...iXe,ld,xg],Yhs=t=>Zhs.find(aXe(t)),LPe=()=>({translate:0,scale:1,origin:0,originPoint:0}),m4=()=>({x:LPe(),y:LPe()}),DPe=()=>({min:0,max:0}),wd=()=>({x:DPe(),y:DPe()}),Xhs=new WeakMap;function Ule(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function d6(t){return typeof t=="string"||Array.isArray(t)}const Awe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ewe=["initial",...Awe];function qle(t){return Ule(t.animate)||Ewe.some(s=>d6(t[s]))}function fXe(t){return!!(qle(t)||t.variants)}function Qhs(t,s,r){for(const n in s){const a=s[n],o=r[n];if(Ru(a))t.addValue(n,a);else if(Ru(o))t.addValue(n,j3(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,j3(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const Wye={current:null},gXe={current:!1},Jhs=typeof window<"u";function ems(){if(gXe.current=!0,!!Jhs)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>Wye.current=t.matches;t.addEventListener("change",s),s()}else Wye.current=!1}const OPe=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Wae={};function xXe(t){Wae=t}function tms(){return Wae}class sms{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=bwe,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 _=bh.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,yl.render(this.render,!1,!0))};const{latestValues:h,renderState:f}=i;this.latestValues=h,this.baseTarget={...h},this.initialValues=r.initial?{...h}:{},this.renderState=f,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=qle(r),this.isVariantNode=fXe(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 j=v[_];h[_]!==void 0&&Ru(j)&&j.set(h[_])}}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,Xhs.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:(gXe.current||ems(),this.shouldReduceMotion=Wye.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(),e_(this.notifyUpdate),e_(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&&Ths.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:h,duration:f}=r.accelerate,g=new YYe({element:this.current,name:s,keyframes:i,times:d,ease:h,duration:np(f)}),v=l(g);this.valueSubscriptions.set(s,()=>{v(),g.cancel()});return}const n=pM.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&yl.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 Wae){const r=Wae[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):wd()}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=j3(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"&&(gYe(n)||yYe(n))?n=parseFloat(n):!Yhs(n)&&xg.test(r)&&(n=lXe(s,r)),this.setBaseTarget(s,Ru(n)?n.get():n)),Ru(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=kwe(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&&!Ru(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 dwe),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){Cwe.render(this.render)}}class yXe extends sms{constructor(){super(...arguments),this.KeyframeResolver=Mhs}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;Ru(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class b_{constructor(s){this.isMounted=!1,this.node=s}update(){}}function vXe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function rms({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function nms(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 Ime(t){return t===void 0||t===1}function Gye({scale:t,scaleX:s,scaleY:r}){return!Ime(t)||!Ime(s)||!Ime(r)}function Rj(t){return Gye(t)||_Xe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function _Xe(t){return RPe(t.x)||RPe(t.y)}function RPe(t){return t&&t!=="0%"}function Gae(t,s,r){const n=t-r,a=s*n;return r+a}function FPe(t,s,r,n,a){return a!==void 0&&(t=Gae(t,a,n)),Gae(t,r,n)+s}function Kye(t,s=0,r=1,n,a){t.min=FPe(t.min,s,r,n,a),t.max=FPe(t.max,s,r,n,a)}function bXe(t,{x:s,y:r}){Kye(t.x,s.translate,s.scale,s.originPoint),Kye(t.y,r.translate,r.scale,r.originPoint)}const zPe=.999999999999,BPe=1.0000000000001;function ams(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;dzPe&&(s.x=1),s.yzPe&&(s.y=1)}function p4(t,s){t.min=t.min+s,t.max=t.max+s}function $Pe(t,s,r,n,a=.5){const o=rc(t.min,t.max,a);Kye(t,s,r,o,n)}function UPe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function f4(t,s,r){const n=r??t;$Pe(t.x,UPe(s.x,n.x),s.scaleX,s.scale,s.originX),$Pe(t.y,UPe(s.y,n.y),s.scaleY,s.scale,s.originY)}function wXe(t,s){return vXe(nms(t.getBoundingClientRect(),s))}function ims(t,s,r){const n=wXe(t,r),{scroll:a}=s;return a&&(p4(n.x,a.offset.x),p4(n.y,a.offset.y)),n}const oms={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},lms=mM.length;function cms(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(Gn.test(t))t=parseFloat(t);else return t;const r=qPe(t,s.target.x),n=qPe(t,s.target.y);return`${r}% ${n}%`}},dms={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=xg.parse(t);if(a.length>5)return n;const o=xg.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 h=rc(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=h),typeof a[3+l]=="number"&&(a[3+l]/=h),o(a)}},Zye={borderRadius:{...qA,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:qA,borderTopRightRadius:qA,borderBottomLeftRadius:qA,borderBottomRightRadius:qA,boxShadow:dms};function kXe(t,{layout:s,layoutId:r}){return pM.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!Zye[t]||t==="opacity")}function Pwe(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)(Ru(n[i])||a&&Ru(a[i])||kXe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function ums(t){return window.getComputedStyle(t)}class hms extends yXe{constructor(){super(...arguments),this.type="html",this.renderInstance=jXe}readValueFromInstance(s,r){var n;if(pM.has(r))return(n=this.projection)!=null&&n.isProjecting?Dye(r):Eus(s,r);{const a=ums(s),o=(PYe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return wXe(s,r)}build(s,r,n){Iwe(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return Pwe(s,r,n)}}const mms={offset:"stroke-dashoffset",array:"stroke-dasharray"},pms={offset:"strokeDashoffset",array:"strokeDasharray"};function fms(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?mms:pms;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const gms=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function NXe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,h,f){if(Iwe(t,i,h),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=(f==null?void 0:f.transformBox)??"fill-box",delete g.transformBox);for(const _ of gms)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&&fms(g,a,o,l,!1)}const SXe=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"]),CXe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function xms(t,s,r,n){jXe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(SXe.has(a)?a:Nwe(a),s.attrs[a])}function MXe(t,s,r){const n=Pwe(t,s,r);for(const a in t)if(Ru(t[a])||Ru(s[a])){const o=mM.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class yms extends yXe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=wd}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(pM.has(r)){const n=oXe(r);return n&&n.default||0}return r=SXe.has(r)?r:Nwe(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return MXe(s,r,n)}build(s,r,n){NXe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){xms(s,r,n,a)}mount(s){this.isSVGTag=CXe(s.tagName),super.mount(s)}}const vms=Ewe.length;function TXe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?TXe(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})=>xhs(t,r,n)))}function jms(t){let s=wms(t),r=VPe(),n=!0,a=!1;const o=h=>(f,g)=>{var _;const v=h5(t,g,h==="exit"?(_=t.presenceContext)==null?void 0:_.custom:void 0);if(v){const{transition:j,transitionEnd:w,...k}=v;f={...f,...k,...w}}return f};function l(h){s=h(t)}function i(h){const{props:f}=t,g=TXe(t.parent)||{},v=[],_=new Set;let j={},w=1/0;for(let M=0;Mw&&L,G=!1;const J=Array.isArray(D)?D:[D];let ne=J.reduce(o(S),{});B===!1&&(ne={});const{prevResolvedValues:ie={}}=E,ee={...ie,...ne},de=ce=>{W=!0,_.has(ce)&&(G=!0,_.delete(ce)),E.needsAnimating[ce]=!0;const ge=t.getValue(ce);ge&&(ge.liveStyle=!1)};for(const ce in ee){const ge=ne[ce],Te=ie[ce];if(j.hasOwnProperty(ce))continue;let ve=!1;$ye(ge)&&$ye(Te)?ve=!AXe(ge,Te):ve=ge!==Te,ve?ge!=null?de(ce):_.add(ce):ge!==void 0&&_.has(ce)?de(ce):E.protectedKeys[ce]=!0}E.prevProp=D,E.prevResolvedValues=ne,E.isActive&&(j={...j,...ne}),(n||a)&&t.blockInitialAnimation&&(W=!1);const oe=$&&V;W&&(!oe||G)&&v.push(...J.map(ce=>{const ge={type:S};if(typeof ce=="string"&&(n||a)&&!oe&&t.manuallyAnimateOnMount&&t.parent){const{parent:Te}=t,ve=h5(Te,ce);if(Te.enteringChildren&&ve){const{delayChildren:ye}=ve.transition||{};ge.delay=QYe(Te.enteringChildren,t,ye)}}return{animation:ce,options:ge}}))}if(_.size){const M={};if(typeof f.initial!="boolean"){const S=h5(t,Array.isArray(f.initial)?f.initial[0]:f.initial);S&&S.transition&&(M.transition=S.transition)}_.forEach(S=>{const E=t.getBaseTarget(S),D=t.getValue(S);D&&(D.liveStyle=!0),M[S]=E??null}),v.push({animation:M})}let k=!!v.length;return n&&(f.initial===!1||f.initial===f.animate)&&!t.manuallyAnimateOnMount&&(k=!1),n=!1,a=!1,k?s(v):Promise.resolve()}function d(h,f){var v;if(r[h].isActive===f)return Promise.resolve();(v=t.variantChildren)==null||v.forEach(_=>{var j;return(j=_.animationState)==null?void 0:j.setActive(h,f)}),r[h].isActive=f;const g=i(h);for(const _ in r)r[_].protectedKeys={};return g}return{animateChanges:i,setActive:d,setAnimateFunction:l,getState:()=>r,reset:()=>{r=VPe(),a=!0}}}function kms(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!AXe(s,t):!1}function xb(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function VPe(){return{animate:xb(!0),whileInView:xb(),whileHover:xb(),whileTap:xb(),whileDrag:xb(),whileFocus:xb(),exit:xb()}}function HPe(t,s){t.min=s.min,t.max=s.max}function zf(t,s){HPe(t.x,s.x),HPe(t.y,s.y)}function WPe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const EXe=1e-4,Nms=1-EXe,Sms=1+EXe,IXe=.01,Cms=0-IXe,Mms=0+IXe;function wh(t){return t.max-t.min}function Tms(t,s,r){return Math.abs(t-s)<=r}function GPe(t,s,r,n=.5){t.origin=n,t.originPoint=rc(s.min,s.max,t.origin),t.scale=wh(r)/wh(s),t.translate=rc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=Nms&&t.scale<=Sms||isNaN(t.scale))&&(t.scale=1),(t.translate>=Cms&&t.translate<=Mms||isNaN(t.translate))&&(t.translate=0)}function TI(t,s,r,n){GPe(t.x,s.x,r.x,n?n.originX:void 0),GPe(t.y,s.y,r.y,n?n.originY:void 0)}function KPe(t,s,r){t.min=r.min+s.min,t.max=t.min+wh(s)}function Ams(t,s,r){KPe(t.x,s.x,r.x),KPe(t.y,s.y,r.y)}function ZPe(t,s,r){t.min=s.min-r.min,t.max=t.min+wh(s)}function Kae(t,s,r){ZPe(t.x,s.x,r.x),ZPe(t.y,s.y,r.y)}function YPe(t,s,r,n,a){return t-=s,t=Gae(t,1/r,n),a!==void 0&&(t=Gae(t,1/a,n)),t}function Ems(t,s=0,r=1,n=.5,a,o=t,l=t){if(Ox.test(s)&&(s=parseFloat(s),s=rc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=rc(o.min,o.max,n);t===o&&(i-=s),t.min=YPe(t.min,s,r,i,a),t.max=YPe(t.max,s,r,i,a)}function XPe(t,s,[r,n,a],o,l){Ems(t,s[r],s[n],s[a],s.scale,o,l)}const Ims=["x","scaleX","originX"],Pms=["y","scaleY","originY"];function QPe(t,s,r,n){XPe(t.x,s,Ims,r?r.x:void 0,n?n.x:void 0),XPe(t.y,s,Pms,r?r.y:void 0,n?n.y:void 0)}function JPe(t){return t.translate===0&&t.scale===1}function PXe(t){return JPe(t.x)&&JPe(t.y)}function e6e(t,s){return t.min===s.min&&t.max===s.max}function Lms(t,s){return e6e(t.x,s.x)&&e6e(t.y,s.y)}function t6e(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function LXe(t,s){return t6e(t.x,s.x)&&t6e(t.y,s.y)}function s6e(t){return wh(t.x)/wh(t.y)}function r6e(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function lx(t){return[t("x"),t("y")]}function Dms(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:h,rotate:f,rotateX:g,rotateY:v,skewX:_,skewY:j}=r;h&&(n=`perspective(${h}px) ${n}`),f&&(n+=`rotate(${f}deg) `),g&&(n+=`rotateX(${g}deg) `),v&&(n+=`rotateY(${v}deg) `),_&&(n+=`skewX(${_}deg) `),j&&(n+=`skewY(${j}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 DXe=["TopLeft","TopRight","BottomLeft","BottomRight"],Oms=DXe.length,n6e=t=>typeof t=="string"?parseFloat(t):t,a6e=t=>typeof t=="number"||Gn.test(t);function Rms(t,s,r,n,a,o){a?(t.opacity=rc(0,r.opacity??1,Fms(n)),t.opacityExit=rc(s.opacity??1,0,zms(n))):o&&(t.opacity=rc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(l6(t,s,n))}function Bms(t,s,r){const n=Ru(t)?t:j3(t);return n.start(jwe("",n,s,r)),n.animation}function u6(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const $ms=(t,s)=>t.depth-s.depth;class Ums{constructor(){this.children=[],this.isDirty=!1}add(s){lwe(this.children,s),this.isDirty=!0}remove(s){Uae(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort($ms),this.isDirty=!1,this.children.forEach(s)}}function qms(t,s){const r=bh.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(e_(n),t(o-s))};return yl.setup(n,!0),()=>e_(n)}function $se(t){return Ru(t)?t.get():t}class Vms{constructor(){this.members=[]}add(s){lwe(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&&(Uae(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Uae(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 Use={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Pme=["","X","Y","Z"],Hms=1e3;let Wms=0;function Lme(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function RXe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=rXe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",yl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&RXe(n)}function FXe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=Wms++,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(Zms),this.nodes.forEach(Jms),this.nodes.forEach(eps),this.nodes.forEach(Yms)},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;yl.read(()=>{g=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==g&&(g=_,this.root.updateBlockedByResize=!0,f&&f(),f=qms(v,250),Use.hasAnimatedSinceResize&&(Use.hasAnimatedSinceResize=!1,this.nodes.forEach(c6e)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&h&&(i||d)&&this.addEventListener("didUpdate",({delta:f,hasLayoutChanged:g,hasRelativeLayoutChanged:v,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const j=this.options.transition||h.getDefaultTransition()||aps,{onLayoutAnimationStart:w,onLayoutAnimationComplete:k}=h.getProps(),M=!this.targetLayout||!LXe(this.targetLayout,_),S=!g&&v;if(this.options.layoutRoot||this.resumeFrom||S||g&&(M||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...wwe(j,"layout"),onPlay:w,onComplete:k};(h.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(f,S)}else g||c6e(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(),e_(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(tps),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&&RXe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let f=0;f{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!wh(this.snapshot.measuredBox.x)&&!wh(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=D/1e3;d6e(g.x,l.x,L),d6e(g.y,l.y,L),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Kae(v,this.layout.layoutBox,this.relativeParent.layout.layoutBox),rps(this.relativeTarget,this.relativeTargetOrigin,v,L),E&&Lms(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=wd()),zf(E,this.relativeTarget)),w&&(this.animationValues=f,Rms(f,h,this.latestValues,L,S,M)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,d,h;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(h=(d=this.resumingFrom)==null?void 0:d.currentAnimation)==null||h.stop(),this.pendingAnimation&&(e_(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=yl.update(()=>{Use.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=j3(0)),this.motionValue.jump(0,!1),this.currentAnimation=Bms(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:f=>{this.mixTargetDelta(f),l.onUpdate&&l.onUpdate(f)},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(Hms),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:d,layout:h,latestValues:f}=l;if(!(!i||!d||!h)){if(this!==l&&this.layout&&h&&zXe(this.options.animationType,this.layout.layoutBox,h.layoutBox)){d=this.target||wd();const g=wh(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const v=wh(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+v}zf(i,d),f4(i,f),TI(this.projectionDeltaWithTransform,this.layoutCorrected,i,f)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new Vms),this.sharedNodes.get(l).add(i);const h=i.options.initialPromotionConfig;i.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.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 h=this.getStack();h&&h.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 h={};d.z&&Lme("z",l,h,this.animationValues);for(let f=0;f{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(o6e),this.root.sharedNodes.clear()}}}function Gms(t){t.updateLayout()}function Kms(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;o==="size"?lx(g=>{const v=l?s.measuredBox[g]:s.layoutBox[g],_=wh(v);v.min=n[g].min,v.max=v.min+_}):zXe(o,s.layoutBox,n)&&lx(g=>{const v=l?s.measuredBox[g]:s.layoutBox[g],_=wh(n[g]);v.max=v.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[g].max=t.relativeTarget[g].min+_)});const i=m4();TI(i,n,s.layoutBox);const d=m4();l?TI(d,t.applyTransform(a,!0),s.measuredBox):TI(d,n,s.layoutBox);const h=!PXe(i);let f=!1;if(!t.resumeFrom){const g=t.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:v,layout:_}=g;if(v&&_){const j=wd();Kae(j,s.layoutBox,v.layoutBox);const w=wd();Kae(w,n,_.layoutBox),LXe(j,w)||(f=!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:h,hasRelativeLayoutChanged:f})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Zms(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 Yms(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Xms(t){t.clearSnapshot()}function o6e(t){t.clearMeasurements()}function l6e(t){t.isLayoutDirty=!1}function Qms(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function c6e(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Jms(t){t.resolveTargetDelta()}function eps(t){t.calcProjection()}function tps(t){t.resetSkewAndRotation()}function sps(t){t.removeLeadSnapshot()}function d6e(t,s,r){t.translate=rc(s.translate,0,r),t.scale=rc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function u6e(t,s,r,n){t.min=rc(s.min,r.min,n),t.max=rc(s.max,r.max,n)}function rps(t,s,r,n){u6e(t.x,s.x,r.x,n),u6e(t.y,s.y,r.y,n)}function nps(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const aps={duration:.45,ease:[.4,0,.1,1]},h6e=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),m6e=h6e("applewebkit/")&&!h6e("chrome/")?Math.round:ef;function p6e(t){t.min=m6e(t.min),t.max=m6e(t.max)}function ips(t){p6e(t.x),p6e(t.y)}function zXe(t,s,r){return t==="position"||t==="preserve-aspect"&&!Tms(s6e(s),s6e(r),.2)}function ops(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const lps=FXe({attachResizeListener:(t,s)=>u6(t,"resize",s),measureScroll:()=>{var t,s;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((s=document.body)==null?void 0:s.scrollTop)||0}},checkIsScrollRoot:()=>!0}),Dme={current:void 0},BXe=FXe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Dme.current){const t=new lps({});t.mount(window),t.setOptions({layoutScroll:!0}),Dme.current=t}return Dme.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),$Xe=T.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function cps(t=!0){const s=T.useContext(owe);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=T.useId();T.useEffect(()=>{if(t)return a(o)},[t]);const l=T.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const UXe=T.createContext({strict:!1}),f6e={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 g6e=!1;function dps(){if(g6e)return;const t={};for(const s in f6e)t[s]={isEnabled:r=>f6e[s].some(n=>!!r[n])};xXe(t),g6e=!0}function qXe(){return dps(),tms()}function ups(t){const s=qXe();for(const r in t)s[r]={...s[r],...t[r]};xXe(s)}const hps=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 Zae(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||hps.has(t)}let VXe=t=>!Zae(t);function mps(t){typeof t=="function"&&(VXe=s=>s.startsWith("on")?!Zae(s):t(s))}try{mps(require("@emotion/is-prop-valid").default)}catch{}function pps(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||(VXe(a)||r===!0&&Zae(a)||!s&&!Zae(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const Vle=T.createContext({});function fps(t,s){if(qle(t)){const{initial:r,animate:n}=t;return{initial:r===!1||d6(r)?r:void 0,animate:d6(n)?n:void 0}}return t.inherit!==!1?s:{}}function gps(t){const{initial:s,animate:r}=fps(t,T.useContext(Vle));return T.useMemo(()=>({initial:s,animate:r}),[x6e(s),x6e(r)])}function x6e(t){return Array.isArray(t)?t.join(" "):t}const Lwe=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function HXe(t,s,r){for(const n in s)!Ru(s[n])&&!kXe(n,r)&&(t[n]=s[n])}function xps({transformTemplate:t},s){return T.useMemo(()=>{const r=Lwe();return Iwe(r,s,t),Object.assign({},r.vars,r.style)},[s])}function yps(t,s){const r=t.style||{},n={};return HXe(n,r,t),Object.assign(n,xps(t,s)),n}function vps(t,s){const r={},n=yps(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 WXe=()=>({...Lwe(),attrs:{}});function _ps(t,s,r,n){const a=T.useMemo(()=>{const o=WXe();return NXe(o,s,CXe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};HXe(o,t.style,t),a.style={...o,...a.style}}return a}const bps=["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 Dwe(t){return typeof t!="string"||t.includes("-")?!1:!!(bps.indexOf(t)>-1||/[A-Z]/u.test(t))}function wps(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??Dwe(t)?_ps:vps)(s,n,a,t),h=pps(s,typeof t=="string",o),f=t!==T.Fragment?{...h,...d,ref:r}:{},{children:g}=s,v=T.useMemo(()=>Ru(g)?g.get():g,[g]);return T.createElement(t,{...f,children:v})}function jps({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:kps(r,n,a,t),renderState:s()}}function kps(t,s,r,n){const a={},o=n(t,{});for(const v in o)a[v]=$se(o[v]);let{initial:l,animate:i}=t;const d=qle(t),h=fXe(t);s&&h&&!d&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let f=r?r.initial===!1:!1;f=f||l===!1;const g=f?i:l;if(g&&typeof g!="boolean"&&!Ule(g)){const v=Array.isArray(g)?g:[g];for(let _=0;_(s,r)=>{const n=T.useContext(Vle),a=T.useContext(owe),o=()=>jps(t,s,n,a);return r?o():jds(o)},Nps=GXe({scrapeMotionValuesFromProps:Pwe,createRenderState:Lwe}),Sps=GXe({scrapeMotionValuesFromProps:MXe,createRenderState:WXe}),Cps=Symbol.for("motionComponentSymbol");function Mps(t,s,r){const n=T.useRef(r);T.useInsertionEffect(()=>{n.current=r});const a=T.useRef(null);return T.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 KXe=T.createContext({});function VC(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Tps(t,s,r,n,a,o){var E,D;const{visualElement:l}=T.useContext(Vle),i=T.useContext(UXe),d=T.useContext(owe),h=T.useContext($Xe),f=h.reducedMotion,g=h.skipAnimations,v=T.useRef(null),_=T.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:f,skipAnimations:g,isSVG:o}),_.current&&v.current&&(v.current.manuallyAnimateOnMount=!0));const j=v.current,w=T.useContext(KXe);j&&!j.projection&&a&&(j.type==="html"||j.type==="svg")&&Aps(v.current,r,a,w);const k=T.useRef(!1);T.useInsertionEffect(()=>{j&&k.current&&j.update(r,d)});const M=r[sXe],S=T.useRef(!!M&&typeof window<"u"&&!((E=window.MotionHandoffIsComplete)!=null&&E.call(window,M))&&((D=window.MotionHasOptimisedAnimation)==null?void 0:D.call(window,M)));return Nds(()=>{_.current=!0,j&&(k.current=!0,window.MotionIsMounted=!0,j.updateFeatures(),j.scheduleRenderMicrotask(),S.current&&j.animationState&&j.animationState.animateChanges())}),T.useEffect(()=>{j&&(!S.current&&j.animationState&&j.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,M)}),S.current=!1),j.enteringChildren=void 0)}),j}function Aps(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:h,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:ZXe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&VC(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:d,layoutRoot:h})}function ZXe(t){if(t)return t.options.allowProjection!==!1?t.projection:ZXe(t.parent)}function Ome(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&ups(n);const o=r?r==="svg":Dwe(t),l=o?Sps:Nps;function i(h,f){let g;const v={...T.useContext($Xe),...h,layoutId:Eps(h)},{isStatic:_}=v,j=gps(h),w=l(h,_);if(!_&&typeof window<"u"){Ips();const k=Pps(v);g=k.MeasureLayout,j.visualElement=Tps(t,w,v,a,k.ProjectionNode,o)}return e.jsxs(Vle.Provider,{value:j,children:[g&&j.visualElement?e.jsx(g,{visualElement:j.visualElement,...v}):null,wps(t,h,Mps(w,j.visualElement,f),w,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=T.forwardRef(i);return d[Cps]=t,d}function Eps({layoutId:t}){const s=T.useContext(fYe).id;return s&&t!==void 0?s+"-"+t:t}function Ips(t,s){T.useContext(UXe).strict}function Pps(t){const s=qXe(),{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 Lps(t,s){if(typeof Proxy>"u")return Ome;const r=new Map,n=(o,l)=>Ome(o,l,t,s),a=(o,l)=>n(o,l);return new Proxy(a,{get:(o,l)=>l==="create"?n:(r.has(l)||r.set(l,Ome(l,void 0,t,s)),r.get(l))})}const Dps=(t,s)=>s.isSVG??Dwe(t)?new yms(s):new hms(s,{allowProjection:t!==T.Fragment});class Ops extends b_{constructor(s){super(s),s.animationState||(s.animationState=jms(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Ule(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 Rps=0;class Fps extends b_{constructor(){super(...arguments),this.id=Rps++}update(){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;const a=this.node.animationState.setActive("exit",!s);r&&!s&&a.then(()=>{r(this.id)})}mount(){const{register:s,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),s&&(this.unmount=s(this.id))}unmount(){}}const zps={animation:{Feature:Ops},exit:{Feature:Fps}};function fL(t){return{point:{x:t.pageX,y:t.pageY}}}const Bps=t=>s=>Mwe(s)&&t(s,fL(s));function AI(t,s,r,n){return u6(t,s,Bps(r),n)}const YXe=({current:t})=>t?t.ownerDocument.defaultView:null,y6e=(t,s)=>Math.abs(t-s);function $ps(t,s){const r=y6e(t.x,s.x),n=y6e(t.y,s.y);return Math.sqrt(r**2+n**2)}const v6e=new Set(["auto","scroll"]);class XXe{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=O8(this.lastRawMoveEventInfo,this.transformPagePoint));const _=Rme(this.lastMoveEventInfo,this.history),j=this.startEvent!==null,w=$ps(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!j&&!w)return;const{point:k}=_,{timestamp:M}=pu;this.history.push({...k,timestamp:M});const{onStart:S,onMove:E}=this.handlers;j||(S&&S(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),E&&E(this.lastMoveEvent,_)},this.handlePointerMove=(_,j)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=j,this.lastMoveEventInfo=O8(j,this.transformPagePoint),yl.update(this.updatePoint,!0)},this.handlePointerUp=(_,j)=>{this.end();const{onEnd:w,onSessionEnd:k,resumeAnimation:M}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&M&&M(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=Rme(_.type==="pointercancel"?this.lastMoveEventInfo:O8(j,this.transformPagePoint),this.history);this.startEvent&&w&&w(_,S),k&&k(_,S)},!Mwe(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=fL(s),h=O8(d,this.transformPagePoint),{point:f}=h,{timestamp:g}=pu;this.history=[{...f,timestamp:g}];const{onSessionStart:v}=r;v&&v(s,Rme(h,this.history)),this.removeListeners=hL(AI(this.contextWindow,"pointermove",this.handlePointerMove),AI(this.contextWindow,"pointerup",this.handlePointerUp),AI(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(v6e.has(n.overflowX)||v6e.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),yl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),e_(this.updatePoint)}}function O8(t,s){return s?{point:s(t.point)}:t}function _6e(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Rme({point:t},s){return{point:t,delta:_6e(t,QXe(s)),offset:_6e(t,Ups(s)),velocity:qps(s,.1)}}function Ups(t){return t[0]}function QXe(t){return t[t.length-1]}function qps(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=QXe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>np(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>np(s)*2&&(n=t[1]);const o=qp(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 Vps(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?rc(r,t,n.max):Math.min(t,r)),t}function b6e(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 Hps(t,{top:s,left:r,bottom:n,right:a}){return{x:b6e(t.x,r,a),y:b6e(t.y,s,n)}}function w6e(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=l6(s.min,s.max-n,t.min):n>a&&(r=l6(t.min,t.max-a,s.min)),Vx(0,1,r)}function Kps(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 Yye=.35;function Zps(t=Yye){return t===!1?t=0:t===!0&&(t=Yye),{x:j6e(t,"left","right"),y:j6e(t,"top","bottom")}}function j6e(t,s,r){return{min:k6e(t,s),max:k6e(t,r)}}function k6e(t,s){return typeof t=="number"?t:t[s]||0}const Yps=new WeakMap;class Xps{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=wd(),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(fL(g).point),this.stopAnimation()},l=(g,v)=>{const{drag:_,dragPropagation:j,onDragStart:w}=this.getProps();if(_&&!j&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ehs(_),!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),lx(M=>{let S=this.getAxisMotionValue(M).get()||0;if(Ox.test(S)){const{projection:E}=this.visualElement;if(E&&E.layout){const D=E.layout.layoutBox[M];D&&(S=wh(D)*(parseFloat(S)/100))}}this.originPoint[M]=S}),w&&yl.update(()=>w(g,v),!1,!0),Uye(this.visualElement,"transform");const{animationState:k}=this.visualElement;k&&k.setActive("whileDrag",!0)},i=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v;const{dragPropagation:_,dragDirectionLock:j,onDirectionLock:w,onDrag:k}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:M}=v;if(j&&this.currentDirection===null){this.currentDirection=Jps(M),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",v.point,M),this.updateAxis("y",v.point,M),this.visualElement.render(),k&&yl.update(()=>k(g,v),!1,!0)},d=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v,this.stop(g,v),this.latestPointerEvent=null,this.latestPanInfo=null},h=()=>{const{dragSnapToOrigin:g}=this.getProps();(g||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:f}=this.getProps();this.panSession=new XXe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,distanceThreshold:n,contextWindow:YXe(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&&yl.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||!R8(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=Vps(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&&VC(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=Hps(n.layoutBox,s):this.constraints=!1,this.elastic=Zps(r),a!==this.constraints&&!VC(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&lx(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=Kps(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!VC(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=ims(n,a.root,this.visualElement.getTransformPagePoint());let l=Wps(a.layout.layoutBox,o);if(r){const i=r(rms(l));this.hasMutatedConstraints=!!i,i&&(l=vXe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},h=lx(f=>{if(!R8(f,r,this.currentDirection))return;let g=d&&d[f]||{};l&&(g={min:0,max:0});const v=a?200:1e6,_=a?40:1e7,j={type:"inertia",velocity:n?s[f]:0,bounceStiffness:v,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...g};return this.startAxisValueAnimation(f,j)});return Promise.all(h).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return Uye(this.visualElement,s),n.start(jwe(s,n,0,r,this.visualElement,!1))}stopAnimation(){lx(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){lx(r=>{const{drag:n}=this.getProps();if(!R8(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]-rc(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!VC(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};lx(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=Gps({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(),lx(l=>{if(!R8(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:h}=this.constraints[l];i.set(rc(d,h,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Yps.set(this.visualElement,this);const s=this.visualElement.current,r=AI(s,"pointerdown",h=>{const{drag:f,dragListener:g=!0}=this.getProps(),v=h.target,_=v!==s&&Rhs(v);f&&g&&!_&&this.start(h)});let n;const a=()=>{const{dragConstraints:h}=this.getProps();VC(h)&&h.current&&(this.constraints=this.resolveRefConstraints(),n||(n=Qps(s,h.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),yl.read(a);const i=u6(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:h,hasLayoutChanged:f})=>{this.isDragging&&f&&(lx(g=>{const v=this.getAxisMotionValue(g);v&&(this.originPoint[g]+=h[g].translate,v.set(v.get()+h[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=Yye,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function N6e(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function Qps(t,s,r){const n=PPe(t,N6e(r)),a=PPe(s,N6e(r));return()=>{n(),a()}}function R8(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function Jps(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class efs extends b_{constructor(s){super(s),this.removeGroupControls=ef,this.removeListeners=ef,this.controls=new Xps(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ef}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 Fme=t=>(s,r)=>{t&&yl.update(()=>t(s,r),!1,!0)};class tfs extends b_{constructor(){super(...arguments),this.removePointerDownListener=ef}onPointerDown(s){this.session=new XXe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:YXe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:Fme(s),onStart:Fme(r),onMove:Fme(n),onEnd:(o,l)=>{delete this.session,a&&yl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=AI(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let zme=!1;class sfs extends T.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),zme&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Use.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}),zme=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||yl.postRender(()=>{const i=l.getStack();(!i||!i.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:s}=this.props.visualElement;s&&(s.root.didUpdate(),Cwe.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;zme=!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 JXe(t){const[s,r]=cps(),n=T.useContext(fYe);return e.jsx(sfs,{...t,layoutGroup:n,switchLayoutGroup:T.useContext(KXe),isPresent:s,safeToRemove:r})}const rfs={pan:{Feature:tfs},drag:{Feature:efs,ProjectionNode:BXe,MeasureLayout:JXe}};function S6e(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&&yl.postRender(()=>o(s,fL(s)))}class nfs extends b_{mount(){const{current:s}=this.node;s&&(this.unmount=Phs(s,(r,n)=>(S6e(this.node,n,"Start"),a=>S6e(this.node,a,"End"))))}unmount(){}}class afs extends b_{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=hL(u6(this.node.current,"focus",()=>this.onFocus()),u6(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function C6e(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&&yl.postRender(()=>o(s,fL(s)))}class ifs extends b_{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=zhs(s,(a,o)=>(C6e(this.node,o,"Start"),(l,{success:i})=>C6e(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const Xye=new WeakMap,Bme=new WeakMap,ofs=t=>{const s=Xye.get(t.target);s&&s(t)},lfs=t=>{t.forEach(ofs)};function cfs({root:t,...s}){const r=t||document;Bme.has(r)||Bme.set(r,{});const n=Bme.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(lfs,{root:t,...s})),n[a]}function dfs(t,s,r){const n=cfs(s);return Xye.set(t,r),n.observe(t),()=>{Xye.delete(t),n.unobserve(t)}}const ufs={some:0,all:1};class hfs extends b_{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();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:ufs[a]},i=d=>{const{isIntersecting:h}=d;if(this.isInView===h||(this.isInView=h,o&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:f,onViewportLeave:g}=this.node.getProps(),v=h?f:g;v&&v(d)};return dfs(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(mfs(s,r))&&this.startObserver()}unmount(){}}function mfs({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const pfs={inView:{Feature:hfs},tap:{Feature:ifs},focus:{Feature:afs},hover:{Feature:nfs}},ffs={layout:{ProjectionNode:BXe,MeasureLayout:JXe}},gfs={...zps,...pfs,...rfs,...ffs},Un=Lps(gfs,Dps),xfs=[{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 yfs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:xfs.map((s,r)=>e.jsxs(Un.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 Hle={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 M6e({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Ys(),d=vs(),[h,f]=T.useState(!1),[g,v]=T.useState("type"),[_,j]=T.useState(""),[w,k]=T.useState(null),[M,S]=T.useState(!1),[E,D]=T.useState("home_anniversary"),[L,B]=T.useState(""),[$,V]=T.useState(""),[W,G]=T.useState(""),[J,ne]=T.useState(""),[ie,ee]=T.useState("elegant"),[de,oe]=T.useState(null),[ue,ce]=T.useState(null),ge=T.useState(!1);!ge[0]&&t&&s&&(ge[1](!0),f(!0),D(s),r&&k(r),n&&B(n),a&&V(a),o&&G(o),v(n?"details":"contact"));const{data:Te}=zt({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let Ge=Z.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);_&&(Ge=Ge.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:wt,error:Ie}=await Ge;if(Ie)throw Ie;return wt},enabled:!!(i!=null&&i.id)&&h}),{data:ve}=zt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Ge,error:wt}=await Z.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(wt)throw wt;return Ge},enabled:!!(i!=null&&i.id)}),ye=Ge=>{k(Ge.id),B(`${Ge.first_name}${Ge.last_name?" "+Ge.last_name:""}`),V([Ge.address,Ge.city,Ge.state].filter(Boolean).join(", ")),G(Ge.home_anniversary||""),v("details")},Se=Ge=>{D(Ge),v("contact")},Ke=async()=>{var Ge;if(!(!i||!ve)){S(!0);try{const wt={owner_user_id:i.id,contact_id:w,card_type:E,template:ie,recipient_name:L,property_address:$||null,home_anniversary_date:W||null,custom_message:J||null,property_photo_url:de||null,video_url:ue||null,agent_name:ve.name||"Agent",agent_photo_url:ve.avatar_url,agent_phone:ve.phone,agent_email:ve.email,agent_brokerage:((Ge=ve.brokerage)==null?void 0:Ge.name)||null},{error:Ie}=await Z.from("sendable_cards").insert(wt);if(Ie)throw Ie;be.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),Ae()}catch(wt){be.error(wt.message||"Failed to create card")}finally{S(!1)}}},Ae=()=>{f(!1),v("type"),D("home_anniversary"),j(""),k(null),B(""),V(""),G(""),ne(""),ee("elegant"),oe(null),ce(null)},Ee={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"},He=Hle[E],Ue=E==="home_anniversary",De=["home_anniversary","just_listed","just_sold"].includes(E);return e.jsxs(js,{open:h,onOpenChange:Ge=>{Ge?f(!0):(Ae(),l==null||l(!1))},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(Y,{className:"gap-2",children:[e.jsx(ar,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:g==="type"?"What type of card?":g==="contact"?`${Ee[E]} — Choose a Contact`:`${Ee[E]} — Customize`})}),g==="type"&&e.jsx(yfs,{onSelect:Se}),g==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Y,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>v("type"),children:[e.jsx(bi,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search contacts...",value:_,onChange:Ge=>j(Ge.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[Te==null?void 0:Te.map(Ge=>e.jsxs("button",{onClick:()=>ye(Ge),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(Wo,{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:[Ge.first_name," ",Ge.last_name]}),Ge.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Zn,{className:"h-3 w-3"}),Ge.address]})]}),Ge.home_anniversary&&E==="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"})]},Ge.id)),(Te==null?void 0:Te.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(Y,{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(Y,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>v("contact"),children:[e.jsx(bi,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Recipient Name"}),e.jsx(Be,{value:L,onChange:Ge=>B(Ge.target.value),placeholder:"John & Jane Smith"})]}),De&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Property Address"}),e.jsx(Be,{value:$,onChange:Ge=>V(Ge.target.value),placeholder:"123 Main St, Austin, TX"})]}),Ue&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Home Anniversary Date"}),e.jsx(Be,{type:"date",value:W,onChange:Ge=>G(Ge.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Personal Message (optional)"}),e.jsx(Rr,{value:J,onChange:Ge=>ne(Ge.target.value),placeholder:He.defaultMessage,rows:3})]}),e.jsx(pYe,{photoUrl:de,videoUrl:ue,onPhotoChange:oe,onVideoChange:ce,contactId:w}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(Ge=>e.jsxs("button",{onClick:()=>ee(Ge),className:`p-3 rounded-lg border-2 transition-all text-center ${ie===Ge?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${Ge==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":Ge==="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:Ge})]},Ge))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(Y,{variant:"outline",onClick:()=>v("contact"),className:"flex-1",children:"Back"}),e.jsx(Y,{onClick:Ke,disabled:!L||M,className:"flex-1 gap-2",children:M?"Creating...":"Create Card"})]})]})]})]})}const vfs={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 _fs({card:t}){const{user:s}=Ys(),{isGmailConnected:r}=MN(),n=vs(),[a,o]=T.useState(!1),[l,i]=T.useState("");T.useEffect(()=>{a&&t.contact_id&&!l&&Z.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:w})=>{w!=null&&w.email&&i(w.email)})},[a,t.contact_id]);const d={home_anniversary:`🏡 Happy Home Anniversary, ${t.recipient_name}!`,just_listed:`🏠 Just Listed — Check This Out, ${t.recipient_name}!`,just_sold:`🎉 Just Sold! Congrats, ${t.recipient_name}!`,congratulations:`🏆 Congratulations, ${t.recipient_name}!`,birthday:`🎂 Happy Birthday, ${t.recipient_name}!`,holiday:`🎄 Happy Holidays, ${t.recipient_name}!`,thank_you:`💐 Thank You, ${t.recipient_name}!`,thinking_of_you:`💭 Thinking of You, ${t.recipient_name}!`},[h,f]=T.useState(d[t.card_type]||`A Special Card for ${t.recipient_name}!`),[g,v]=T.useState(""),_=`https://cardstudio.relevelup.com/c/${t.share_token}`,j=Wt({mutationFn:async()=>{var E;if(!l)throw new Error("Recipient email is required");const w=`
${g?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:k}=await Z.auth.getSession(),M=(E=k==null?void 0:k.session)==null?void 0:E.access_token,S=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${M}`},body:JSON.stringify({to:l,subject:h,body:w,contactId:t.contact_id||void 0})});if(!S.ok){const D=await S.json();throw new Error(D.error||"Failed to send")}return S.json()},onSuccess:async()=>{await Z.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),be.success(`Card sent to ${l}!`),o(!1)},onError:w=>{be.error(w.message||"Failed to send email")}});return r?e.jsxs(js,{open:a,onOpenChange:o,children:[e.jsx(Fi,{asChild:!0,children:e.jsx(Y,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Wa,{className:"h-3 w-3"})})}),e.jsxs(_s,{className:"sm:max-w-md",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"To"}),e.jsx(Be,{type:"email",value:l,onChange:w=>i(w.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Subject"}),e.jsx(Be,{value:h,onChange:w=>f(w.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Personal Note (optional)"}),e.jsx(Rr,{value:g,onChange:w=>v(w.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:_})]}),e.jsx(Y,{onClick:()=>j.mutate(),disabled:!l||j.isPending,className:"w-full gap-2",children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(Y,{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(Wa,{className:"h-3 w-3"})})}function bfs({card:t}){const s=vs(),[r,n]=T.useState(!1),[a,o]=T.useState(!1),[l,i]=T.useState(t.recipient_name),[d,h]=T.useState(t.property_address||""),[f,g]=T.useState(t.home_anniversary_date||""),[v,_]=T.useState(t.custom_message||""),[j,w]=T.useState(t.template),[k,M]=T.useState(t.property_photo_url),[S,E]=T.useState(t.video_url||null),D=B=>{B&&(i(t.recipient_name),h(t.property_address||""),g(t.home_anniversary_date||""),_(t.custom_message||""),w(t.template),M(t.property_photo_url),E(t.video_url||null)),n(B)},L=async()=>{if(!l.trim()){be.error("Recipient name is required");return}o(!0);try{const{error:B}=await Z.from("sendable_cards").update({recipient_name:l.trim(),property_address:d.trim()||null,home_anniversary_date:f||null,custom_message:v.trim()||null,template:j,property_photo_url:k||null,video_url:S||null}).eq("id",t.id);if(B)throw B;s.invalidateQueries({queryKey:["sendable-cards"]}),be.success("Card updated"),n(!1)}catch(B){be.error(B.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(js,{open:r,onOpenChange:D,children:[e.jsx(Fi,{asChild:!0,children:e.jsx(Y,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Xa,{className:"h-3 w-3"})})}),e.jsxs(_s,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Ps,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Recipient Name"}),e.jsx(Be,{value:l,onChange:B=>i(B.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Property Address"}),e.jsx(Be,{value:d,onChange:B=>h(B.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Home Anniversary Date"}),e.jsx(Be,{type:"date",value:f,onChange:B=>g(B.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Personal Message (optional)"}),e.jsx(Rr,{value:v,onChange:B=>_(B.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(pYe,{photoUrl:k,videoUrl:S,onPhotoChange:M,onVideoChange:E,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(je,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(B=>e.jsxs("button",{onClick:()=>w(B),className:`p-3 rounded-lg border-2 transition-all text-center ${j===B?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${B==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":B==="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:B})]},B))})]}),e.jsx(Y,{onClick:L,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Us,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function wfs(){const{user:t}=Ys(),s=vs(),[r,n]=T.useState(""),[a,o]=Oc(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),h=a.get("address"),f=a.get("date"),g=!!l,{data:v,isLoading:_}=zt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:E,error:D}=await Z.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(D)throw D;return E},enabled:!!(t!=null&&t.id)}),j=Wt({mutationFn:async E=>{const{error:D}=await Z.from("sendable_cards").delete().eq("id",E);if(D)throw D},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),be.success("Card deleted")}}),w=E=>{const D=`https://cardstudio.relevelup.com/c/${E}`;navigator.clipboard.writeText(D),be.success("Share link copied!")},k=v==null?void 0:v.filter(E=>{var D;return!r||E.recipient_name.toLowerCase().includes(r.toLowerCase())||((D=E.property_address)==null?void 0:D.toLowerCase().includes(r.toLowerCase()))}),M={elegant:"Elegant",bold:"Bold",warm:"Warm"},S={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(Vs,{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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Card Studio"}),e.jsx(E1e,{})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create & send beautiful branded cards to your clients"})]}),e.jsx(M6e,{initialOpen:g,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:h||void 0,initialDate:f||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(On,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Be,{placeholder:"Search cards...",value:r,onChange:E=>n(E.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(E=>e.jsx(Oe,{className:"animate-pulse",children:e.jsxs($e,{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"})]})},E))}):k!=null&&k.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:k.map(E=>e.jsxs(Oe,{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 ${E.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":E.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:[E.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"})]}),E.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%)]"})]}),E.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:E.card_type==="home_anniversary"?"🏡":E.card_type==="birthday"?"🎂":E.card_type==="just_sold"?"🎉":E.card_type==="just_listed"?"🏠":E.card_type==="thank_you"?"💐":E.card_type==="congratulations"?"🏆":E.card_type==="holiday"?"🎄":E.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${E.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:S[E.card_type]||E.card_type}),e.jsx("p",{className:`font-semibold text-base ${E.template==="bold"?"text-white":"text-foreground"}`,children:E.recipient_name}),E.property_address&&e.jsx("p",{className:`text-xs mt-1 ${E.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:E.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(ct,{variant:E.template==="bold"?"outline":"secondary",className:`text-[10px] ${E.template==="bold"?"border-white/30 text-white/80":""}`,children:M[E.template]||E.template})})]}),e.jsxs($e,{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(wi,{className:"h-3 w-3"}),E.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_u(new Date(E.created_at),{addSuffix:!0})})]}),E.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",Bs(new Date(E.sent_at),"MMM d, yyyy")," via ",E.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(Y,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>w(E.share_token),children:[e.jsx(Di,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(bfs,{card:E}),e.jsx(_fs,{card:E}),e.jsx(Y,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${E.share_token}`,"_blank"),children:e.jsx(bn,{className:"h-3 w-3"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>j.mutate(E.id),children:e.jsx(Ir,{className:"h-3 w-3"})})]})]})]},E.id))}):e.jsx(Oe,{className:"border-dashed",children:e.jsxs($e,{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(zr,{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(M6e,{initialOpen:g,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:h||void 0,initialDate:f||void 0,onOpenChange:()=>o({})})]})})]})})}function VA({delay:t,x:s,y:r,size:n}){return e.jsx(Un.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 jfs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:h,agentBrokerage:f,propertyPhotoUrl:g,videoUrl:v}=t,_=Hle[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(Un.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(Un.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(VA,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(VA,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(VA,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(VA,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(VA,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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}),f&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:f})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[d&&e.jsxs(Un.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(Ha,{className:"h-3.5 w-3.5"})," Call"]}),h&&e.jsxs(Un.a,{href:`mailto:${h}`,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(zr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Un.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 $me({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(Un.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 HA({delay:t,x:s,y:r}){return e.jsx(Un.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 T6e={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 kfs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:h,agentBrokerage:f,propertyPhotoUrl:g,videoUrl:v}=t,_=Hle[s],j=T6e[s]||T6e.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${j.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx($me,{delay:0,x:"10%",y:"10%",color:j.orbs[0],size:200}),e.jsx($me,{delay:1,x:"70%",y:"60%",color:j.orbs[1],size:180}),e.jsx($me,{delay:2,x:"50%",y:"20%",color:j.orbs[2],size:150}),e.jsx(HA,{delay:0,x:"20%",y:"25%"}),e.jsx(HA,{delay:.8,x:"75%",y:"15%"}),e.jsx(HA,{delay:1.6,x:"85%",y:"65%"}),e.jsx(HA,{delay:2.4,x:"10%",y:"75%"}),e.jsx(HA,{delay:.4,x:"45%",y:"85%"}),e.jsxs(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Zn,{className:"h-3.5 w-3.5"}),n]})]}),g&&e.jsx(Un.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(Un.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(Un.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(Un.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(Un.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}),f&&e.jsx("p",{className:"text-xs text-violet-300/60",children:f})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[d&&e.jsxs(Un.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(Ha,{className:"h-3.5 w-3.5"})," Call Me"]}),h&&e.jsxs(Un.a,{href:`mailto:${h}`,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(zr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Un.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 Nfs({emoji:t,delay:s,x:r,duration:n}){return e.jsx(Un.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 A6e={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 Sfs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:h,agentBrokerage:f,propertyPhotoUrl:g,videoUrl:v}=t,_=Hle[s],j=A6e[s]||A6e.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${j.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[_.emojis.map((w,k)=>e.jsx(Nfs,{emoji:w,delay:k*1.2,x:`${15+k*14}%`,duration:5+k%3},k)),e.jsx(Un.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(Un.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(Un.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(Un.div,{className:`h-28 bg-gradient-to-r ${j.header} relative overflow-hidden`,children:[e.jsx(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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(Un.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 ${j.accent}`,children:[e.jsx(Un.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(Un.h1,{className:`text-3xl font-bold ${j.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[_.title.join(" ")," ",_.emojis[4]]}),e.jsxs(Un.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:`text-lg font-semibold ${j.text} mb-1`,children:r}),n&&e.jsxs("p",{className:`text-sm ${j.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[e.jsx(Gi,{className:"h-3 w-3"}),n]})]}),g&&e.jsx(Un.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(Un.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(Un.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 ${j.text} leading-relaxed italic`,children:['"',o||_.defaultMessage,'"']})}),e.jsxs(Un.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(Un.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 ${j.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 ${j.accent}`,children:l}),f&&e.jsx("p",{className:`text-xs ${j.text} opacity-60`,children:f})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(Un.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${j.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Ha,{className:"h-3.5 w-3.5"})," Call"]}),h&&e.jsxs(Un.a,{href:`mailto:${h}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${j.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(zr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Un.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 eQe(){const{shareToken:t}=wl(),{data:s,isLoading:r,error:n}=zt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await Z.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(T.useEffect(()=>{t&&Z.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(kfs,{...o});case"warm":return e.jsx(Sfs,{...o});case"elegant":default:return e.jsx(jfs,{...o})}}const tQe=()=>{const t=pm();return T.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 Cfs(){return T.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs($8e,{children:[e.jsx(nr,{path:"/c/:shareToken",element:e.jsx(eQe,{})}),e.jsx(nr,{path:"*",element:e.jsx(tQe,{})})]})}const Mfs=({team:t,onSelect:s})=>{const{data:r}=zt({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await Z.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 Z.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(Oe,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Ht,{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(Gt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(Tr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(ct,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(br,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs($e,{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(_a,{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(kh,{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(Bu,{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(ct,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(ct,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(ct,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},Tfs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Ys(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:d,isLoading:h,createTeam:f,updateTeam:g,deleteTeam:v,addMember:_,removeMember:j,updateMemberRole:w}=CN(i),[k,M]=T.useState(!1),[S,E]=T.useState(null),{data:D}=zt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:$,error:V}=await Z.from("brokerages").select("id, name").order("name");if(V)throw V;return $||[]},enabled:s}),{data:L}=zt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:$,error:V}=await Z.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(V)throw V;return $||[]},enabled:!!l}),B=async $=>{const V=$.brokerage_id||l||null,W=await f.mutateAsync({name:$.name,brokerage_id:V,description:$.description});if($.leaderId&&$.leaderId!=="none"&&await _.mutateAsync({team_id:W.id,user_id:$.leaderId,role:"team_leader"}),$.memberIds)for(const G of $.memberIds)await _.mutateAsync({team_id:W.id,user_id:G,role:"team_member"});M(!1)};return!r&&!s?e.jsx(Vs,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(br,{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(Vs,{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(Y,{onClick:()=>M(!0),children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(eHe,{open:k,onOpenChange:M,onCreateTeam:B,isCreating:f.isPending,brokerageAgents:L||[],isAdmin:s,allBrokerages:D,activeBrokerageId:l}),h&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map($=>e.jsx(Oe,{children:e.jsxs($e,{className:"p-6",children:[e.jsx(ys,{className:"h-5 w-32 mb-3"}),e.jsx(ys,{className:"h-4 w-48 mb-4"}),e.jsx(ys,{className:"h-8 w-full"})]})},$))}),!h&&d.length===0&&!S&&e.jsx(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(br,{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(Y,{onClick:()=>M(!0),children:[e.jsx(ar,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!h&&d.length>0&&!S&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:d.map($=>e.jsx(Mfs,{team:$,onSelect:()=>E($)},$.id))}),S&&e.jsx(JVe,{team:S,brokerageAgents:L||[],onBack:()=>E(null),onUpdate:$=>g.mutateAsync({id:S.id,...$}).then(V=>E(V)),onAddMember:($,V)=>_.mutateAsync({team_id:S.id,user_id:$,role:V}),onRemoveMember:$=>j.mutateAsync({team_id:S.id,member_id:$}),onUpdateRole:($,V)=>w.mutateAsync({team_id:S.id,member_id:$,role:V}),onDeleteTeam:()=>v.mutate(S.id),isUpdating:g.isPending,isAddingMember:_.isPending})]})})},Afs=()=>{const{data:t,isLoading:s}=h_(),{useTeamMembers:r}=CN(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Vs,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ys,{className:"h-8 w-48"}),e.jsx(ys,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Vs,{title:"My Team",description:"Your team",children:e.jsx(Oe,{children:e.jsxs($e,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(br,{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(Vs,{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(ct,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(kh,{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(Qa,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Ga,{className:"flex-wrap",children:[e.jsx(Fs,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(Fs,{value:"contacts",children:[e.jsx(bk,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(Fs,{value:"lead-pond",children:[e.jsx(Nx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(Fs,{value:"shared-assets",children:[e.jsx(om,{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(ys,{className:"h-16 w-full"},l))}):n.map(l=>{var i,d,h,f;return e.jsx(Oe,{children:e.jsxs($e,{className:"flex items-center gap-3 p-4",children:[e.jsxs(fn,{className:"h-10 w-10",children:[e.jsx(_a,{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:((h=l.profile)==null?void 0:h.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(f=l.profile)==null?void 0:f.email})]}),l.role==="team_leader"?e.jsxs(ct,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(kh,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(ct,{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(D_e,{})}),o.lead_pond_enabled&&e.jsx(Zs,{value:"lead-pond",className:"space-y-4",children:e.jsx(O_e,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(Zs,{value:"shared-assets",className:"space-y-4",children:e.jsx(QVe,{teamId:t.teamId})})]})]})})},Efs=new Clt,Ifs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},Pfs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},Lfs=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},Dfs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},Ofs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},Rfs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},Ffs=()=>e.jsx(Ilt,{client:Efs,children:e.jsx(K8e,{children:e.jsxs(bN,{children:[e.jsx(Gat,{}),e.jsx(Nit,{}),e.jsx(Vct,{children:e.jsx(Zht,{children:e.jsx(Yht,{children:e.jsxs(Qht,{children:[e.jsx(Xht,{}),e.jsx(Aft,{}),e.jsx(Wft,{}),Rfs()?e.jsx(Cfs,{}):Pfs()?e.jsx(uxt,{}):Ifs()?e.jsx(Pgt,{}):Lfs()?e.jsx(pxt,{}):Dfs()?e.jsx(jvt,{}):Ofs()?e.jsx(qvt,{}):e.jsxs($8e,{children:[e.jsx(nr,{path:"/",element:e.jsx(Qvt,{})}),e.jsx(nr,{path:"/privacy-policy",element:e.jsx(Jvt,{})}),e.jsx(nr,{path:"/terms-of-service",element:e.jsx(e1t,{})}),e.jsx(nr,{path:"/data-deletion",element:e.jsx(t1t,{})}),e.jsx(nr,{path:"/public/listings",element:e.jsx(N7e,{})}),e.jsx(nr,{path:"/public/listing/:slugOrId",element:e.jsx(rwt,{})}),e.jsx(nr,{path:"/card/:slug",element:e.jsx(nwt,{})}),e.jsx(nr,{path:"/join-brokerage/:slug",element:e.jsx(Hcs,{})}),e.jsx(nr,{path:"/recruit-video/:shareToken",element:e.jsx(Gcs,{})}),e.jsx(nr,{path:"/auth",element:e.jsx(r1t,{})}),e.jsx(nr,{path:"/subscription-success",element:e.jsx(n1t,{})}),e.jsx(nr,{path:"/subscription",element:e.jsx(Sr,{children:e.jsx(ubt,{})})}),e.jsx(nr,{path:"/share/video",element:e.jsx(Jbt,{}),children:e.jsx(nr,{path:":shareToken",element:e.jsx(Qbt,{})})}),e.jsx(nr,{path:"/p/:shareToken",element:e.jsx(pds,{})}),e.jsx(nr,{path:"/portal/:slug",element:e.jsx(bds,{})}),e.jsx(nr,{path:"/og/video/:token",element:e.jsx(ewt,{})}),e.jsx(nr,{path:"/setup-brokerage",element:e.jsx(Sr,{children:e.jsx(hbt,{})})}),e.jsx(nr,{path:"/claim-account",element:e.jsx(f5e,{})}),e.jsx(nr,{path:"/claim",element:e.jsx(f5e,{})}),e.jsx(nr,{path:"/join",element:e.jsx(mbt,{})}),e.jsx(nr,{path:"/trial",element:e.jsx(kbt,{})}),e.jsx(nr,{path:"/trial/success",element:e.jsx(Nbt,{})}),e.jsx(nr,{path:"/dashboard",element:e.jsx(Sr,{children:e.jsx(l2t,{})})}),e.jsx(nr,{path:"/profile",element:e.jsx(Sr,{children:e.jsx(W3t,{})})}),e.jsx(nr,{path:"/apps",element:e.jsx(Sr,{children:e.jsx(aMt,{})})}),e.jsx(nr,{path:"/admin",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(VAt,{})})}),e.jsx(nr,{path:"/admin/apps",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(GAt,{})})}),e.jsx(nr,{path:"/admin/members",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(tEt,{})})}),e.jsx(nr,{path:"/admin/invite-codes",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(sEt,{})})}),e.jsx(nr,{path:"/admin/events",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(lEt,{})})}),e.jsx(nr,{path:"/events",element:e.jsx(Sr,{children:e.jsx(sMt,{})})}),e.jsx(nr,{path:"/events/:eventId",element:e.jsx(Sr,{children:e.jsx(nMt,{})})}),e.jsx(nr,{path:"/templates",element:e.jsx(Sr,{children:e.jsx(iMt,{})})}),e.jsx(nr,{path:"/templates/:templateId",element:e.jsx(Sr,{children:e.jsx(dMt,{})})}),e.jsx(nr,{path:"/admin/templates",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(cEt,{})})}),e.jsx(nr,{path:"/academy",element:e.jsx(Sr,{children:e.jsx(uMt,{})})}),e.jsx(nr,{path:"/academy/:videoId",element:e.jsx(Sr,{children:e.jsx(mMt,{})})}),e.jsx(nr,{path:"/admin/academy",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(uEt,{})})}),e.jsx(nr,{path:"/toolbox",element:e.jsx(Sr,{children:e.jsx(pMt,{})})}),e.jsx(nr,{path:"/toolbox/:kitId",element:e.jsx(Sr,{children:e.jsx(fMt,{})})}),e.jsx(nr,{path:"/admin/toolbox",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(hEt,{})})}),e.jsx(nr,{path:"/social-swag",element:e.jsx(Sr,{children:e.jsx(gMt,{})})}),e.jsx(nr,{path:"/social-swag-2",element:e.jsx(Sr,{children:e.jsx(pAt,{})})}),e.jsx(nr,{path:"/social-swag/:swagId",element:e.jsx(Sr,{children:e.jsx(fAt,{})})}),e.jsx(nr,{path:"/social-connections",element:e.jsx(Sr,{children:e.jsx(Kcs,{})})}),e.jsx(nr,{path:"/social-connections/callback",element:e.jsx(Sr,{children:e.jsx(Zcs,{})})}),e.jsx(nr,{path:"/social-connections/linkedin-callback",element:e.jsx(Sr,{children:e.jsx(Xcs,{})})}),e.jsx(nr,{path:"/social-connections/google-callback",element:e.jsx(Sr,{children:e.jsx(Ycs,{})})}),e.jsx(nr,{path:"/admin/social-swag",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(mEt,{})})}),e.jsx(nr,{path:"/admin/social-swag-2",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(ePt,{})})}),e.jsx(nr,{path:"/community",element:e.jsx(Sr,{children:e.jsx(LAt,{})})}),e.jsx(nr,{path:"/support",element:e.jsx(Sr,{children:e.jsx(DAt,{})})}),e.jsx(nr,{path:"/admin/community",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(tPt,{})})}),e.jsx(nr,{path:"/admin/support-tickets",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(cPt,{})})}),e.jsx(nr,{path:"/admin/email-templates",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(hPt,{})})}),e.jsx(nr,{path:"/admin/agent-email-templates",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(mPt,{})})}),e.jsx(nr,{path:"/admin/analytics",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(iPt,{})})}),e.jsx(nr,{path:"/admin/brokerage-resources",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(oPt,{})})}),e.jsx(nr,{path:"/admin/dashboard-management",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(lPt,{})})}),e.jsx(nr,{path:"/brokerage/dashboard",element:e.jsx(Sr,{requireBrokerageManager:!0,children:e.jsx(NPt,{})})}),e.jsx(nr,{path:"/brokerage/teams",element:e.jsx(Sr,{requireBrokerageManager:!0,children:e.jsx(Tfs,{})})}),e.jsx(nr,{path:"/my-team",element:e.jsx(Sr,{children:e.jsx(Afs,{})})}),e.jsx(nr,{path:"/my-brokerage",element:e.jsx(Sr,{children:e.jsx(EPt,{})})}),e.jsx(nr,{path:"/brokerage-resources",element:e.jsx(Sr,{requireBrokerageManager:!0,children:e.jsx($At,{})})}),e.jsx(nr,{path:"/brokerage-resources/:resourceId",element:e.jsx(Sr,{requireBrokerageManager:!0,children:e.jsx(UAt,{})})}),e.jsx(nr,{path:"/newsletters",element:e.jsx(Sr,{children:e.jsx(IPt,{})})}),e.jsx(nr,{path:"/newsletters/:id",element:e.jsx(Sr,{children:e.jsx(LPt,{})})}),e.jsx(nr,{path:"/wishlist",element:e.jsx(Sr,{children:e.jsx(RPt,{})})}),e.jsx(nr,{path:"/wishlist/:itemId",element:e.jsx(Sr,{children:e.jsx(FPt,{})})}),e.jsx(nr,{path:"/admin/wishlist",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(zPt,{})})}),e.jsx(nr,{path:"/admin/levelup-brief",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(BPt,{})})}),e.jsx(nr,{path:"/admin/newsletters",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(OPt,{})})}),e.jsx(nr,{path:"/admin/additional-services",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx($Pt,{})})}),e.jsx(nr,{path:"/admin/discounts",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(UPt,{})})}),e.jsx(nr,{path:"/admin/subscriptions",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(qPt,{})})}),e.jsx(nr,{path:"/admin/referrals",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(VPt,{})})}),e.jsx(nr,{path:"/admin/prospector",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(wcs,{})})}),e.jsx(nr,{path:"/admin/recruiting",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(Vcs,{})})}),e.jsx(nr,{path:"/admin/onboarding-checklist",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(WPt,{})})}),e.jsx(nr,{path:"/admin/marketplace",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(Jls,{})})}),e.jsx(nr,{path:"/admin/agent-points",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(jls,{})})}),e.jsx(nr,{path:"/admin/reward-store",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(pcs,{})})}),e.jsx(nr,{path:"/admin/integrations",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(gcs,{})})}),e.jsx(nr,{path:"/admin/integrations/callback",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(bcs,{})})}),e.jsx(nr,{path:"/reward-store",element:e.jsx(Sr,{children:e.jsx(ads,{})})}),e.jsx(nr,{path:"/additional-services",element:e.jsx(Sr,{children:e.jsx(r6t,{})})}),e.jsx(nr,{path:"/additional-services/:serviceId",element:e.jsx(Sr,{children:e.jsx(n6t,{})})}),e.jsx(nr,{path:"/ai-toolkit",element:e.jsx(Sr,{children:e.jsx(a6t,{})})}),e.jsx(nr,{path:"/mission-control",element:e.jsx(Sr,{children:e.jsx(v6t,{})})}),e.jsx(nr,{path:"/mission-control/contacts",element:e.jsx(Sr,{children:e.jsx(H6t,{})})}),e.jsx(nr,{path:"/mission-control/contacts/:contactId",element:e.jsx(Sr,{children:e.jsx(iLt,{})})}),e.jsx(nr,{path:"/mission-control/plans",element:e.jsx(Sr,{children:e.jsx(oLt,{})})}),e.jsx(nr,{path:"/mission-control/popbys",element:e.jsx(Sr,{children:e.jsx(dLt,{})})}),e.jsx(nr,{path:"/mission-control/popbys/map",element:e.jsx(Sr,{children:e.jsx(uLt,{})})}),e.jsx(nr,{path:"/admin/notification-settings",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(ycs,{})})}),e.jsx(nr,{path:"/admin/agent-os",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(KPt,{})})}),e.jsx(nr,{path:"/mission-control/listings",element:e.jsx(Sr,{children:e.jsx(Yas,{})})}),e.jsx(nr,{path:"/mission-control/listings/new",element:e.jsx(Sr,{children:e.jsx(GIe,{})})}),e.jsx(nr,{path:"/mission-control/listings/:listingId",element:e.jsx(Sr,{children:e.jsx(uis,{})})}),e.jsx(nr,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(Sr,{children:e.jsx(GIe,{})})}),e.jsx(nr,{path:"/admin/listing-exchange",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(xls,{})})}),e.jsx(nr,{path:"/mission-control/pipeline",element:e.jsx(Sr,{children:e.jsx(Nos,{})})}),e.jsx(nr,{path:"/mission-control/tasks",element:e.jsx(Sr,{children:e.jsx(Dos,{})})}),e.jsx(nr,{path:"/mission-control/my-card",element:e.jsx(Sr,{children:e.jsx(tls,{})})}),e.jsx(nr,{path:"/mission-control/integrations",element:e.jsx(Sr,{children:e.jsx(cls,{})})}),e.jsx(nr,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(Sr,{children:e.jsx(dls,{})})}),e.jsx(nr,{path:"/mission-control/integrations/canva/callback",element:e.jsx(uls,{})}),e.jsx(nr,{path:"/mission-control/integrations/meta/callback",element:e.jsx(Sr,{children:e.jsx(hls,{})})}),e.jsx(nr,{path:"/mission-control/scorecard",element:e.jsx(Sr,{children:e.jsx(Bas,{})})}),e.jsx(nr,{path:"/admin/scorecard",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(pls,{})})}),e.jsx(nr,{path:"/admin/scorecard/:userId",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(gls,{})})}),e.jsx(nr,{path:"/admin/membership-reviews",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(yls,{})})}),e.jsx(nr,{path:"/admin/weekly-digest",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(bls,{})})}),e.jsx(nr,{path:"/mission-control/video/record",element:e.jsx(Sr,{children:e.jsx(vis,{})})}),e.jsx(nr,{path:"/mission-control/video-library",element:e.jsx(Sr,{children:e.jsx(Nis,{})})}),e.jsx(nr,{path:"/marketplace",element:e.jsx(Sr,{children:e.jsx(Qcs,{})})}),e.jsx(nr,{path:"/marketplace/:productId",element:e.jsx(Sr,{children:e.jsx(Jcs,{})})}),e.jsx(nr,{path:"/marketplace/cart",element:e.jsx(Sr,{children:e.jsx(eds,{})})}),e.jsx(nr,{path:"/marketplace/orders",element:e.jsx(Sr,{children:e.jsx(tds,{})})}),e.jsx(nr,{path:"/marketplace/orders/:orderId",element:e.jsx(Sr,{children:e.jsx(rds,{})})}),e.jsx(nr,{path:"/marketplace/success",element:e.jsx(Sr,{children:e.jsx(nds,{})})}),e.jsx(nr,{path:"/admin/agent-cards",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(kls,{})})}),e.jsx(nr,{path:"/admin/presentation-analytics",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(vcs,{})})}),e.jsx(nr,{path:"/admin/guest-book-analytics",element:e.jsx(Sr,{requireAdmin:!0,children:e.jsx(_cs,{})})}),e.jsx(nr,{path:"/mission-control/presentations",element:e.jsx(Sr,{children:e.jsx(lds,{})})}),e.jsx(nr,{path:"/mission-control/presentations/new",element:e.jsx(Sr,{children:e.jsx(uPe,{})})}),e.jsx(nr,{path:"/mission-control/presentations/:id",element:e.jsx(Sr,{children:e.jsx(uPe,{})})}),e.jsx(nr,{path:"/mission-control/guest-book",element:e.jsx(Sr,{children:e.jsx(gds,{})})}),e.jsx(nr,{path:"/guestbook/:slug",element:e.jsx(_ds,{})}),e.jsx(nr,{path:"/mission-control/card-studio",element:e.jsx(Sr,{children:e.jsx(wfs,{})})}),e.jsx(nr,{path:"/c/:shareToken",element:e.jsx(eQe,{})}),e.jsx(nr,{path:"*",element:e.jsx(tQe,{})})]}),")"]})})})})]})})});eOe(document.getElementById("root")).render(e.jsx(Ffs,{}));